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

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

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터 및 File Exchange에서 Installing Products에 대해 자세히 알아보기

질문:

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