简体   繁体   中英

Converting HSV to RGB in opencv

My python code:

import numpy as np
hsvimg = np.zeros(10,10,3)
hsvimg[:,:,0] = np.linspace(0.2722,0.4722,10)
hsvimg[:,:,1] = np.linspace(0.5722,0.6522,10)
hsvimg[:,:,2] = np.ones(10)

how can i convert hsv image to rgb, only using opencv

You can find the answer on many tutorials (eg here ) and on OpenCV documentation for cvtColor .

rgbimg = cv2.cvtColor(hsvimg, cv2.COLOR_HSV2RGB)

Note that OpenCV stores RGB values inverting R and B channels, ie BGR. So you probably need this instead:

bgrimg = cv2.cvtColor(hsvimg, cv2.COLOR_HSV2BGR)

Invalid number of channels in input image: 'VScn::contains(scn)' where 'scn' is 4

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM