Correct HSV InRange Values for 'Red' Objects
I am using OpenCV 2.4.6 to try to detect white objects in an image that is primarily green-grey. (See the following picture).
I have converted this image into the HSV format and these white objects (houses) as expected are converted into a reddish-orange equivalent when printed out. I've been trying to find the values that cover these reddish oranges so I can then use connected components to detect the objects.
However, experimentally trying to find the ranges has not been working - so far it has produced somewhat adequate results with the range 190 to 255. Looking around, I have found sources saying thresholds of 0 to 10 work, or 110 to 140, but sources also say that the HSV InRange values in OpenCV only range from 0 to 180.
- How am I still getting results with my current parameters?
- How do I detect this red color in the HSV plane?
FYI: There is background noise such as a road and fields but that's not important right now, I just want to find out the 'correct' InRange Values.
Here is a snippet of my current code:
// Convert to HSV for better thresh results Mat src = read from image file; Mat dest = new Mat();
Imgproc.cvtColor(src, dest, Imgproc.COLOR_RGB2HSV);
Highgui.imwrite(outputFilename + "HSV.png", dest);
List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
Core.inRange(dest, new Scalar(190, 0, 0), new Scalar(256, 256, 256), dest);
Highgui.imwrite(outputFilename + "Filter.png", dest);
Pictures:
Thanks in advance.