Re: rotation matching of 2D images [message #49511] |
Mon, 31 July 2006 08:47 |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
"phil" <philippe_kobel@yahoo.es> writes:
> Hello!
>
> I have 2 images of same sizes, but different orientations.
> One of these images is my 'reference' image, and the other one is the
> 'target' image, that I would like to rotate, so that the orientation of
> its features match the orientation of the reference image.
>
> I would then need an algorithm performing some kind of
> cross-correlation and returning the adequate rotation angle( I could
> then use the idl function ROT afterwards).
>
> Does somebody have a clue of such a procedure ?
Wayne has some good suggestions. I was also impressed by this paper:
http://www.nmt.edu/~hjxie/Auto.pdf
which has sample IDL code to do image reconstruction by FFT, including
rotation, scale and shift.
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
Re: rotation matching of 2D images [message #49514 is a reply to message #49511] |
Mon, 31 July 2006 05:09  |
Wayne Landsman
Messages: 117 Registered: January 1997
|
Senior Member |
|
|
"phil" <philippe_kobel@yahoo.es> wrote in message
news:1154160396.159851.81990@i42g2000cwa.googlegroups.com...
> Hello!
>
> I have 2 images of same sizes, but different orientations.
> One of these images is my 'reference' image, and the other one is the
> 'target' image, that I would like to rotate, so that the orientation of
> its features match the orientation of the reference image.
>
> I would then need an algorithm performing some kind of
> cross-correlation and returning the adequate rotation angle( I could
> then use the idl function ROT afterwards).
>
If you can locate matched features on each image, so that the (X1i, Y1i)
points on one image are matched with (X2i, Y2i) on the rotated image, then I
would use POLYWARP to determine the coefficients to pass to POLY_2D to
perform the rotation. See the example in the POLYWARP documentation, and
note that the IDL ROT() function also calls POLY_2d.
This is fine for aligning images, though it applies a general linear
transformation rather than just a rotation. If you are certain that you
just want to apply a rotation, then I would define a function of one
variable ( say, theta) that computes the summed distances between the
(X2i,Y2i) and the rotated input features (X1i*cos(theta) - Y1i*sin(theta),
X1i*sin(theta) + Y1i*cos(theta) ). (Be sure all X,Y are measured from the
center of rotation.) Then minimize this function -- I like to use Craig
Marwardt's tnmin.pro for this (
http://astrog.physics.wisc.edu/~craigm/idl/down/tnmin.pro ) -- to find the
best angle.
Finally, if you don't have the matched features, then in principle one can
do more of a "blind" determination of the rotation, by finding the rotation
that maximizes the correlation coefficient between the two images. I have
a program that does this to determine shifts
( http://idlastro.gsfc.nasa.gov/ftp/pro/image/correl_optimize. pro ) but it
would be
considerably more CPU-intensive, and somewhat more complicated to do this
for rotations. --Wayne
|
|
|