Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Laplacian output has many white dots (noise)

Hi,

I applied Gaussian, and then laplacian to images. The output has many white dots. Please check the following 2 outputs.

image description

images[i].convertTo(img, CV_32F, 1.0f / 255.0f);
GaussianBlur(img, img, Size(5,5), 0, 0, BORDER_DEFAULT );
if (channels == 3) {
cvtColor(img, gray, COLOR_RGB2GRAY);
}
else {
img.copyTo(gray);
}
Laplacian(gray, contrast, CV_32F);

Could someone please explain why? And how to solve it? Thank you!

Laplacian output has many white dots (noise)

Hi,

I applied Gaussian, and then laplacian to images. The output has many white dots. Please check the following 2 outputs.

image description

images[i].convertTo(img, CV_32F, 1.0f / 255.0f);
GaussianBlur(img, img, Size(5,5), 0, 0, BORDER_DEFAULT );
if (channels == 3) {
cvtColor(img, gray, COLOR_RGB2GRAY);
}
else {
img.copyTo(gray);
}
Laplacian(gray, contrast, CV_32F);

Could someone please explain why? And how to solve it? Thank you!

EDIT: The above code is shown to be valid by LBerger's post. My problem is due to the normalization of the 2 output images by their sum. After division, some pixels tend to infinity. Shown by my following code here

for (size_t i = 0; i < images.size(); i++) {    
    contrast_sum = constrast[i]
}
for (size_t i = 0; i < images.size(); i++) {
    contrast[i] /= contrast_sum;
}