How to remove frequency components in an image
Afficher commentaires plus anciens
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 commentaire
Walter Roberson
le 10 Mai 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."'
Réponses (1)
Image Analyst
le 9 Mai 2012
0 votes
Take the 2D FFT. Look for spikes in the 2D FFT and zero them out. Inverse transform and display.
31 commentaires
Jim
le 9 Mai 2012
Walter Roberson
le 9 Mai 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?
Jim
le 10 Mai 2012
Image Analyst
le 10 Mai 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
le 10 Mai 2012
Why the duplicate posts?
http://www.mathworks.com/matlabcentral/answers/37965-how-to-remove-high-frequency-components-in-an-image
Jim
le 10 Mai 2012
Image Analyst
le 10 Mai 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
le 10 Mai 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
le 10 Mai 2012
Dr. Seis
le 10 Mai 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)))); ].
Jim
le 10 Mai 2012
Dr. Seis
le 10 Mai 2012
I was thinking something more simplified, along the lines of:
image_mag = abs(fft2(image));
hist(image_mag(:));
Someone else may have a better solution.
Image Analyst
le 10 Mai 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
le 10 Mai 2012
Image Analyst
le 10 Mai 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
le 10 Mai 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.
Dr. Seis
le 11 Mai 2012
Jim: Can you post another figure displaying the image in the frequency domain? Something like:
surf(fftshift(abs(fft2(image))),'EdgeColor','none');
Image Analyst
le 11 Mai 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.
Jim
le 18 Mai 2012
Walter Roberson
le 18 Mai 2012
Looks to me like you have a big DC offset.
Jim
le 18 Mai 2012
Walter Roberson
le 18 Mai 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.
Jim
le 18 Mai 2012
Walter Roberson
le 18 Mai 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.
Jim
le 18 Mai 2012
Jim
le 18 Mai 2012
Image Analyst
le 18 Mai 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
le 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
le 20 Nov 2017
See attached demo.
Nbillah
le 19 Fév 2019
Hi, @Image Analyst, thank you very much for the code, very helpful. I have one question for you i.e how did you decide the value for amplitudethreshold=10.9?
Image Analyst
le 20 Fév 2019
I tried experimenting around with some values and that's just what worked the best.
Catégories
En savoir plus sur Matched Filter and Ambiguity Function dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!