How to remove objects from a gray scale image in frequency domain?
조회 수: 5 (최근 30일)
이전 댓글 표시
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/152600/image.jpeg)
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.
댓글 수: 0
채택된 답변
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
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/180760/image.jpeg)
추가 답변 (1개)
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 :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1105350/image.png)
and the reconstructed image (from the filtered spectrum) will look like this :
unfortunately the knives are too vertically blurred, but the chopsticks are "gone".
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1105355/image.png)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!