Filter for red tint - emgucv / opencv

How to filter the image for a red tint? I understand that the red color lies around zero between 330 ° and 30 ° (represented from 15 to 15 in OpenCV?). How can I use this range with the InRange method since there is overflow at 360 ° (180 in OpenCV)?

+4
source share
1 answer

Im detecting the HUE color using the following code:

Mother img_hsv, dst;
cap → image;
cvtColor (image, img_hsv, CV_RGB2HSV);
inRange (img_hsv, Scalar (110, 130, 100), Scalar (140, 255, 255), dst);

where dst is a Mat of the same size as img_hsv and CV_8U.
And your scalars define the filtered color. In my case, this is:

HUE 110 to 140
SAT 130 to 255
VAL 100 to 255

more information here: OpenCV 2.4 InRange ()

I'm not sure about using a shade that overflows the 180 range, but I think you can calculate them separately and then add the resulting mats.

+1
source

All Articles