Imsubtract Returns Black Image
Afficher commentaires plus anciens
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.
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 7 Mar 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.
Catégories
En savoir plus sur Image Arithmetic dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!