If i have two images of the same scene, reference image and a shifted image, the shift can be in x or y directions, i want to estimate the shift using the shift property of the fourier transform.

S1 = fftshift(fft2(im1)); % Fourier transform of the reference image
S2 = fftshift(fft2(im2)); % Fourier transform of the image to be registered
Q = S1./S2;
A = angle(Q);

How can i use the phase shift Ato estimate the shift in both directions?

  • $\begingroup$ Is the reference image period along the $x$ and $y$ direction $\endgroup$ Nov 16 '13 at 4:15
  • $\begingroup$ assume the direction of increasing of columns indices is $x$, and the one in which the row indices increase is $y$. $\endgroup$
    – HforHesham
    Nov 16 '13 at 11:46
  • $\begingroup$ A different approach would be to take the product of S1 and S2 and then do the inverse fourier transform, since multiplication in the frequency domain is circular convolution in the space domain. This would be like doing a matched filter. $\endgroup$
    – Aaron
    Dec 18 '13 at 6:52

Assume the image is 256x256, The shift in spatial domain corresponds to a linear phase in the frequency domain.


linear_phase= exp(-2*pi*1i.*(((v).*dy)+((u).*dx)));

dx shift in $x$ and dy shift in $y$, and A equals linear_phaseso i can get a lot of equations to solve for dx and dy

If dx or dy is $0.5/128$ the shift is one pixel in $x$ or $y$


Phase correlation method can be used to estimate the shift.

Q = (S1.*conj(S2)) ./ abs(S1.*conj(S2));
Qi = ifft2(Q);

The position of the maximum entry of Qi will give you the shift amount.


This should answer your question (mainly your notation):

$Q = \frac{S_1}{|S_1|}\frac{S_2^*}{|S_2|} = e^{i(k_x\Delta x + k_y \Delta y)}$

This quantity is the phase in Fourier-space. Since a displacement in image space results in a linear phase in Fourier space, you end up with the phase factor here. Note that the magnitudes of $S_1$ and $S_2$ are identical - only the phase is different, if you have a translation in image space.

If you transform $Q$ back to image space by an inverse Fourier transformation, you end up with an image that is mainly zero everywhere and should have a strong peak at one position only. This peak, relative to the center pixel of your image, gives you the shifts $\Delta x$ and $\Delta y$, i. e. if your image center is at pixel (128, 128) and the peak you get is at (130, 124), then the image was shifted by $\Delta x = 2\,\textrm{px}$, and $\Delta y = -4\,\textrm{px}$.

Note that you have to transform Q back to image space. The phase distribution in Fourier space itself will be of less value to your application!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.