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
try to put 360 into a uchar ;)
so, it's just divided by 2 to make it fit..
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
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]
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#
Related
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.
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
I am working on a project on detecting traffic signs in opencv. I need a good HSV range to filter out red, blue and yellow traffic signs in the urban environment. This is just so that I have a smaller region of interest. So I do not want a highly accurate range but a rough estimate. Can anyone help me out??
You might want to read this link. I extract the interesting part here:
How to find HSV values to track?
This is a common question found in stackoverflow.com. It is very simple and you can use the same function, cv2.cvtColor(). Instead of passing an image, you just pass the BGR values you want. For example, to find the HSV value of Green, try following commands in Python terminal:
green = np.uint8([[[0,255,0 ]]])
hsv_green = cv2.cvtColor(green,cv2.COLOR_BGR2HSV)
print hsv_green
[[[ 60 255 255]]]
Now you take [H-10, 100,100] and [H+10, 255, 255] as lower bound and upper bound respectively. Apart from this method, you can use any image editing tools like GIMP or any online converters to find these values, but don’t forget to adjust the HSV ranges.
I need to quantize the RGB values to 29 uniform color dictionary. I used rgb2ind(image,29) in Matlab.
So, is there any function or efficient way to quantize the image color in OpenCV?
(I need to quantize the image color because i want to get a 29-sized histogram of color)
You will have to make your own. I can reccomend using HSV instead of RGB (you can convert RGB to HSV with opencv). Once the image is converted, you can then simply use 29 ranges for the H value.
EDIT: I saw this answer might be a bit vague for those who have little experience in computer vision. This question gives a lot more information about the difference between HSV and RGB and why this is usefull.
i'm using that guide to detect blobs of a certain color.
On that guide, it check for orange's blob and it use this values:
int orange[3] = {200, 250, 10};
On the guide it says that this values represents the orange in HSV.
I don't know how they calculate this values but i try to check for blue value converting from rgb to hsv but it doesn't work. What i have to detect is this color:
Any ideas on how to determinate HSV values to detect colors? thanks!!
For blue, it can be used as HSV values : [120,255,255]
I calculated it from GIMP, an open-source image processing tool like Photoshop. Similarly you can use any tools to do so.
But remember in OpenCV, Hue ranges from 0-180, S = 0-255, V = 0-255
But in GIMP, it is H = 0-360, S = 0-100, V = 0-100. So you have to apply scaling according to that.
A lot of interactive sites are available on googling. You can try that.
To know how they convert these values, check its wikipedia page.
Or you can check out the OpenCV docs to see how it works in OpenCV :
cvtColor()
I just pasted the relation for you here:
I am reading a book for image processing algorithms and for the contrast
algorithm it says that I can either go RGB->HSL or RGB->HSI first and
than apply a contrast technique for grayscale images, on the lightness component.
Then it gives this formula only, not other formulas for color conversion:
L(x,y) = 0.299*R(x,y) + 0.587*G(x,y) + 0.114*B(x,y)
This formula is neither for the L in HSL, neither for the I in HSI and that is
what confuses me.
Thanks
It's the luma value mentioned in the fourth bullet here: http://en.wikipedia.org/wiki/HSL_and_HSV#Lightness