Imsubtract Returns Black Image

15 visualizaciones (últimos 30 días)
Isaiah Egan
Isaiah Egan el 6 de Mzo. de 2018
Respondida: Image Analyst el 7 de Mzo. de 2018
Hi, I am trying to retrieve the Laplacian pyramid for a given image. Here is a snippet from my code for the n=1 case:
inp = im2double(imread('gray.jpg'));
g = fspecial('gaussian',[5,5], 1.6);
blur = imfilter(inp, g, 'conv');
diff = imsubtract(inp , blur);
figure;
subplot(121);
imshow(blur)
subplot(122);
imshow(diff)
'blur' returns the correct gaussian-filtered image. However, it always returns a black image for the image 'diff'.
I have searched related questions and imsubtract guides, and I have asserted that all of my images have non-zero data in them, and that I am subtracting two images of the same type (double). I am at a loss for how to solve this problem. Any help is greatly appreciated.

Respuesta aceptada

Isaiah Egan
Isaiah Egan el 7 de Mzo. de 2018
Editada: Isaiah Egan el 7 de Mzo. de 2018
The solution: normalize the final image for display with
imshow(mat2gray(diff))

Más respuestas (1)

Image Analyst
Image Analyst el 7 de Mzo. de 2018
Always use [] when using imshow() with floating point variables:
imshow(diffImage, []);
By the way, DON'T USE diff as a variable name since it's a built in function.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by