fft2 - how does it work

8 views (last 30 days)
moose
moose on 18 Aug 2015
Commented: moose on 25 Aug 2015
Hello, I am trying to understand how fft2 works and what it really means by simple example - my image is black&white stripes:
n = 256;
step = 4;
m_in = zeros(n,n);
for i = 1 : step : n
m_in(:,i) = 1;
end
I've noticed that if my step is power of 2 then
imshow(abs(fftshift(fft(m_in))))
will provide a black image with step number of white dots (4 in the above example).
Why is that?
Also, if my step in NOT power of 2 (for example step=7), then
imshow(abs(fftshift(fft(m_in))))
will result in simply a full white line accross the entire pic (like in the image below):
Why is that?

Answers (1)

Honglei Chen
Honglei Chen on 18 Aug 2015
I'm a bit confused by your question, there is no fft2 in your code. All you do is fft along columns. Also for your code, if I change step to 7, I also get a series white dots, which is expected. I don't get that white line.
  3 Comments
Honglei Chen
Honglei Chen on 24 Aug 2015
This time your code is using fft2 instead of fft. Before, you set every 7th column to all 1's, so the fft of that is an impulse. That's why you'll see white dots at every 7th column.
moose
moose on 25 Aug 2015
Thanks again Chen. But my question remains - why in the above code, when my step is a power of 2 (4,8,16, etc...), I receive a series of dots (4,8,16 dots, respectively)... while if my step is NOT a power of 2 (7,9, etc...), I get a straight line?

Sign in to comment.

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!