[Insight-developers] Bug in CenteredRigid2DTransform

Luis Ibanez luis.ibanez@kitware.com
Fri, 24 Jan 2003 10:46:21 -0500


Hi Jim,

The CenteredRigid2DTransform do for you both
the back and forth translations to the center.

The explicit translation parameter is to be
applied after the image have been placed back
in the original frame.

So,
If you need just to rotate the image around
its center. Set the Translation to a NULL vector.
An only specify that the center of rotation is
point P and the angle is X

The transform in this case will do:

1) translate the image from point P to the axis origin
2) rotate by angle X
3) translate back from axis origin to point P.


The current setup of the transform is extremly
convenient for registration since it match the
way in which we could describe a miss registration
in terms of the image center.

E.g. if an image is missregistered only by a rotation
with respect to the center of the image. We will
say that there is a rotation by angle X and that
there is no translation at all.

I agree with you in that we could have absorbed the
second translation with the user-specified translation.
That's mathematically correct but probably less
intuitive for naive users.



    Luis



--------------------------------------------------

Miller, James V (Research) wrote:

> I am having trouble using the CenteredRigid2DTransform and I think there 
> is a bug in the ComputeMatrixAndOffset() method.  This transform allows 
> to specify a center of rotation and angle to rotate about and an amount 
> to translate after rotation.
> 
>  
> 
> For my task at hand, I just want to rotate an image about its center. So 
> I specify the center and translation as the same point.  This should 
> translate the center of the image to the origin, rotate by the specified 
> angle and translate the center back to the original position.
> 
>  
> 
> The code to compute the offset (final composed translation component of 
> the transform) is currently
> 
>   offset[0] = tx + sa * cy + ( 1.0 - ca ) * cx;
>   offset[1] = ty - sa * cx + ( 1.0 - ca ) * cy;
> 
> where ca, sa are the sine and cosine of the angle, cx and cy are the 
> center to rotate about, and tx and ty are the final translation.
> 
>  
> 
> I think this code should be
> 
>  
> 
>   offset[0] = tx - ca * cx + sa * cy;
>   offset[1] = ty - sa * cx - ca * cy;
> 
> note the signs are set such that we translate the origin to the center 
> (shift by negative center), rotate, then translate to the specified 
> position.
> 
>  
> 
> Does this make sense?
> 
> 
> *Jim Miller*
> */_____________________________________/*
> /Visualization & Computer Vision//
> /GE Research/
> /Bldg. KW, Room C218B/
> /P.O. Box 8, Schenectady NY 12301/
> 
> //_millerjv@research.ge.com <mailto:millerjv@research.ge.com>_/
> 
> /_james.miller@research.ge.com_/
> /(518) 387-4005, Dial Comm: 8*833-4005, /
> /Cell: (518) 505-7065, Fax: (518) 387-6981/
> 
>  
> 
>  
>