Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to estimate rotation angle between two images

451 views
Skip to first unread message

vijay srini

unread,
May 6, 2007, 9:13:22 AM5/6/07
to
Hi
I want to know if there is any simple method to find out the
rotation angle between two images when one is rotated with respect to
another.. Thank You
Regards Vijay

ImageAnalyst

unread,
May 6, 2007, 11:09:04 AM5/6/07
to
Well one really simple way is to have the user click on a pair of
landmark points in each image. Then you simply calculate the angle
between them with basic trigonometry. There are other more
complicated, more rubust, and more automated ways.
Regards,
ImageAnalyst

vijay srini

unread,
May 6, 2007, 11:19:22 PM5/6/07
to
Hi,
Thankyou for the reply . But I cannot use the landmark detecting
method since I am using it for the superesolution purpose and I can't
keep on clicking landmark points. Can you please suggest some other
ideas??
Regards Vijay

vijay srini

unread,
May 6, 2007, 11:19:37 PM5/6/07
to
Hi,
Thankyou for the reply . But I cannot use the landmark detecting
method since I am using it for the superesolution purpose and I can't
keep on clicking landmark points. Can you please suggest some other
ideas??
Regards Vijay

ImageAnalyst wrote:
>
>
> Well one really simple way is to have the user click on a pair of
> landmark points in each image. Then you simply calculate the angle
> between them with basic trigonometry. There are other more
> complicated, more rubust, and more automated ways.
> Regards,
> ImageAnalyst
>
>
> On May 6, 9:13 am, "vijay srini" <vijvalsriniva...@gmail.com>
> wrote:

Laszlo Baranyai

unread,
May 7, 2007, 6:06:15 AM5/7/07
to
> keep on clicking landmark points. Can you please suggest
> some other ideas??

There might be 3 parameters: coordinates of the rotation
center and the angle. Optimization can help you. I
recommend the correlation to be the object (or cost)
function.

Btw. Some years ago I saw a patent for this (it was
developed for image databases):

<http://www.patentstorm.us/>

e.g.:
<http://www.patentstorm.us/patents/6553136-description.html>

Regards,
Laszlo

Dave Robinson

unread,
May 8, 2007, 5:05:26 AM5/8/07
to
If you compute two images representing the horizontal and vertical
gradients of the edges of the two images, from this (with a little
use of the atan2 function) you can compute an angle image of the two
scenes. Now histogram these two angle images, and run a circular
correlation between the histograms (not the images). The correlation
will peak at the angle of rotation between the two pictures (but be
careful of spikes at 90 degrees that can be caused by aliasing
artefacts).

This technique works very well

Dave Robinson

vijay srini

unread,
May 8, 2007, 8:27:38 AM5/8/07
to
Hi Dave,
Thak you so much for the reply. But It would be much more helpful
to me in case you could give some more detailsas an algorithm or
psudocode for the method or else I will get many doubts popped up.
Hope you will come back with a reply..
Thank you
Vijay

Peter Bone

unread,
May 8, 2007, 8:55:54 AM5/8/07
to
Here's a thread containing code to create a logarithmic polar map.

http://mathforum.org/kb/thread.jspa?forumID=80&threadID=1535493&messageID=5522026#5522026

This can be used to do what you want. Convert both images to a log polar mapping and correlate them use corr2. A rotation in Cartesian space produces a horizontal shift in the log polar mapping. The correlation peak will therefore be horizontally shifted from the center after correlating the log polar maps. You should be able to work out the angle from the shift of the correlation peak from the center of the correlation plane. The rotation point needs to be at the center of the image for this method to work.

Dave Robinson

unread,
May 8, 2007, 11:58:24 AM5/8/07
to
vijay srini wrote:
>
>
> Hi Dave,
> Thak you so much for the reply. But It would be much more helpful
> to me in case you could give some more detailsas an algorithm or
> psudocode for the method or else I will get many doubts popped up.
> Hope you will come back with a reply..
> Thank you
> Vijay
> Dave Robinson wrote:

Do you have access to MathCad? if so I can send you an active
document which explains the process in detail. However it is in the
form of a MathCad 2000 file. It will take too long to convert it into
another readable format.

Unfortunately I don't have access to the Matlab image processing
toolbox on this installation, so I can't generate any matlab oriented
code.

Does your EMAIL address above actually work? so I can forward it.

Regards

Dave Robinson

Peter Bone

unread,
May 8, 2007, 12:26:19 PM5/8/07
to
Posting my response again for the benefit of MATLAB Central readers.

Here's a thread containing code to create a logarithmic polar map.

<http://mathforum.org/kb/thread.jspa?forumID=80&threadID=1535493&messageID=5522026#5522026>

This can be used to do what you want. Convert both images to a log

