現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
How to remove frequency components in an image
38 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Walter Roberson
2012 年 5 月 10 日
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."'
回答 (1 件)
Image Analyst
2012 年 5 月 9 日
Take the 2D FFT. Look for spikes in the 2D FFT and zero them out. Inverse transform and display.
31 件のコメント
Jim
2012 年 5 月 9 日
--you mean fft2 of image
--what do you mean by spikes
--I used fft2 and got some complex values in work space
--when I used imshow to fft image,it is giving the black and white dots
can u please explain me in detail
Walter Roberson
2012 年 5 月 9 日
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
2012 年 5 月 10 日
--can I use high pass filter here to remove spikes in the frequency domain of the image
--if it is?
---how to write a code to apply high pass filter
Image Analyst
2012 年 5 月 10 日
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
2012 年 5 月 10 日
Why the duplicate posts?
http://www.mathworks.com/matlabcentral/answers/37965-how-to-remove-high-frequency-components-in-an-image
Jim
2012 年 5 月 10 日
So,
--Can I take the frequency components in an array
--And can I give some threshold to remove higher frequency components
from that array
Image Analyst
2012 年 5 月 10 日
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
2012 年 5 月 10 日
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
2012 年 5 月 10 日
--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
2012 年 5 月 10 日
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
2012 年 5 月 10 日
Thank you for ur reply
--how to take histogram of the values of abs(fft2(image))
imhist(abs(fft2(image)))
Dr. Seis
2012 年 5 月 10 日
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
2012 年 5 月 10 日
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
2012 年 5 月 10 日
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
2012 年 5 月 10 日
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
2012 年 5 月 10 日
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
2012 年 5 月 11 日
Jim: Can you post another figure displaying the image in the frequency domain? Something like:
surf(fftshift(abs(fft2(image))),'EdgeColor','none');
Image Analyst
2012 年 5 月 11 日
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
2012 年 5 月 18 日
Elige Grant :You can see the image of
surf(fftshift(abs(fft2(image))),'EdgeColor','none'); in the following link
http://magnitude2143.blogspot.se/
Jim
2012 年 5 月 18 日
can you give me the code to fix this?
How this texture can be removed from the image?
Walter Roberson
2012 年 5 月 18 日
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
2012 年 5 月 18 日
How can you say that the spike is from DC offset?
removing the mean is just like removing DC component from the fft image
making FFT(1,1)=0;
iS THIS CORRECT?
Walter Roberson
2012 年 5 月 18 日
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
2012 年 5 月 18 日
If I need to make abs(frequencies) which are having less magnitudee to zero
then what I need to do?
Image Analyst
2012 年 5 月 18 日
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
2017 年 11 月 20 日
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
Nbillah
2019 年 2 月 19 日
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
2019 年 2 月 20 日
I tried experimenting around with some values and that's just what worked the best.
参考
カテゴリ
Help Center および File Exchange で Fourier Analysis and Filtering についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- 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)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)