filtering using FFT in images

58 views (last 30 days)
Jason
Jason on 26 Oct 2015
Commented: Jason on 29 Oct 2015
Hi, I am experimenting with masking out areas on a FFT of an image to see the effect on the processed image:
After reading, I have the following.
I=I-mean(I(:));
f = fftshift(fft2(I));
fabs=abs(f);
figure
subplot(1,3,1)
imshow(fabs,[])
After viewing the FFT, I notice there are some white spots, so to attempt to remove these, I have defined a threshold of 90% of the max. My aim is to remove these from the fabs image and then inverse fft and then view this processed image.
thresh=0.9*max(fabs(:))
Im not too sure how to apply the the threshold to the frequency domain image and then iFFT back.

Accepted Answer

Image Analyst
Image Analyst on 26 Oct 2015
Try this:
% Find pixels that are brighter than the threshold.
mask = fabs > thresh;
% Erase those from the image
fabs(mask) = 0;
% Shift back and inverse fft
filteredImage = ifft2(fftshift(fabs)) + mean2(I);
imshow(filteredImage, []);
  12 Comments
Image Analyst
Image Analyst on 29 Oct 2015
What do you want to do? The spikes and bars in the spectrum represent periodic structures in the spatial domain. If you get rid of those spikes, you should reduce the periodic patterns in the spatial domain.
They're inversely related. Fast changing spatial bars give rise to widely spaced spikes in the Fourier spectrum and vice versa. So the 4 big spikes you see are related to the sine wave pattern on the white rectangles. The other stuff is a 2D sinc due to there being a couple of bright squares in the image. The big spike at 0, the "DC spike" is due to the fact that the image has a non-zero mean gray level.
Jason
Jason on 29 Oct 2015
Thanks for your explanation. One thing why is there a dc offset as i subtracted off the mean originally. Are there any tricks to reject this?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!