Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

read image as HSV vs convert red RBG to HSV?

Hi

Why is the final result of both different?

Reading the image as HSV OR converting a color image into HSV

then,

Extracting the pixels using HSV values should give SAME RESULT

Here's the code for reading image as HSV then selecting HSV value

cim = cv2.imread('OI5.jpg',cv2.COLOR_RGB2HSV)
huemask1 = ((cim >np.array([100,0,0])).astype(np.float32)+(cim>np.array([100,0,0])).astype(np.float32)*(-0.5)+0.5)
mask1_intrd = (huemask1.astype(np.uint8))*255

Here's the OUTPUT

image description

Here's the code for reading image as color, convert to HSV the selecting by HSV Value

cim = cv2.imread('OI5.jpg')

hsvim = cv2.cvtColor(cim,cv2.COLOR_RGB2HSV)

huemask1 = ((hsvim >np.array([100,0,0])).astype(np.float32)+(hsvim>np.array([100,0,0])).astype(np.float32)*(-0.5)+0.5)

mask1_intrd = (huemask1.astype(np.uint8))*255

Here's the OUTPUT

image description