I'm trying to compare every pixel's hue value with a threshold given. If the pixel's hue is between the threshold value given, it will draw a small circle to that particular pixel.
So, what I did is to iterate over every pixel from the photo and compare every pixel to see whether the pixel's hue is between the threshold or not. But, when I was doing this, the speed of iterating over the pixels are very slow. Is there any way to speed up the iterating process?
Here's what I did:
img = cv2.imread("green bottle.jpg")
imgHSV = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
h, w, d = imgHSV.shape
for i in range(h):
for j in range(w):
k = imgHSV[i, j]
if 26 <= k[0] <= 35: # the hue value threshold between 26 to 57
cv2.circle(img, (j, i), 1, (255, 0, 0)) # draw a small circle for every matching result
elif 36 <= k[0] <=77:
cv2.circle(img, (j, 1), 1, (0, 255, 0)) # draw a small circle for every matching result
cv2.imshow("Image", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Thanks in advance!