Azzera filtri
Azzera filtri

How to remove objects from a gray scale image in frequency domain?

5 visualizzazioni (ultimi 30 giorni)
I want to remove some objects of a gray scale image in frequency domain. I am transforming a gray scale image into frequency domain from spatial domain using fft2() and then i am doing fftshift() to shift zero frequency component to center of spectrum. I don't know i am going into right way or wrong? After doing fftshift() i am having a totally gray image with some unclear dotted center frequency component. I want to remove vertical line of that spectrum.
Sample image have some chop sticks and knives. I want to remove those chop sticks. I attached sample image and experimental image.
Here is my code:
if true
img = imread('sample.png');
figure,imshow(img,'InitialMagnification','fit');
imgB = im2bw(img,0.2);
figure,imshow(imgB,[],'InitialMagnification','fit');
imgF = fftshift(fft2(imgB));
figure, imshow(imgF,[],'InitialMagnification','fit');
end
I need some guideline to remove those chopsticks using frequency domain.

Risposta accettata

Image Analyst
Image Analyst il 13 Dic 2015
You did not attach the images. But anyway, you cannot remove chopsticks and knives by filtering in the Fourier domain. Not sure why you thought you could.
  2 Commenti
Ruhul Amin
Ruhul Amin il 13 Dic 2015
Sorry. Now you can check the image. As far as i know if i convert this image into frequency domain the horizontal chopsticks component would be shifted to vertical component.
Image Analyst
Image Analyst il 13 Dic 2015
You can look for spikes in the Fourier domain and zero those out, but with this image the spikes would be buried in the noise and be hardly visible. Actually instead of spikes they'd be sinc functions which would make them even harder to find. Even if you did find them, erasing them would very slightly reduce the contrast but definitely not remove them totally. See my attached demo where I tried to remove very periodic ripples in an image.

Accedi per commentare.

Più risposte (1)

Horus Hormaeus
Horus Hormaeus il 23 Ago 2022
like Image Analyst said, you can't remove a localized object in an image by just blocking some frequencies in its frequency spectrum. however, in this particular case, your chopsticks are horizontally positioned ,and other items are vertical, so if you really want to "remove" the chopsticks by cutting off some frequencies, you could achieve it by making the chopsticks so blurry that you basically can't see it, while the other items in the image are still resolved (but blurred too) -- it's kind of cheating.
so what you need to do is creating a very slim elliptical lowpass filter (or something equivalent), and filter the fourier spectrum of your image like this :
and the reconstructed image (from the filtered spectrum) will look like this :
unfortunately the knives are too vertically blurred, but the chopsticks are "gone".

Community Treasure Hunt

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

Start Hunting!

Translated by