I have a function as
void doCorrectIntensityVariation(Mat& image)
{
Mat kernel = getStructuringElement(MORPH_ELLIPSE, Size(19,19));
Mat closed;
morphologyEx(image, closed, MORPH_CLOSE, kernel);
image.convertTo(image, CV_32F); // divide requires floating-point
divide(image, closed, image, 1, CV_32F);
normalize(image, image, 0, 255, NORM_MINMAX);
image.convertTo(image, CV_8UC1); // convert back to unsigned int
imshow("gamma corrected",image); cvWaitKey(0);
}
and
IplImage* processImage(IplImage *imrgb, IplImage *n_im)
{
..................
..................
Mat pre(n_im);
doCorrectIntensityVariation(pre);
n_im=new IplImage( pre);// this line throws segmentation fault (core dumped)
...............
...............
return n_im;
}
My program runs till last line But at the end throws glibc detected * : double free or corruption (!prev): 0x0886dee8 * segmentation fault (core dumped) I have tried all the tricks I knew but I am stuck and dont know what is going wrong