segmentation fault
this code can work the image size 256x256, but not work on 4096x4096. I really confuse where get problem. the img.at<float>(i,j) should not access invalid memory address.
void dustHighValue(Mat & img, float & sigma)
{
int m = img.rows;
int n = img.cols;
copyMakeBorder(img, img,2, 2, 2, 2, BORDER_CONSTANT, Scalar::all(0));
Mat tmp;
Scalar meanValue, stdValue;
for ( int i=2; i<img.rows-2; ++i)
for( int j=2; j<img.cols-2; ++j)
{
tmp=img(Rect(i-1,j-1,3,3));
meanStdDev(tmp, meanValue, stdValue);
if( img.at<float>(i,j) > (sigma * stdValue[0] + meanValue[0]))
{
img.at<float>(i,j) = meanValue[0];
}
}
img=img(Rect(2,2,n,m));
}
first, let's clarify the type . how do you acquire the image, and why do you access it as float ?
again, please highlite, why you think, your image has actually float type. ( if it is not so, (usually images loaded are uchar(nchannels), not float , this might explain your failure.)
the most plausible explanation of your segfault is : you're accessing your image using the wrong type
cerr << img.type() << endl; // returns what ?