Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cvtColor doesn't take 3-channel images

I have the following code:

img_plane_rgb = imread('baboon.jpg')
img_plane_rgb_sc = img_plane_rgb.astype(float)/255
cv2.cvtColor(img_plane_rgb, img_plane_hsi,cv2.COLOR_BGR2HSV)

The error that I get is

TypeError: only length-1 arrays can be converted to Python scalars

The documentation says that an image read using imread should be usable in cvtColor. Even if I pass img_plane_rgb[1,:,0] as an argument the error persists, even though it is now a 1D array.

What other modification needs to be done to use cvtColor?