4

I'm currently trying to understand the 2d fourier shift theorem.

According to what I've learnd so far a translation in the image space leads to differences in phase but not the magnitude in frequency space.

I tried to demonstrate this with a little example but it only worked for shifts in rows but not in columns. Here's the little demo (I'm only showing the magnitude plots here)

clear all
close all
Iin = zeros(128);
Iin(10:20,10:20)=1;
figure,imagesc(Iin)
Y = fft(Iin);
figure, imagesc(fftshift(log10(abs(Y))));

Iin = zeros(128);
Iin(10:20,20:30)=1;
figure,imagesc(Iin)
Y = fft(Iin);
figure, imagesc(fftshift(log10(abs(Y))));

Iin = zeros(128);
Iin(20:30,10:20)=1;
figure,imagesc(Iin)
Y = fft(Iin);
figure, imagesc(fftshift(log10(abs(Y))));

In my opinion all 3 magnitude plots should yield the same result. Can anyone explain me what I'm doing wrong here?

Thank you very much for your help,

best regards,

Mini

Mini
  • 63
  • 1
  • 5

1 Answers1

3

I think you want to use fft2, not fft for this.

fft2 calculates the 2d fourier transform, which is what you stated you are studing. fft only calculates the fourier transform of each row.

Everything should work if you just substitute fft2 for fft in your code.

dustincarr
  • 1,365
  • 1
  • 9
  • 14
  • thank you very much, I was looking at the code for over an hour but I wasn't able to find the missing 2 in fft2 ;-) – Mini Dec 10 '12 at 23:57
  • No problem :). It didn't jump right out at me until I looked at the plots from your code and I knew something was wrong. – dustincarr Dec 11 '12 at 00:04
  • +1: this is a very easy mistake to make - I've wasted a lot of time in the past when using Octave (MATLAB clone) and typing `fft` instead of `fft2`. The results even look plausible a lot of the time, which can make the mistake hard to spot. – Paul R Dec 11 '12 at 06:32