Hi,
Adaptivethreshold thresh image relative to the difference between image and a blur image. Blur image is given by a boxfilter (APTIVE_THRESH_MEAN_C) or a gaussian filter (ADAPTIVE_THRESH_GAUSSIAN_C) (line 1332 thresh.cpp). When I use adaptiveThreshold with APTIVE_THRESH_MEAN_C results are stable with various filer size. When I use adaptiveThreshold with APTIVE_THRESH_GAUSSIAN_C results are not stable. homogenous region can be white or black. For example size =9 and 11 give with image in this post
sigma for gaussian blur is given by this ((size-1)0.5 - 1)0.3 + 0.8. I have try with sigma equal to 200000 filter is flat but problem is still here. So I do not understand if somebody can give me an explanation about this.
Thanks in advance
int main (int argc,char **argv)
{
Mat m,im;
char tmp[256];
m=imread("T4wsOW8.jpg",CV_LOAD_IMAGE_GRAYSCALE);
Mat g=cv::getGaussianKernel( 40, 20000, CV_64F );
// Only to check
for (int i=0;i<g.rows;i++)
{
for (int j=0;j<g.cols;j++)
cout<< g.at<double>(i,j)<<"\t";
cout<<"\n********\n";
}
int n=55;
for (int i=5;i<n;i+=2)
{
adaptiveThreshold( m, im, 255,cv::ADAPTIVE_THRESH_GAUSSIAN_C,THRESH_BINARY,i,0);
sprintf(tmp,"adaThreshGau%d.jpg",i);
String s(tmp);
imwrite(s,im);
}
for (int i=5;i<n;i+=2)
{
adaptiveThreshold( m, im, 255,cv::ADAPTIVE_THRESH_MEAN_C,THRESH_BINARY,i,0);
sprintf(tmp,"adaThreshMean%d.jpg",i);
String s(tmp);
imwrite(s,im);
}
return 0;
};