필터 지우기
필터 지우기

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

조회 수: 5 (최근 30일)
Ruhul Amin
Ruhul Amin 2015년 12월 13일
답변: Horus Hormaeus 2022년 8월 23일
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.

채택된 답변

Image Analyst
Image Analyst 2015년 12월 13일
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
Ruhul Amin
Ruhul Amin 2015년 12월 13일
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 2015년 12월 13일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Horus Hormaeus
Horus Hormaeus 2022년 8월 23일
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".

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by