[Insight-users] Applying an affine to an image with a special twist.
Lydia Ng
lng at insightful . com
Fri, 23 May 2003 11:37:22 -0700
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.
>=20
> Hi All,
>=20
> 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.
>=20
> I would like to do the same thing, except I would like to replace the
> rotation part with the application of an affine.
>=20
> For example, consider the following code snippet:
>=20
> //////////////////////////////////////////////
> // Translate centroid to the origin in (mm) //
> //////////////////////////////////////////////
> TransformType::OutputVectorType translateCentroidToOrigin;
> translateCentroidToOrigin[0] =3D -centroidX * imageSpacing[0];
> translateCentroidToOrigin[1] =3D -centroidY * imageSpacing[1];
> translateCentroidToOrigin[2] =3D -centroidZ * imageSpacing[2];
> transform->Translate( translateCentroidToOrigin );
>=20
> //////////////////////
> // 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.
>=20
> ////////////////////////////////////////////////
> // Translate centroid from the origin in (mm) //
> ////////////////////////////////////////////////
> TransformType::OutputVectorType translateCentroidFromOrigin;
> translateCentroidFromOrigin[0] =3D centroidX * imageSpacing[0];
> translateCentroidFromOrigin[1] =3D centroidY * imageSpacing[1];
> translateCentroidFromOrigin[2] =3D centroidZ * imageSpacing[2];
> transform->Translate( translateCentroidFromOrigin );
>=20
>=20
> 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)?
>=20
>=20
> Thanks!
>=20
> - Peter
>=20
> --
> 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
>=20
> TEL (919) 962-1879
> FAX (919) 962-1699
> E-MAIL lorenzen at cs . unc . edu
> WEB PAGE http://www . cs . unc . edu/~lorenzen
>=20
> _______________________________________________
> Insight-users mailing list
> Insight-users at public . kitware . com
> http://public . kitware . com/mailman/listinfo/insight-users