[Insight-users] Centered Affine Transform
Lucas Lorenzo
lucas at cvrti.utah.edu
Mon Jul 19 15:53:03 EDT 2004
Hi Luis,
>
> Hi Lucas,
>
> Please post numbers :-)
My original object is center is located at point (175 mm ; 168 mm). So
that's the center of rotation.
>
a) For translation I'm using (43.54 mm , -17.81 mm). If for rotation I
use a matrix [1 0 ; 0 1] then the result is as I expect: the object is
only translated and the new object center is now at (134.77 mm ; 188.20
mm). Please, take into account that my object has an irregular shape so
the coordinates aren't 100 % precise. But this results don't match the
equation you've posted bellow. Let's do it for the new x coordinate of
the center:
x' = 1 * (x - Cx) + (Tx + Cx) = 1 * (43.54 - 43.54) + (175 + 43.54) =
218.54 mm
where Cx is the original x coordinate for the center and Tx is the x
component of the translation vector.
b) If instead of using the translation vector specified before I use
its negative (- 43.54 mm , 17.81 mm) then the equation makes sense, but
now the results are not what I expect. Now the new center is 218.54 mm
instead of 131.46 mm.
c) if for rotation I use a matrix [0 -1 ; 1 0] (we are rotating the
image 90 degrees) around center (174.765 mm, 175.242 mm) and I use a
translation vector of (43.5537 mm, -17.8095 mm), then the object is
rotated according to what I expect but the new center is translated to
location (218.54 mm , 152 mm).
If I apply the equations then the new center will be at (218.3187 mm ,
157.4325 mm).
d) if for rotation I use a matrix [0 -1 ; 1 0] (we are rotating the
image 90 degrees) around center (183.42 mm, 176.236 mm) and I use a
translation vector of (-44.1889 mm, 17.5775 mm), then the object is
rotated according to what I expect but the new center is translated to
location (156.93 mm , 143.67 mm).
If I apply the equations then the new center will be at (139.24 mm ,
193.8 mm).
Again I have to be doing something wrong.
Thanks for your help,
Lucas
> What are the coordinates of the center of the object ?
> What is the translation that you are applyng ?
>
>
> TheCenteredAffineTransform transforms a point P into
> a point P' by using the following expression
>
>
> P' = R * ( P - C ) + ( T + C )
>
> In dimension N: C is a N dimensional point with
> the coordinates of the center of rotation, P is
> the N dimensional point to be transformed, P' is
> the resulting N dimensional point, T is the N
> dimensional translation Vector.
>
>
> Regards,
>
>
>
> Luis
>
>
>
> ----------------------
> Lucas Lorenzo wrote:
>> Hi Luis,
>> I'm selecting the spatial coordinates of the center of the object I'm
>> interested in.
>> Lucas
>> On Jul 16, 2004, at 5:06 PM, Luis Ibanez wrote:
>>> Hi Lucas,
>>>
>>>
>>> What center of rotation did you selected ?
>>>
>>> Luis
>>>
>>>
>>> ---------------------
>>> Lucas Lorenzo wrote:
>>>
>>>> Hi Luis,
>>>> I've been running some tests so as to understand a little bit
>>>> better what's this transform doing and it is clear to me now that
>>>> it is applying the translation first and then it is rotating the
>>>> translated image with respect to the specified center of rotation.
>>>> My understanding is that it should perform these operations but in
>>>> reverse order.
>>>> Please let me know if this is wrong.
>>>> Thanks,
>>>> Lucas
>>>> On Jul 16, 2004, at 2:14 PM, Lucas Lorenzo wrote:
>>>>
>>>>> Hi Luis,
>>>>>
>>>>> thanks for your feedback.
>>>>>
>>>>> 1) Till now the way I was setting the parameters was using the
>>>>> m_Transform->SetParameters(m_TransformParameters);
>>>>>
>>>>> 2) I have a 2D image so my understanding is that I'm going to have
>>>>> 8 parameters for this transformation where the first 4 parameters
>>>>> define the rotation, shear, and scaling; the next two define the
>>>>> center of rotation and the last two define the translation to be
>>>>> applied with respect to the center of rotation (after the image
>>>>> has been rotated).
>>>>>
>>>>> Please, let me know where am I making a mistake.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Lucas
>>>>>
>>>>>
>>>>> On Jul 16, 2004, at 1:17 PM, Luis Ibanez wrote:
>>>>>
>>>>>>
>>>>>> Hi Lucas,
>>>>>>
>>>>>> It is likely that you are misinterpreting
>>>>>> the encoding of the parameters in this
>>>>>> transform.
>>>>>>
>>>>>> Please post the values of the parameters
>>>>>> that you are providing, and post also
>>>>>> what you are expecting to be the effect.
>>>>>>
>>>>>> Note that you have:
>>>>>>
>>>>>> - Center of rotation
>>>>>> - Translation
>>>>>> - Offset
>>>>>> - Rotation matrix
>>>>>>
>>>>>>
>>>>>> When you use this transform you should only
>>>>>> care about SetCenter(), SetTranlation() and
>>>>>> Rotation. Never touch the Offset directly.
>>>>>>
>>>>>>
>>>>>> A code snippet illustrating the calls that
>>>>>> you are making on the transform will also
>>>>>> be very useful....
>>>>>>
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>>
>>>>>> Luis
>>>>>>
>>>>>>
>>>>>> ----------------------
>>>>>> Lucas Lorenzo wrote:
>>>>>>
>>>>>>> Hi Gavin,
>>>>>>> thanks a lot for your answer.
>>>>>>> I'm setting the parameters using
>>>>>>> m_Transform->SetParameters(m_TransformParameters);
>>>>>>> So, afterwards I'm adding
>>>>>>> m_Transform->ComputeOffset();
>>>>>>> But still the results are not as expected (after rotation the
>>>>>>> object is not been translated to the desired location). Is
>>>>>>> there anything wrong in what I'm doing ?
>>>>>>> Thanks,
>>>>>>> Lucas
>>>>>>> On Jul 15, 2004, at 10:07 PM, Gavin Baker wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> Hi Lucas,
>>>>>>>>
>>>>>>>> On Thu, Jul 15, 2004 at 06:01:26PM -0600, Lucas Lorenzo wrote:
>>>>>>>>
>>>>>>>>> I'm trying to use a Centered Affine Transform. So first I'm
>>>>>>>>> taking a
>>>>>>>>> look at the following example:
>>>>>>>>>
>>>>>>>>> Examples/Registration/ImageRegistration9.cxx.
>>>>>>>>>
>>>>>>>>> I'm a little bit confused on how to use the ComputeOffset()
>>>>>>>>> method
>>>>>>>>> because I don't see where it is been used in this example and
>>>>>>>>> when
>>>>>>>>> reading the online documentation my understanding is that it is
>>>>>>>>> mandatory to use this particular method.
>>>>>>>>>
>>>>>>>>> Could anyone please help me to get a better understanding on
>>>>>>>>> this issue
>>>>>>>>> ?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> When using the centered affine transform, there is an implicit
>>>>>>>> translation
>>>>>>>> due to the center. The offset takes into account the affect of
>>>>>>>> any
>>>>>>>> rotations you specify on this center, to give a new
>>>>>>>> translation. The
>>>>>>>> ComputeOffset() method recalcuates this offset (which need only
>>>>>>>> be done
>>>>>>>> once), and needs to be updated before applying the transform.
>>>>>>>>
>>>>>>>> This was discussed a while ago:
>>>>>>>>
>>>>>>>>
>>>>>>>> http://public.kitware.com/pipermail/insight-users/2003-October/
>>>>>>>> 005230.html
>>>>>>>>
>>>>>>>> http://public.kitware.com/pipermail/insight-users/2003-October/
>>>>>>>> 005272.html
>>>>>>>>
>>>>>>>>> From the comments at the top of ImageRegistration9.cxx (from
>>>>>>>>> the Software
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Guide) show:
>>>>>>>>
>>>>>>>> // Note that the final total offset of
>>>>>>>> the transform
>>>>>>>> // is to be computed as a combination of the shift due
>>>>>>>> rotation plus the
>>>>>>>> // explicit translation set on the transform.
>>>>>>>> //
>>>>>>>>
>>>>>>>> General usage would be:
>>>>>>>>
>>>>>>>> xform->Translate( delta );
>>>>>>>> xform->Rotate( theta );
>>>>>>>> // ...
>>>>>>>> xform->ComputeOffset();
>>>>>>>>
>>>>>>>> resample->Update();
>>>>>>>>
>>>>>>>>
>>>>>>>> ComputeOffset() is actually called explicitly in all the
>>>>>>>> CenteredAffineTransform methods that affect the transform, but
>>>>>>>> (obviously)
>>>>>>>> not any AffineTransform methods. It isn't called automagically
>>>>>>>> (after each
>>>>>>>> change) since it only needs to be done once, although it
>>>>>>>> probably wouldn't
>>>>>>>> hurt if it were.
>>>>>>>>
>>>>>>>> :: Gavin
>>>>>>>>
>>>>>>>> --
>>>>>>>> Gavin Baker Complex
>>>>>>>> Systems Group
>>>>>>>> http://www.cs.mu.oz.au/~gavinb The University of
>>>>>>>> Melbourne
>>>>>>>> _______________________________________________
>>>>>>>> Insight-users mailing list
>>>>>>>> Insight-users at itk.org
>>>>>>>> http://www.itk.org/mailman/listinfo/insight-users
>>>>>>>>
>>>>>>> Lucas Lorenzo
>>>>>>> University of Utah
>>>>>>> Nora Eccles Harrison CardioVascular Research and Training
>>>>>>> Institute
>>>>>>> Fellows Room
>>>>>>> 95 South 2000 East
>>>>>>> Salt Lake City, UT 84112-5000
>>>>>>> e-mail: lucas at cvrti.utah.edu
>>>>>>> telephone: 801-587-9536
>>>>>>> _______________________________________________
>>>>>>> Insight-users mailing list
>>>>>>> Insight-users at itk.org
>>>>>>> http://www.itk.org/mailman/listinfo/insight-users
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> Lucas Lorenzo
>>>>>
>>>>> University of Utah
>>>>> Nora Eccles Harrison CardioVascular Research and Training Institute
>>>>> Fellows Room
>>>>> 95 South 2000 East
>>>>> Salt Lake City, UT 84112-5000
>>>>>
>>>>> e-mail: lucas at cvrti.utah.edu
>>>>> telephone: 801-587-9536
>>>>>
>>>>>
>>>> Lucas Lorenzo
>>>> University of Utah
>>>> Nora Eccles Harrison CardioVascular Research and Training Institute
>>>> Fellows Room
>>>> 95 South 2000 East
>>>> Salt Lake City, UT 84112-5000
>>>> e-mail: lucas at cvrti.utah.edu
>>>> telephone: 801-587-9536
>>>
>>>
>>>
>>>
>>>
>> Lucas Lorenzo
>> University of Utah
>> Nora Eccles Harrison CardioVascular Research and Training Institute
>> Fellows Room
>> 95 South 2000 East
>> Salt Lake City, UT 84112-5000
>> e-mail: lucas at cvrti.utah.edu
>> telephone: 801-587-9536
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
Lucas Lorenzo
University of Utah
Nora Eccles Harrison CardioVascular Research and Training Institute
Fellows Room
95 South 2000 East
Salt Lake City, UT 84112-5000
e-mail: lucas at cvrti.utah.edu
telephone: 801-587-9536
More information about the Insight-users
mailing list