You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How to remove frequency components in an image
16 views (last 30 days)
Show older comments
How can I use the fourier transform to find out the frequency components which are responsible for the texture on the surface?
Then I have to remove them to have a smooth surface without texture.
Thanks in advance
1 Comment
Walter Roberson
on 10 May 2012
In one of your duplicate posts, which I have now deleted, Image Analyst commented,
'Like I said in a comment on one of your other numerous posts on this subject: "Jim, you've got to stop the duplicate posts. You do this frequently, and then people like Wayne waste their time telling you how to do a high pass filter when I've already told you that a high pass filter is not the way to go."'
Answers (1)
Image Analyst
on 9 May 2012
Take the 2D FFT. Look for spikes in the 2D FFT and zero them out. Inverse transform and display.
31 Comments
Walter Roberson
on 9 May 2012
fft2() is an implementation of the concept of 2D FFT.
A spike in the frequency domain is a frequency that has a large amplitude relative to the surrounding frequencies.
fft() and fft2() will almost always produce complex values. The complex component encodes phase of the frequency.
Are you using the [] option to imshow() so that the range of values is automatically scaled to use the full color map?
Image Analyst
on 10 May 2012
No you cannot. You must remove the isolated spikes and only the isolated spikes from the spectrum. That is not what a high pass filter does.
Wayne King
on 10 May 2012
Why the duplicate posts?
http://www.mathworks.com/matlabcentral/answers/37965-how-to-remove-high-frequency-components-in-an-image
Image Analyst
on 10 May 2012
I think you mean frequency components with high power rather than high frequency components. I hope you realize that those are two different concepts. But your threshold would have to be locally adaptive because often with these kinds of textures, the spikes are on a downward sloping surface so you can't apply a global threshold. Imagine you stuck pencils in a volcano-shaped hill of dirt. A global threshold would get the whole top of the volcano and miss the pencils lower down on the slopes.
Walter Roberson
on 10 May 2012
Jim, I get the impression that you still do not understand what a Fourier transform does. A Fourier transform analyzes a vector in terms of sine and cosine frequency components. By definition, sine and cosine frequency frequency components repeat at precise intervals. Your texture does not repeat at precise intervals: there are a lot of places in that image where the texture is locally absent. Simply removing (zeroing) some frequency components *might* remove the texture where it _is_, but that will damage the image in the places where the texture is absent.
Jim
on 10 May 2012
--If I apply fft2 to the image, I will get complex values which will encodes the phase of the frequency
--But I need frequencies that has a large amplitude relative to the surrounding frequencies.
--first I used
abs(fft2(image)) to find magnitude of frequency components of image
--Now how to identify the frequencies with larger amplitude in the surrounding frequencies
Dr. Seis
on 10 May 2012
You could run the values from "abs(fft2(image))" through a histogram. That way you can get an idea of how the majority of the amplitudes are behaving and an idea of what amplitudes are way outside the distribution. Once you identify an amplitude to set as a threshold (say "max_threshold") then it is just a matter of setting those amplitudes to zero [i.e., image_mag = abs(fft2(image)); image_mag(image_mag > max_threshold) = 0; new_image = ifft(image_mag.*exp(1i*angle(fft2(image)))); ].
Image Analyst
on 10 May 2012
In the spectra I've seen, they look like a volcano with a periodic array of sticks stuck in the slopes, so viewing a histogram of that kind of image won't let you know that there are spikes at all, let alone where they are. The best way is to visualize the image. You can take the log of it to make the spikes more visible since that will suppress the large central main peak. Then you need to zero out those spikes. If you're really lucky with a high contrast texture (like a screen or grid or honeycomb) then you'll see a nice array of spikes without many low frequencies. A histogram may clue you in to there being spikes, but not as well as simply viewing the FFT image, and the histogram still won't tell you *where* they are, which is what you need to know if you want to zero them out. Perhaps some day I might have time to make up a texture removal demo.
Jim
on 10 May 2012
Thank you for your reply
--I applied log(abs(fft2_image)) and used fftshift to move zero frequency components to the center
--Now I need to define low pass filter and move it to the center of the image
--Can you suggest me, which type of low pass filter,can I use here
--how to define it and move it to the center of the image
Image Analyst
on 10 May 2012
I don't know what to say. I agree with Walter that you seem to need a lot more background in linear filtering because you don't seem to understand the situation. Let me try to make it more clear. You DO NOT need a low pass filter. You DO NOT need a high pass filter. What you need is a filter that zeros out small isolated areas at the location of each spike. That's not even a band pass filter - it's a special Fourier domain filter that is specially designed to remove a periodic signal. You need to find the spikes yourself and zero them out. There is no single MATLAB function to do that for you. You will have to string together a bunch of MATLAB code to accomplish that.
Walter Roberson
on 10 May 2012
Jim, look at Wayne King's postings, as he often shows how to create low-pass and high-pass filters using the signal processing toolbox. You need to decide matters such as whether you want a FIR or IIR filter, and how sharp of a roll-off you want. See for example http://www.mathworks.com/matlabcentral/answers/37975-how-to-design-an-iir-low-pass-filter-with-matlab
To move a low-pass or high-pass filter "to the center of the image", do nothing: low pass and high pass filters are position independent.
Image Analyst: I think that Jim needs to go ahead an experiment with low pass and high pass filters in order to establish for himself the extent to which they are useful in this project.
Image Analyst
on 11 May 2012
Although high pass and/or low pass filters won't remove the texture, experimenting with various filters is an excellent way to learn and get a good intuitive feel for how different operations affect the image.
Walter Roberson
on 18 May 2012
Image Analyst has told you several times how to remove texture from the image.
Changing the DC offset (i.e. the mean) is something you've been shown more than once.
Walter Roberson
on 18 May 2012
Yes, and be sure to do that before you do the fftshift()
How can I say the spike is from the DC offset? Experience. The DC is most often the largest absolute value in an fft (for mathematical reasons). The spike occurs half way along one side in the plot, which is exactly what one would expect if the spike was originally at (1,1) and had been fftshift()'d _once_. You would need to fftshift() along x and y separately to get your (1,1) to move to the center of the surf(), but only one fftshift() was done so it just moved to half-way along one edge.
Image Analyst
on 18 May 2012
Huh? There are no frequencies that will be less than zero once you take their absolute value. If you want to set negative values to zero, you do array(array==0) = 0, but I'm pretty sure you know that already, so please explain.
MUHAMMAD ADNAN
on 20 Nov 2017
hI @Image Analyst how can I set spikes to zero for certain repetitive structure like line or circle in image FFT domain ?Please can you give simple code for this process or guide me. Thanks
Image Analyst
on 20 Feb 2019
I tried experimenting around with some values and that's just what worked the best.
See Also
Categories
Find more on Get Started with Signal Processing Toolbox 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!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)