Removing Periodic Noise from an Image Using the Fourier Transform

I perform 2D FFT on a particular image and I get its spectral components. Now this image is superimposed with another image to create periodic noise.

The original image as well as the periodic noise version are shown below:

Source image

enter image description here

Periodic noise image

enter image description here

To filter this out, I used manual boxes that masked the components in the amplitude spectrum, which are quite large compared to other components, as shown below.

enter image description here

After that, I perform the inverse FFT, but I do not get the original image back.

enter image description here

Does anyone know what I'm doing wrong?

Here is the code that masks the values ​​and then performs the inverse 2D FFT on the masked spectral image:

pat1 = imread('Pattern1.png'); spec_orig = fft2(double(pat1)); spec_orig2 = abs(spec_orig); spec_img = fftshift(spec_orig2); for j = 115:125 for n = 96:106 spec_img(n,j) = 0; end for n = 216:226 spec_img(n,j) = 0; end for n = 274:284 spec_img(n,j) = 0; end for n = 298:308 spec_img(n,j) = 0; end for n = 12:22 spec_img(n,j) = 0; end for n = 37:47 spec_img(n,j) = 0; end end %Getting Back the Image for Pattern1 figure;subplot(2,1,1); spec_img = log(1 + spec_img); imshow(spec_img,[]); subplot(2,1,2); ptnfx = ifft2(spec_img); imshow(ptnfx); 
+6
source share
2 answers

Filtering in the frequency domain is a complex business to get eligible. There are several errors in your code that prevent you from restoring the original image:

  • You apply filtering only to the component value . You must do this on the original spectrum of the images , and not just on the magnitude component. This phase is necessary for proper reconstruction. BTW, to use the term signal processing, what you implement is a notch filter or a bandpass filter that removes certain selection frequencies.

  • You centered the spectrum through fftshift , but after you filtered, you forgot to cancel the shift . You must call ifftshift on the resulting filtered image to cancel centering.

  • You find the inverse FFT of the image converted to a log . Remember that performing a logarithmic spectrum conversion is for display purposes only. You do not use this when filtering or looking for the opposite. This will lead to unintended consequences, since most of the spectrum has been changed due to non-linear operation. You have to do this on the most original spectrum of the image.

  • A quick note, but make sure you call real after filtering the result after you take the inverse FFT. Most likely, some residual imaginary components are related to floating point computational errors, and therefore the call to real will only extract the real components of the signal.

With these fixes, this is the code I have. I read your image directly from StackOverflow to be reproducible:

 pat1 = imread('http://i.stack.imgur.com/oIumJ.png'); %// Change spec_orig = fft2(double(pat1)); spec_img = fftshift(spec_orig); for j = 115:125 for n = 96:106 spec_img(n,j) = 0; end for n = 216:226 spec_img(n,j) = 0; end for n = 274:284 spec_img(n,j) = 0; end for n = 298:308 spec_img(n,j) = 0; end for n = 12:22 spec_img(n,j) = 0; end for n = 37:47 spec_img(n,j) = 0; end end %// Change ptnfx = real(ifft2(ifftshift(spec_img))); imshow(ptnfx,[]); 

I get this image:

enter image description here

A pretty good reconstruction of the original image, which I will add. You will still see a few stripes, and this greatly depends on the shape and size of the notch filter. Perhaps make the size larger and moreover, make the shape of a circular filter instead of a square. This tends to retain more of the original image, since the hard edges introduced by the corners of the squares have unintentional sound effects.

+13
source

When converting the inverse image to a spatial domain, you should use "ifftshift".

-1
source

All Articles