# find the rotation of one image with respect to other in MATLAB

I have two images. One is the reference image and the other is the rotated version of the reference image. I would like to find what is the angle by which the second image is rotated with respect to the first one. i want this to work automatic.

-

Enumerate over all possible angles (under some reasonable discretization), rotate one of the images, and calculate the $L_2$ distance (sum of squared differences); the angle at which the distance is minimal is the one you seek.

An even better idea is to calculate the two-dimensional Fourier transform, and now do the same with shifts instead of rotations (rotation in the time domain corresponds to shift in the frequency domain). Maybe you can reduce the amount of shifts tested by looking at some prominent peeks of the spectrum and trying to match them.

I have no idea how to implement these suggestions in Matlab, but I'm sure you can find out.

Both solutions assume that the image is "continuous" with reasonable "modulus of continuity". If the image is random that the methods wouldn't work.

-
can you please explain what do you mean by enumerate all possible angles? –  chee Dec 22 '10 at 18:02
go over all possible angles, up to some discretization, i.e. $2\pi n/N$ for $n=0,\ldots,N-1$ and $N$ is "big enough". –  Yuval Filmus Dec 22 '10 at 20:42