[Insight-users] Applying an affine to an image with a special twist.
Peter Lorenzen
lorenzen at cs . unc . edu
Fri, 23 May 2003 14:27:56 -0400
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