Converting HSV to RGB in opencv

22,259

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)
Share:
22,259
Sulabh Tiwari
Author by

Sulabh Tiwari

Updated on February 23, 2022

Comments

  • Sulabh Tiwari
    Sulabh Tiwari over 2 years

    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

  • Admin
    Admin over 2 years
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.