Bizarre result in manual image filtering
Afficher commentaires plus anciens
Hello,
I have a code for manual 2D image filter. You need a 512 by 512 image to execute the code.
xx=-255:256;
[X, Y]=(meshgrid(xx,xx));
psf=exp(-(X.^2/1+Y.^2/1).^0.5);
psf2=fft2(psf);
testimage2fft=ifft2(fft2(testimage2));%same with original.
testimage2psf=(ifft2(fft2(testimage2).*(psf2)));% complex valued, fftshifted, filtered image
testimage2psf2=(ifft2(fft2(testimage2).*abs(psf2)));% complex valued, original, filtered image
This code is meant to be a low pass filter.
As you expect,
testimage2fft=ifft2(fft2(testimage2));%same with original
is real value, and same with testimage2.
What about below?
testimage2psf=(ifft2(fft2(testimage2).*(psf2)));% complex valued, fftshifted, filtered image
figure;imagesc(abs(testimage2psf));
It is complex valued, that deserves. I expected to see the filtered image, but it is fftshifted.
The last one is as follow,
testimage2psf2=(ifft2(fft2(testimage2).*abs(psf2)));% complex valued, original, filtered image
figure;imagesc(abs(testimage2psf2));
Yes, it shows the filtered image, and not shifted, what I expected.
What am I missing here? How does the '.*psf2' give shifted result while '.*abs(psf2)' give correct result?
1 commentaire
Adam
le 4 Nov 2016
The second one is multiplying two complex-valued results together so the two imaginary terms will become real and the imaginary will be a combination of the real part of each with the imaginary part of the other. That will clearly give a different result than just multiplying by an absolute envelope result as you are in the last of your solutions.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Image Filtering dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!