Imsubtract Returns Black Image
8 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
More Answers (1)
Image Analyst
on 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.
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!