FFT not working on periodic data!?!?!?

Hello,
I have data which, when visualized,, displays some very periodic behavior (picture a 2D sine wave). However, when I call the fft2() function on my matrix I only get the zero-frequency bin to be non-zero. I would have expected the very clear periodicity in my data to become clear in the FFT, but it seems that somewhere something's going wrong!
Any ideas, including common mistakes or misunderstandings with fft2 or FFTs in general?
Actually, it's quite weird that, regardless of my data, I only get the zero-frequency bin lighting up in the fft!!
code: (msum2 is my real data)
zMapT2=fftshift(fft2(msum2));
zMapAbs=abs(zMapT2);
imagesc(zMapAbs);
so I'd expect to see some bins lighting up away from the origin, but everything's blue except for the red at the center.

3 件のコメント

Rick Rosson
Rick Rosson 2014 年 9 月 13 日
Please post your code.
Rick Rosson
Rick Rosson 2014 年 9 月 13 日
編集済み: Rick Rosson 2014 年 9 月 13 日
Please type the following at the command prompt:
mean(msum2(:))
min(msum2(:))
max(msum2(:))
size(msum2)
class(msum2)
What is the value of each of these expressions?
Bruce
Bruce 2014 年 9 月 13 日
mean:23.4562
min:21.5823
max:27.5662
size:256 256
class:double

サインインしてコメントする。

回答 (2 件)

Image Analyst
Image Analyst 2014 年 9 月 13 日

0 投票

See my attached demo.
Can't really say much about your code since you didn't post it all. It might be that you have the signal on a big offset, like the signal is all positive, so that there is a huge DC (zero frequency) term which is so much bigger than your spikes due to your periodic component that you can't see the spikes due to the periodic part. You might try taking the log of your data before you pass it to imshow() or imagesc().

3 件のコメント

Image Analyst
Image Analyst 2014 年 9 月 13 日
It could also be that your colormap is such that it hides your spikes. Try using
colormap(gray(256));
instead of the weird colormap that imagesc() uses.
Bruce
Bruce 2014 年 9 月 13 日
Thanks for your ideas. I tried changing the figure colormap as instructed, but now I just get one white center dot in a sea of black. I also tried doing decibel scaling, to no avail!
msum3=10*log10(max(1,msum2));
proceeded as before, still one lone dot!
See my comment to Rick above - my data doesn't seem that wildly varied, and it doesn't have a huge spike somewhere (right?). So confused - seems so straightforward, can't think of why this particular data set is having issues.
Image Analyst
Image Analyst 2014 年 9 月 14 日
Unless you post your actual data I don't know how much more help we can give.

サインインしてコメントする。

Rick Rosson
Rick Rosson 2014 年 9 月 14 日

0 投票

Please try converting the source data to zero mean before taking the FFT:
mu = mean(msum2(:));
msum2 = msum2 - mu;
That will eliminate the DC component, and it should reveal the periodic components in the Fourier domain.

5 件のコメント

Bruce
Bruce 2014 年 9 月 16 日
This did it! Thank you Rick! I'll have to do more research to understand why this worked.
Bruce
Bruce 2014 年 9 月 16 日
Can't find a way to accept your answer though...
Image Analyst
Image Analyst 2014 年 9 月 16 日
It looks like you didn't take the log correctly when you tried to take my suggestion. You took the log of the time or spatial domain instead of the Fourier/spectral domain. Anyway, done correctly, taking the log before plotting/displaying will compress the DC spike and give the little spikes a chance to be seen. Of course if you don't want the complete spectrum and want only the little periodic spikes, then just get rid of the DC spike by subtracting the mean like Rick suggested.
Bruce
Bruce 2014 年 9 月 16 日
I see. I'll try what you said again, thank Analyst!
Bruce
Bruce 2014 年 9 月 16 日
編集済み: Bruce 2014 年 9 月 16 日
Yes, that worked too! They are different images, but the peaks I was after are present in both. I can see the difference between removing the DC spike and just compressing it - very interesting! Thank you both very much for your time. -Bruce

サインインしてコメントする。

カテゴリ

質問済み:

2014 年 9 月 12 日

編集済み:

2014 年 9 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by