Ask Your Question

Revision history [back]

I cannot reproduce your problem using this code :

int main(int argc, char* argv[])
{
Mat img = imread("g:/lib/opencv/samples/data/baboon.jpg", IMREAD_COLOR);
if (img.empty())
{
    cout << "check path";
    exit(-1);
}
img.convertTo(img, CV_32F, 1.0f / 255.0f);
imshow("original", img);

Mat gray,contrast;
GaussianBlur(img, img, Size(5, 5), 0, 0);
imshow("blur", img);
if (img.channels() == 3) {
    cvtColor(img, gray, COLOR_BGR2GRAY);
}
else {
    img.copyTo(gray);
}
Laplacian(gray, contrast, CV_32F);
imshow("Laplacian", contrast);
waitKey(0);
return 0;
}

image description

I cannot reproduce your problem using this code :

int main(int argc, char* argv[])
{
Mat img = imread("g:/lib/opencv/samples/data/baboon.jpg", IMREAD_COLOR);
if (img.empty())
{
    cout << "check path";
    exit(-1);
}
img.convertTo(img, CV_32F, 1.0f / 255.0f);
imshow("original", img);

Mat gray,contrast;
GaussianBlur(img, img, Size(5, 5), 0, 0);
imshow("blur", img);
if (img.channels() == 3) {
    cvtColor(img, gray, COLOR_BGR2GRAY);
}
else {
    img.copyTo(gray);
}
Laplacian(gray, contrast, CV_32F);
imshow("Laplacian", contrast);
10*contrast);
waitKey(0);
return 0;
}

image description

I cannot reproduce your problem using this code :

int main(int argc, char* argv[])
{
Mat img = imread("g:/lib/opencv/samples/data/baboon.jpg", IMREAD_COLOR);
if (img.empty())
{
    cout << "check path";
    exit(-1);
}
img.convertTo(img, CV_32F, 1.0f / 255.0f);
imshow("original", img);

Mat gray,contrast;
GaussianBlur(img, img, Size(5, 5), 0, 0);
imshow("blur", img);
if (img.channels() == 3) {
    cvtColor(img, gray, COLOR_BGR2GRAY);
}
else {
    img.copyTo(gray);
}
Laplacian(gray, contrast, CV_32F);
imshow("Laplacian", 10*contrast);
10 * contrast);
normalize(contrast, contrast, 1,0,NORM_MINMAX);
imshow("Laplacian Normalize", contrast);
waitKey(0);
return 0;
}

image descriptionimage description