Removing periodic noise from an image using the Fourier Transform
23 views (last 30 days)
Show older comments
So I have an image that has horizental lines (noise), in other to get ride of them I worked with the Fourier Transform, however this is the result I get.
Here is my code:
im3 = imread('louvreSin.png');
figure, imshow(im3);
frequencyImage = fftshift(fft2(im3));
% Take log magnitude so we can see it better in the display.
amplitudeImage = log(abs(frequencyImage));
minValue = min(min(amplitudeImage))
maxValue = max(max(amplitudeImage))
imshow(amplitudeImage, []);
amplitudeThreshold = 10.9;
brightSpikes = amplitudeImage > amplitudeThreshold; % Binary image.
imshow(brightSpikes);
% Filter/mask the spectrum.
frequencyImage(brightSpikes) = 0;
% Take log magnitude so we can see it better in the display.
amplitudeImage2 = log(abs(frequencyImage));
minValue = min(min(amplitudeImage2))
maxValue = max(max(amplitudeImage2))
imshow(amplitudeImage2, [minValue maxValue]);
filteredImage = ifft2(fftshift(frequencyImage));
amplitudeImage3 = abs(filteredImage);
minValue = min(min(amplitudeImage3))
maxValue = max(max(amplitudeImage3))
imshow(amplitudeImage3, [minValue maxValue]);
0 Comments
Answers (2)
Image Analyst
on 7 Mar 2023
An image is generally composed of a lot of energy in the low spatial frequencies and less in the higher frequencies. In the high frequencies you may see spikes that stick up but it's likely your spikes were not higher than the low frequencies. You can't just threshold the image or else you will take out the main part of the signal, like you did, which is why the image is mostly black. You essentially did a low pass filter in addition to any removal of periodic noise spikes. See my attached demo.
Also, attach 'louvreSin.png'.
If you have any more questions, then attach your image and code with the paperclip icon after you read this:
0 Comments
See Also
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!