Extract hue channel from HSV image in Pillow

1.1k Views Asked by At

I'm trying to extract the hue channel from a pillow image. Below is an illustration:

In [40]: from PIL import Image
In [41]: pillow_img  = Image.open('lekha.jpg')

# convert to HSV    
In [42]: hsv_img = pillow_img.convert('HSV')

# cast it as NumPy array
In [43]: arr_hsv = np.asarray(hsv_img)

Now, how can I extract only the hue channel from the array arr_hsv?

If it's an RGB image, extracting the red channel would translate to:

red_channel =  arr_rgb[:, :, 0]

However, I'm unsure whether this is the same case for HSV as well.

1

There are 1 best solutions below

0
On BEST ANSWER

It's the same.

hue_channel =  arr_hsv[:, :, 0]