[Insight-developers] Bug in CenteredRigid2DTransform

Miller, James V (Research) millerjv@crd.ge.com
Fri, 24 Jan 2003 11:05:25 -0500


Luis,

I understand how the transform is intended to work (though the 
documentation still has some cut and past errors from some other 
transform class).  I don't want to specify the translation as the 
null vector since I need this image to be placed back in the original
coordinates after rotation.  Which is after all what this particular 
transformation is for, right?


I still question whether the math is correct. I haven't looked at
the Jacobian math yet.


For the bigger picture:
I am trying to gain some insight into the various image to image
metrics.  So I have a program where I take an image and compute
a specified metric between the image and a transformed version of
the image.  In one case, I just translate the image around and 
measure the metric.  In another case, I pin the centers and spin
the image around its center and compute the metric to the unspun
image.

It is this latter case, where I am using the CenteredRigid2DTransform.
I want the image centers to stay aligned, with one image just rotating
about the center.  So I set the center and translation to be same
value, naming the middle of the image (in mm).

Basically, I want to see what the expected area of convergence would
be for a particular metric under the best possible circumstances.





> -----Original Message-----
> From: Luis Ibanez [mailto:luis.ibanez@kitware.com]
> Sent: Friday, January 24, 2003 10:46 AM
> To: Miller, James V (Research)
> Cc: Insight-developers (E-mail)
> Subject: Re: [Insight-developers] Bug in CenteredRigid2DTransform
> 
> 
> 
> 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/
> > 
> >  
> > 
> >  
> > 
> 
> 
>