32

Can anybody explain to me why the hue value of an HSV image in OpenCV only goes to 180° and not the full 360°?

I have found somewhere that OpenCV uses a 180° cylinder, but I can not really visualize such a cylinder.

Thanks in advance!
J

JasperV
  • 656
  • 1
  • 9
  • 19

4 Answers4

38

try to put 360 into a uchar ;)

so, it's just divided by 2 to make it fit..

berak
  • 39,159
  • 9
  • 91
  • 89
  • 2
    hmm ? what do you mean ? maybe it should be added, that it's only divided by 2 in the 8bit case ? – berak May 22 '13 at 12:14
  • I didn't express my thought correctly. I meant you checked the same documentation as I did, but read two paragraphs more and found out the actual thing that explains the issue. My point was that the original question is a bit newbie and it took only a couple of seconds to post an answer. – Mikhail May 22 '13 at 12:27
  • 2
    They mean a uchar (i.e. uint8) can only encode numbers 0 to 255. So to make a 0-360 value fit conveniently, the OpenCV people just decided "lets divide it by 2". – Peter Nov 21 '19 at 20:07
22

The ranges that OpenCV manage for HSV format are the following:

For HSV, Hue range is [0,179], Saturation range is [0,255] and Value range is [0,255]. Different softwares use different scales. So if you are comparing OpenCV values with them, you need to normalize these ranges.

Here is the link to the OpenCV documentation that explains it.

http://docs.opencv.org/3.2.0/df/d9d/tutorial_py_colorspaces.html

igauravsehrawat
  • 3,696
  • 3
  • 33
  • 46
Kevin Infante
  • 321
  • 2
  • 2
3

According to http://docs.opencv.org/modules/imgproc/doc/miscellaneous_transformations.html#cvtcolor

For the 8-bit images, H is converted to H/2 to fit to the [0,255] range. So the range of hue in the HSV color space of OpenCV is [0,179]

0

Is it really so?I think for HSV the ranges are as H[0-179], S[0-255], V[0-255].Please see the link and help me understand if I am missing something. http://docs.opencv.org/trunk/doc/py_tutorials/py_imgproc/py_colorspaces/py_colorspaces.html

If you need to convert the range of Hue, see the link below. http://en.literateprograms.org/RGB_to_HSV_color_space_conversion_%28C%29#

hlkstuv_23900
  • 864
  • 20
  • 34