Saturation tells us how much of that color we have. The way I think about it (not sure if right or not) is to imagine a paint manufactured by adding a powder tint to water. The bigger the number, the more tint you add to the water. That moves the cross in the square from left to right. Notice how the rightest values are "very" blue.
Finally, Brightness tells us how "dark" that color is... Again, the way I look at it is how much light you would put to see the color of the paint. If you almost don't illuminate the water+tint mix, you will see it very dark, while if you put a lot of light, then it will eventually very bright. Moving the slider will move the cross in the square up and down. The others stay constant.
And why to we care about this? Because basically we can easily segment the image by picking values of HSV that are close to each other. See the code here to understand that. In that example, we want to pick a red ball, so, we first segment the Hue (first value on the triplet) by looking at Hue<6 or Hue>175.
Then, we want to pick like a sphere of value around those colors. The sphere that contains more saturated reds or lightest ones. We don't want something that looks like grey or black... We do by computing the distance of (S,V) to (255,255).
Finally we AND both to pick the pixels that match both conditions.
Hope this clarifies whole thing. Just some final remarks.
- How to find what is our HSV? The code that I showed here actually does it real time on the screen. Very useful to debug. Other ways to do it is using the above utility, or you can just use MS Paint or GIMP. Other util which I didn't actually even tried...
- Notice that value range of HSV change from program to program/explanation. In Wikipedia, the ranges seem to be H: 0-360, S:0-1, V:0-1. But in OpenCV, these are H: 0 - 179, S: 0 - 255, V: 0 - 255. See here for more info. FYI MS Paint uses 0-240 for all 3 (HSV).
- Color in OpenCV explained here
- Good tutorial/app (the shown above).
- A tutorial here.
No comments:
Post a Comment