Bizarre result in manual image filtering
이전 댓글 표시
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
Adam
2016년 11월 4일
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.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!