Select HSV Hue from -30 to 30 in Python?
The color wheel shown has a Hue Range of 0 to 179 I believe. I wish to black out the colors with hue range of -30 to 30 as shown in the right color wheel. Unfortunately, I tried the following number sets for 'lower_hsv' and 'upper_hsv', but they do not work:
20,-20: "error: list index out of range"
-20,20: only blacks out range 0 to 20.
20,160: blacks out everything except what I wanted blacked out.
160,20: "error: list index out of range"
Can someone please tell me how I can get the image to display as shown on the right color wheel? I will need to black out several different colors on a different image.
import cv2
import numpy as np
image = cv2.imread("hsvColorCircle.png")
imageHSV = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
image_lower_hsv = np.array([0, 200, 220])
image_upper_hsv = np.array([20, 255, 255])
imageMask = cv2.inRange(imageHSV, image_lower_hsv, image_upper_hsv)
_2, imageMaskContours, imageMaskHierarchy = cv2.findContours(imageMask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
imageCNT = imageMaskContours[0]
imageIndex = -1
imageThickness = 4
imageColor = (0, 0, 0)
cv2.drawContours(image,imageMaskContours,imageIndex,imageColor,-1)
imageResize = cv2.resize(image,(640,480))
cv2.imshow('image', imageResize)
cv2.waitKey(0)
cv2.destroyAllWindows