Removing periodic noise from an image using the Fourier Transform
Date: 2023-01-02 11:25:07
I am performing the 2D FFT on a particular image and I get its spectral components. Now this image has been superimposed with another image to create periodic noise.
The original image as well as the periodic noise version is shown below:
Original Image
Periodic Noise Image
To filter this out, I used manual boxes that masked the components in the magnitude spectrum that are quite large relative to the other components as shown below.
After this is done, I perform an inverse FFT, but I do not get the original image back.
Does anyone know what I'm doing wrong?
Here is the code that masks the values and then proceeds to do an 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);