Suggestions for optimizing filtration method.

asked 2015-03-28 09:58:42 -0500

215 gravatar image

updated 2015-03-28 09:59:13 -0500

I made using OpenCv a program, which first checks the most occurring color, and based on that color creates a mask, which then is used to create a binary image based on the mask.

The problem is though this solution doesn't seems so robust for certain color combination.
ex.

image description image descriptionimage description image description

But for some reason does it work perfectly on these pictures.. http://imgur.com/V73gG1U) (http://imgur.com/tVtw75O,IAerON9#1)

The code is here.. http://pastebin.com/KujpZs6r

Any suggestion for improvements ?

edit retag flag offensive close merge delete

Comments

by a quick view on your code, the following:

double max_Hue = HSV_planes[0].at<uchar>(maxVal_hue.x,maxVal_hue.y);
double max_Sat = HSV_planes[1].at<uchar>(maxVal_sat.x,maxVal_sat.y);

should be:

double max_Hue = maxVal_hue.y;
double max_Sat = maxVal_sat.y;

and this:

while (waitKey(1)) 
{
        //imshow("Hue-channel",  src_HSV);
        //imshow("S-channel", HSV_planes[1]);
        //imshow("V-channel", HSV_planes[2]);
        //imshow("histimage",histImg);
        imshow("result", result);
        imshow("Input", src);
}

causes an infinite loop, please discard the while() loop. Now regarding your problem, I think using just a unique value in order to determine a colour is not a good technique. Colours in your image would have a

theodore gravatar imagetheodore ( 2015-03-28 10:22:52 -0500 )edit
1

variety and therefore you would need to specify a range for the specific colour rather than a specific peak/unique value. Have a look in these answers here and here.

theodore gravatar imagetheodore ( 2015-03-28 10:56:17 -0500 )edit