polar mapping and correlate them using corr2 (or preferably Fourier
transforms so that it's circular). A rotation in Cartesian space


produces a horizontal shift in the log polar mapping. The correlation
peak will therefore be horizontally shifted from the center after
correlating the log polar maps. You should be able to work out the
angle from the shift of the correlation peak from the center of the
correlation plane. The rotation point needs to be at the center of
the image for this method to work.

Using this method also allows you to find the scaling factor between
2 images since this produces a vertical shift of the correlation
peak. If all you want to do is find the angle then you actually only
need a polar map (not logarithmic polar) but I don't know of any code
to do that.

Peter Bone

Dave Robinson

unread,
May 8, 2007, 12:55:05 PM5/8/07
to
Peter Bone wrote:
> Posting my response again for the benefit of MATLAB Central
> readers.
>
> Here's a thread containing code to create a logarithmic polar map.
>
> <http://mathforum.org/kb/thread.jspa?forumID=80&threadID=1535493&messageID=5522026#5522026>
>
> This can be used to do what you want. Convert both images to a log
> polar mapping and correlate them using corr2 (or preferably Fourier
> transforms so that it's circular). A rotation in Cartesian space
> produces a horizontal shift in the log polar mapping. The
> correlation
> peak will therefore be horizontally shifted from the center after
> correlating the log polar maps. You should be able to work out the
> angle from the shift of the correlation peak from the center of the
> correlation plane. The rotation point needs to be at the center of
> the image for this method to work.
>
> Using this method also allows you to find the scaling factor
> between
> 2 images since this produces a vertical shift of the correlation
> peak. If all you want to do is find the angle then you actually
> only
> need a polar map (not logarithmic polar) but I don't know of any
> code
> to do that.
>
> Peter Bone

A very nice solution Peter, probably better than my algorithm; I like
the way that scaling can also be measured - my technique demanded
that the images were exactly the same size, else by converting the
angle histograms to probability functions, one could work in a scale
invariant mode, but the scale cannot actually be measured.

Regards

Dave Robinson

vijay srini

unread,
May 8, 2007, 1:35:12 PM5/8/07
to
Hi Peter,

You helped me in such a situation of crisis Thank you so much and
I have to try coding the rest. I will come upto you in case I find
any difficulty. Hope you don't mind
Thank you once again.. Vijay

vijay srini

unread,
May 8, 2007, 1:39:50 PM5/8/07
to
Hi Dave
Thank you so much for the effort. Speaking frankly I don't have
any idea about the Mathcad . But if you could find any algorithm
please send me at vijvalsr...@gmail.com
Thank you.. Vijay

vijay_srini

unread,
May 8, 2007, 2:39:14 PM5/8/07
to
Hi Peter,
My set of pictures ie the ref image and the rotated version differs
between them with respect to a shift also. ie the images are first
rotated and shifted. SO i have to find out the rotation angle so
that I can nullify the rotation and then use those rotation orrected
images for finding the shioft. I have an algorithm for that
purpose(shift).
I sthere any means that I can align the images so that they seem tio
be rotatted wit respect to the centre. Unfortunately I cannot do the
shifting and then the rotation..
Pls help me on this.. Thank You Vijay

Peter Bone

unread,
May 9, 2007, 5:16:15 AM5/9/07
to
vijay_srini wrote:
>
> Hi Peter,
> My set of pictures ie the ref image and the rotated version
> differs
> between them with respect to a shift also. ie the images are first
> rotated and shifted. SO i have to find out the rotation angle so
> that I can nullify the rotation and then use those rotation
> orrected
> images for finding the shioft. I have an algorithm for that
> purpose(shift).
> I sthere any means that I can align the images so that they seem
> tio
> be rotatted wit respect to the centre. Unfortunately I cannot do
> the
> shifting and then the rotation..
> Pls help me on this.. Thank You Vijay

Hi Vijay,

This is a problem because using the log polar map gives you rotation
and scale invariance but loses x and y shift invariance. So this
method won't work if there's also a shift since you need to make sure
the log polar maps are created from the images where the rotation
point is at the center. The only way you can include shift detection
with this method is by performing a raster search on one of the
images. This will involve creating a new image centered at the
current xy position in the search. You will then need to create a log
polar map for each iteration. This will unfortunately slow down the
algorithm a lot. One way to speed it up a bit is to raster scan in
steps of 3 pixels. Also, you only need to search over one image. You
can pre-calculate the log polar map for the other image before hand.

Peter Bone

Peter Bone

unread,
May 9, 2007, 5:35:25 AM5/9/07
to
I should add that since you have to do a search there's not much
point in using the log polar map any more. You might as well search
over angles and rotate one of the images using imrotate and then
correlate them. The rotation search will then give you rotation
invariance and the correlation will give you shift invariance. You're
then searching over one variable instead of two.

Peter Bone

Gösta Huldt

unread,
May 15, 2007, 5:59:39 PM5/15/07
to

The translation problem could perhaps be solved by Fourier
transforming first and applying the log-polar transform to the
Fourier amplitudes. There is an implemention of this technique
(Fourier-Mellin transform) in the file exchange, /http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=3000&objectType=file).
I haven't tried that code though.

0 new messages