JavaScript
x
22
22
1
import cv2
2
import numpy as np
3
frame = cv2.imread("page.png", 1)
4
5
kernal = np.ones((5, 5), "uint8")
6
7
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
8
lower_blue = np.array([110,50,50])# 80, 255, 0
9
upper_blue = np.array([130,255,255]) # 0, 77, 26
10
11
12
mask = cv2.inRange(hsv, lower_blue, upper_blue)
13
14
15
res = cv2.bitwise_and(frame, frame, mask=mask)
16
17
while True:
18
cv2.imshow("PDF Page", res)
19
if cv2.waitKey(10) & 0xFF == ord('q'):
20
cv2.destroyAllWindows()
21
break
22
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])