I use different OpenCV haar cascade classifiers to detect vehicles, traffic signs, and smiles. To obtain better results, I try to filter out the blue which is the background color pixels. To do so, I apply the HSV filter, but I'm confused about the color range.
To select only white, red, and yellow pixels, how should I define lower and upper filter ranges?
When I apply the HSV filter on the image in these ranges, I received this result:
Well, you've set a range of 0..45 for Hue, so that means 0..90 degrees around the Hue wheel. Blue is at 240 degrees, but there is a scale factor of 2 for Hue in OpenCV, to allow 360 degrees of Hue to become 180 because that will fit in uint8
range of 0..255. So you probably want 120, so set range 105..135 and test.
You've set a range of 0..255 for Saturation. That means you don't care how saturated/vivid or unsaturated your blues are, even grey will be ok. So you need to increase the 0 to 50+.
You've set the Value in range 100..255 which means you only want light blues not dark ones. Decrease the 100 if darker blues are ok.
You can also load your image into Nathancy's GUI here which dynamically shows you the selection. If you run that, you get these values:
(hMin = 69 , sMin = 37, vMin = 0), (hMax = 134 , sMax = 255, vMax = 255)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.