[Insight-users] Affine transform - decomposition ?
Karthik Krishnan
Karthik.Krishnan at kitware.com
Tue Apr 26 10:04:11 EDT 2005
This is exactly done in ImageRegistration9.cxx which converts affine
paramters to ...
OptimizerType::ParametersType finalParameters =
registration->GetLastTransformParameters();
//Compute the rotation angle and scaling from SVD of the matrix
// \todo Find a way to figure out if the scales are along X or along Y.
// VNL returns the eigenvalues ordered from largest to smallest.
vnl_matrix<double> p(2, 2);
p[0][0] = (double) finalParameters[0];
p[0][1] = (double) finalParameters[1];
p[1][0] = (double) finalParameters[2];
p[1][1] = (double) finalParameters[3];
vnl_svd<double> svd(p);
vnl_matrix<double> r(2, 2);
r = svd.U() * vnl_transpose(svd.V());
double angle = asin(r[1][0]);
std::cout << " Scale 1 = " << svd.W(0) << std::endl;
std::cout << " Scale 2 = " << svd.W(1) << std::endl;
std::cout << " Angle (degrees) = " << angle * 45.0 / atan(1.0) << std::endl;
thanks
Miller, James V (Research) wrote:
> If I recall correctly, the Graphic Gems series of books (I, II, III,
> IV, ...) had a number of "sections" on transformation decomposition.
> Graphics Gems II has two nice sections on pages 320-333
>
> Note, itk::AffineTransform is stored as a matrix and a vector
> (offset). The vector is the translation component. So you can just
> call GetOffset() to get the 3 translation parameters. That leaves 9
> parameters to decompose (rotation, scale, skew). Reflections will just
> be negative scales so we can ignore that for now.
>
> The first approach (Graphics Gems II, pg 320) essentially
> orthogonalizes the matrix to get the rotation components and whatever
> is left over from the orthogonalization forms the scaling and skew.
>
> The second approach (Graphics Gems II, pg 324) converts the
> decomposition problem to an eigenvector problem. Let the matrix part
> of the affine transform be M and look at the eigenvector problem
>
> M*v = a*v
>
> where v is an eigenvector of M and a is the associated eigenvalue. The
> eigenvectors and eigenvalues of M tell us about the axis of rotation,
> the amount of scaling etc. The presentation is Graphics Gems II, is
> geared for determining the parameters of rotation, scaling, skew, etc.
> when the transformation in question is ONE of rotation, scaling, skew,
> etc. In other words, if you know the matrix is just a rotation, this
> is how to extract the rotation parameters; if you know the
> transformation is just a scaling, this is how to extract the scaling
> parameters, etc. I don't think this section addresses the problem of
> having a general affine transformation and decomposing it into
> scalings, rotations, etc.... However, many of the ideas in this
> section would still apply. The eigenvectors of the matrix M are
> invariant to the transformation M (only changing the vectors by a
> scale factor). Therefore, the eigenvalues are scale parameters.
> However, they are the scale parameters along the associated
> eigenvectors and not the scalings along the cartesian axes. But this
> is the general idea.
>
> Jim
>
>
>
> -----Original Message-----
> *From:* insight-users-bounces at itk.org
> [mailto:insight-users-bounces at itk.org]*On Behalf Of *Roxana Racz
> *Sent:* Monday, April 25, 2005 6:02 PM
> *To:* insight-users at itk.org
> *Subject:* [Insight-users] Affine transform - decomposition ?
>
> Hello everyone,
>
> I am working on a registration application.
> I would like to display the **geometrically meaningful**
> components using the 12 parameters of the affine transform as
> returned by the registration routine.
>
> That is: from the 12 "raw" parameters returned by the registration
> algorithm employed, I need to be able to monitor the following
> quantities:
> 1.translation(3),
> 2.rotation(3),
> 3.scaling(3),
> 4.skew (?) and
> 5.reflection(3?)
>
> --- Does anyone know of a method based on itk? (it seems that vtk
> offers only the extraction of 1, 2, 3: GetPosition,
> GetOrientation, GetScale, all defined in vtkTransform.cxx).
>
> --- Could anyone recommend a good reading on the underlying maths
> for this extractions?
>
> Thanks in advance,
>
> Roxana
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk.org
>http://www.itk.org/mailman/listinfo/insight-users
>
>
More information about the Insight-users
mailing list