[Insight-users] inverse of affine transform using transform->GetInverseTransform();
John D
john.dz.eis at gmail.com
Wed Feb 12 12:43:32 EST 2014
Sorry. Forgot to include the code in the earlier post
%The affine parameters come in the vAffineParameters vector to the function
typedef itk::AffineTransform< double, 2 > TransformType;
TransformType::Pointer transform = TransformType::New();
TransformType::ParametersType
affParameters(transform->GetNumberOfParameters());
for(int i=0;i<6;i++)
affParameters[i] = vAffineParameters[i];
transform->SetParameters(affParameters);
double center[2];
center[0] = vAffineParameters[6];
center[1] = vAffineParameters[7];
transform->SetCenter(center);
TransformType::InverseTransformBasePointer inverse =
transform->GetInverseTransform();
TransformType::ParametersType inverseParameters =
inverse->GetParameters();
float a11 = inverseParameters[0];
float a12 = inverseParameters[1];
float a21 = inverseParameters[2];
float a22 = inverseParameters[3];
float Tx = inverseParameters[4]; //Tx and Ty seems to be not correct?
float Ty = inverseParameters[5]; //Tx and Ty seems to be not correct?
Cx = transform->GetCenter()[0]; //Is there a way to get the center from
the inverse transform?
Cy = transform->GetCenter()[1];
On Wed, Feb 12, 2014 at 9:40 AM, John D <john.dz.eis at gmail.com> wrote:
> Hello users,
>
> I have a problem where I need to compute the inverse of an affine
> transform in 2D.
>
> I am seeing a problem in the results. Lets say my affine matrix has just
> pure rotation at 45 degree.
>
> So my A matrix is [cost(45) -sin(45); sin(45 cos(45)]. There is no
> translation and so [Tx Ty] = [0 0]. I am trying to rotate a square that is
> 6000 on each side and my center of rotation is mid point of the square
> [3000 3000]
>
> When I use transform->GetInverseTransform() to find the inverse transform
>
> I am getting the correct coordinates for the A matrix. However the
> returned translations in the inverse matrix are wrong. I would have
> expected the Tx, Ty to be [0 0] in the inverse also since rotation is wrt
> to the center. However I am getting [Tx, Ty] = [3000, -1243]
>
> What am I missing? Also when computing the inverse, will the center of
> rotation get changed? How can I get the new center of rotation?
>
> Thanks,
> John
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20140212/7a81e411/attachment.html>
More information about the Insight-users
mailing list