calvin tiger
calvin tiger

Reputation: 391

Order of frequency-shifting operations in 2D FFT for far-field diffraction simulations (with Matlab/Octave/Scipy)

In Matlab/Octave/Scipy, what is the correct way of shifting the frequency components after performing 2D Fourier transforms back and forth between two planes (with the output plane being the far-field diffraction plane of the input plane) ?

Let's say that I would like to run an iterative Fourier-transform algorithm between these two planes in order to compute a hologram (the phase-delay pattern to be applied to the input plane), in order to obtain a given intensity pattern in the output plane.

Let the field in the input plane be called A and the field in the output plane called B.

So B will be the Fourier transform of A, and A the inverse Fourier transform of B (this follows from the Franhauffer diffraction theory).

The question is: in what order shall I shift the frequency components with the command fftshift in between the Fourier transforms connecting the two planes ?

It seems that writing the following does not do the job: B=fftshift(fft2(A)); A2=fftshift(ifft2(B));

This is probably a common issue but I couldn't find the answer anywhere..

Upvotes: 1

Views: 1439

Answers (1)

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272517

I'm not sure I understand your use-case, but the general purpose for fftshift is to rotate the output of fft so that the DC (zero frequency) bin is centred. So the usual pattern is:

X       = fft2(x);         % DC at X(1,1)
X_shift = fftshift(X);     % DC at X_shift(M/2+1,N/2+1)

% ... processing occurs here (Y_shift = foo(X_shift)) ...

Y       = ifftshift(Y_shift);
y       = ifft2(Y);

Upvotes: 3

Related Questions