Monday, March 13, 2006

Correlate two images

When we correlate two images (same size), the peak position tells the shift distance between these two images.
Two images with the same size (Nx, My) and the peak is at (nx, my)

if (nx Nx/2) t_x = nx - 1;
else t_x = nx - Nx;

if (my My/2) t_y = my - 1;
else t_y = my - My;

g_new(x, y) = g_old(x-t_x, y-t_y);