HSV colorspace clarification [closed]

asked 2016-06-24 03:50:49 -0500

VanGog gravatar image

I read that OpenCV uses 0-179° of Hue. In this link the best voted answer is that docs state that OpenCV uses 0-360°. But I did not find that paragraph stating that. What is thruth? I guess the fist. But main reason why I create this question, is it save to use this namespace or can I lose information. I often use Photoshop where the range is 360° or RGB o CMYK image. So if read the image savee using iRGB ICC profile, and then read it by OpenCV and then convert it to HSL, work with it, convert it back to RGB and save it, did I lost the information? And if I measure color ranges in Photoshop and then use color ranges for HSV image (converted from RGB) do I loose information. And what if I want to work with 360° degrees, is there any way how to convert to some different data type or namespace which will contain all the data and not lose it? I am used to work with HSV colorspace because this is the most "user friendly" colorspace, it is quite simple to change lightness or hue or saturation in this colorspace so this is why I am worried about inaccuracies.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-08 07:45:17.898442


LorenaGdL gravatar imageLorenaGdL ( 2016-06-24 04:01:23 -0500 )edit

all hsv colorspace calculations work on the 0-360 range, H ist just stored in 0-180 range, to fit into a byte.

berak gravatar imageberak ( 2016-06-24 04:18:58 -0500 )edit

clarification to @berak's: 0-180 range modification is only performed when using 8-bits images. Otherwise, H is stored in 0-360 range

LorenaGdL gravatar imageLorenaGdL ( 2016-06-24 04:24:31 -0500 )edit

Thanks for explanation! So what image type RGB should I use exactly, not to lose it? CV_8U1, CV_8U3 will cause data lost. Do I need to use floats? So basicly I can use HSV but I need to use wider data type. But which one?

VanGog gravatar imageVanGog ( 2016-06-24 06:56:01 -0500 )edit

@LorenaGdL: It should be possible to force range 256 based on this expression: int hrange = depth == CV_32F ? 360 : code == CV_BGR2HSV || code == CV_RGB2HSV || code == CV_BGR2HLS || code == CV_RGB2HLS ? 180 : 256; It is the 3rd parameter of function cvtColor

VanGog gravatar imageVanGog ( 2016-06-26 08:12:30 -0500 )edit