Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 784
Sulabh Tiwari Avatar asked Oct 18 '25 08:10

Sulabh Tiwari


1 Answers

You can find the answer on many tutorials (e.g. 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, i.e. BGR. So you probably need this instead:

bgrimg = cv2.cvtColor(hsvimg, cv2.COLOR_HSV2BGR)
like image 200
Miki Avatar answered Oct 19 '25 22:10

Miki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!