I’m trying to do some advanced threshold with cv’s cvAdaptiveThreshold function but it doesn’t seem to work.
Here’s my code:
Iat = cvCreateImage(cvSize( WIDTH, HEIGHT), IPL_DEPTH_8U,1);
cvAdaptiveThreshold(grayImage.getCvImage(), Iat, threshold, CV_ADAPTIVE_THRESH_GAUSSIAN_C,CV_THRESH_BINARY,3,5);
grayDiff = Iat;
Where grayImage is an ofxcvcolorimage and grayDiff an ofxcvgrayscaleimage.
The result is an image in a plain gray color, instead of black and white.
Does anyone has a clue?
Have you tried making grayImage a grayscale image?
in that case I’d ask what threshold you’re using? I generally found that threshold around 1-10 is what gives best results (and I’m pretty sure you have to pass in a greyscale image, not color).
in the first place, yes both your source image and your destination image need to be 1 channel IplImages.
for the threshold value cvAdaptiveThreshold()'s syntax is a little bit funky compared to the normal threshold function: in fact the third parameter of the function is actually the maximum value you want to get, not the minimum value to threshold; look here to get an idea.
so your “threshold” variable should be a plain 255; if you give it a lesser value, ie. 100, you’ll get a grey color wherever you’d expect white