[Insight-users] Applying an affine to an image with a special twist.

Peter Lorenzen lorenzen at cs . unc . edu
Fri, 23 May 2003 15:21:55 -0400


Hi Lydia,

I completely missed the Compose method.  Your suggestion worked.  
Thanks.

- Peter

On Friday, May 23, 2003, at 14:37 US/Eastern, Lydia Ng wrote:

> Hi Peter,
>
> AffineTransform has a Compose method which takes another
> AffineTransform.
> I wonder if you can SetMatrix and SetOffset on another instance of
> AffineTransform (say transform2) and then compose it with the original?
>
> Cheers,
> Lydia
>
>> -----Original Message-----
>> From: Peter Lorenzen [mailto:lorenzen at cs . unc . edu]
>> Sent: Friday, May 23, 2003 11:28 AM
>> To: Insight-users at public . kitware . com
>> Subject: [Insight-users] Applying an affine to an image with a special
>> twist.
>>
>> Hi All,
>>
>> In the ITK examples directory there are several well documented
>> examples of how to translate an image to some origin, apply a
> rotation,
>> and translate back from said origin.
>>
>> I would like to do the same thing, except I would like to replace the
>> rotation part with the application of an affine.
>>
>> For example, consider the following code snippet:
>>
>>    //////////////////////////////////////////////
>>    // Translate centroid to the origin in (mm) //
>>    //////////////////////////////////////////////
>>    TransformType::OutputVectorType translateCentroidToOrigin;
>>    translateCentroidToOrigin[0] = -centroidX * imageSpacing[0];
>>    translateCentroidToOrigin[1] = -centroidY * imageSpacing[1];
>>    translateCentroidToOrigin[2] = -centroidZ * imageSpacing[2];
>>    transform->Translate( translateCentroidToOrigin );
>>
>>    //////////////////////
>>    // Apply the affine //
>>    //////////////////////
>>    transform->SetMatrix( matrix );
>>    transform->SetOffset( offset );
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> I can apply this affine, but I end up blowing away the original
>> translation of the
>> centroid to the origin.
>>
>>    ////////////////////////////////////////////////
>>    // Translate centroid from the origin in (mm) //
>>    ////////////////////////////////////////////////
>>    TransformType::OutputVectorType translateCentroidFromOrigin;
>>    translateCentroidFromOrigin[0] = centroidX * imageSpacing[0];
>>    translateCentroidFromOrigin[1] = centroidY * imageSpacing[1];
>>    translateCentroidFromOrigin[2] = centroidZ * imageSpacing[2];
>>    transform->Translate( translateCentroidFromOrigin );
>>
>>
>> Is there a way I can do this in ITK without having to generate two
>> additional images (i.e. decouple with transformation into three
>> separate stages)?
>>
>>
>> Thanks!
>>
>> - Peter
>>
>> --
>> Peter J. Lorenzen
>> Ph.D. Student
>> Department of Computer Science
>> University of North Carolina at Chapel Hill
>> Sitterson Hall 268, Campus Box 3175
>> Chapel Hill, NC  27599-3175
>>
>> TEL (919) 962-1879
>> FAX (919) 962-1699
>> E-MAIL lorenzen at cs . unc . edu
>> WEB PAGE http://www . cs . unc . edu/~lorenzen
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at public . kitware . com
>> http://public . kitware . com/mailman/listinfo/insight-users
>>
--
Peter J. Lorenzen
Ph.D. Student
Department of Computer Science
University of North Carolina at Chapel Hill
Sitterson Hall 268, Campus Box 3175
Chapel Hill, NC  27599-3175

TEL (919) 962-1879
FAX (919) 962-1699
E-MAIL lorenzen at cs . unc . edu
WEB PAGE http://www . cs . unc . edu/~lorenzen