Ask Your Question

ashgabat's profile - activity

2015-12-26 04:08:39 -0600 received badge  Student (source)
2014-11-04 10:13:48 -0600 received badge  Famous Question (source)
2014-08-16 02:20:54 -0600 received badge  Notable Question (source)
2014-07-04 00:20:57 -0600 received badge  Popular Question (source)
2014-02-25 00:27:49 -0600 commented answer Correct HSV InRange Values for 'Red' Objects

Thank you very much! How can I run your code with Java (since yours is in C) or can I use gcc to compile your C code?

2014-02-25 00:25:49 -0600 received badge  Supporter (source)
2014-02-23 23:30:42 -0600 asked a question 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.

  1. How am I still getting results with my current parameters?
  2. 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:

C:\fakepath\Houses8.png

C:\fakepath\GrayOutHSV.png

Thanks in advance.