-2

I try to convert a RGB image to HSV color space, and get the HSV value of a pixel. But the result is a little strange, as far as I know, the range of H is between 0 and 360, S and V is between 0 to 255, but the result that I have got is 0~255 for any of HSV value. I doubt that OpenCV have done the transform, is that right? Please help me.

Bing
  • 1
  • 4
  • 1
    See [this question](http://stackoverflow.com/questions/10948589/choosing-correct-hsv-values-for-opencv-thresholding-with-inranges). The H range in opencv is not what you think. – Dan Mašek Apr 04 '16 at 01:01

1 Answers1

0

If you're acquaint with the RGB-HSV conversion, OpenCV uses the following formulas to convert B,G,R values, (0~255) to H,S,V:

V=Max(B,G,R)

S=255*[1-min(B,G,R)/Max(B,G,R)]

let d=Max(B,G,R)-min(B,G,R)

H=30*[((G-B)/d)%6] if V=R

=30*[((B-R)/d)+2] if V=G

=30*[((R-G)/d)+4] if V=B

Saransh Kejriwal
  • 2,467
  • 5
  • 15
  • 39