import cv2 import numpy as np frame = cv2.imread("page.png", 1) kernal = np.ones((5, 5), "uint8") hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) lower_blue = np.array([110,50,50])# 80, 255, 0 upper_blue = np.array([130,255,255]) # 0, 77, 26 mask = cv2.inRange(hsv, lower_blue, upper_blue) res = cv2.bitwise_and(frame, frame, mask=mask) while True: cv2.imshow("PDF Page", res) if cv2.waitKey(10) & 0xFF == ord('q'): cv2.destroyAllWindows() break
This is a basic Detection of a specific color script in python taken from here. I am trying to work with “#34659F” color. I checked the above values, and they dont correspond to blue region. I check both the uppler and lower values and found that they dont correspond to blue values. I tried to select the upper and lower bound for “#34659F” from here but I am unable to get anything back.
So, I was wondering how those values are selected for any given color.
Advertisement
Answer
These are the values you are looking for.
lower_blue = np.array([60, 0, 0]) upper_blue = np.array([255, 206, 153])