This Matlab code will denoise the periodic noise present in a given image file.
Here I have used the fast Fourier transformation method to convert the image to the Fourier domain. now the noise can be detected in the Fourier plot by finding bright spots.
A fast Fourier transform (FFT) is an algorithm that computes the discrete Fourier transform (DFT) of a sequence, or its inverse (IDFT). Fourier analysis converts a signal from its original domain (often time or space) to a representation in the frequency domain and vice versa. (Wikipedia)
Note that: This program can be used for removing/denoising a periodic noise from a given image file.
![]() |
![]() |
Cameraman.tif | FFT plot of Cameraman.tif |
img_test = 35*ones(256,256);
for i = 1:16:size(img_test,2)
img_test(:,i:i+7) = -35;
end
figure, imshow(img_test);
test_ft = fft2(img_test);
figure, imshow(log(1+fftshift(test_ft)));
![]() |
![]() |
periodic noise | FFT of periodic noise |
img_n = double(img1) + img_test;
figure, imshow(img_n,[]);
![]() |
![]() |
Adding noise to Cameraman.tif | FFT of new Image |
Note: here if you can notice, the bright spots in FFT of the new image (same in the FFT of periodic noise), now if somehow we can remove those spots, we can denoise the image.
From this point, we only work with the newly generated image (noisy one)
Let’s write a function to calculate the intensities greater than a particular threshold in the FFT of the new image. We set
Threshold = Max( Magnitude ( FFT_New_Image ) ) / 30
![]() |
![]() |
Applying the threshold function, and generating a binary matrix (Image) | skipping the centre part, we almost get the FFT of noise. |
![]() |
![]() |
Replacing the Bright spots by an average value in its neighbourhood. | Take inverse FFT and generate the image back! |