[Insight-users] Finding the inverse of a Transformation

Luis Ibanez luis.ibanez at kitware.com
Wed Jun 23 13:55:48 EDT 2004


Hi Neilson,

Yeap, this is equivalent to converting the parameters.
Note that it is safer to have a conversion from the
transform than from the array of doubles, because the
Transform is the one who knows how the parameters have
been encoded in the array.

Still the easy way to do it is to create a class that
take and itk::Matrix and an itk::Vector and produces
a vtkTransform. The matrix and vector are can be taken
from the transform, and in that way the conversion class
is not limited to a specific type of transform. Such a
class will work with all the Rigid transforms in ITK as
well as with the AffineTransform and SimilarityTransform.


Please let us know if you need any help in writing this
class



   Thanks,



     Luis



------------------------------
N.E. Mackenzie Mackay wrote:

> sorry Luis...  by parameters I mean the final parameters of the 
> registration.  Right now it is an angle, center and translation.  It 
> would be nice to have all that in a 4x4 matrix.
> 
> Neilson
> On Jun 22, 2004, at 4:22 PM, Luis Ibanez wrote:
> 
>>
>>
>> Hi Neilson,
>>
>>
>> The problem is that the "Inverse()" method is not defined in
>> the CenteredRigid2DTransform.
>>
>> Could you please log a bug repport on the bug tracker ?
>> The link is:
>>
>>                http://www.itk.org/Bug/
>>
>> You just need to create an account using your email address.
>>
>>
>> -------
>>
>>
>> In the meantime, what you can do is to pass the rotation matrix
>> and offset from this transform into an itkAffineTransform, and
>> then ask the affinne transform to compute the inverse.  The resulting 
>> transform should still be a rigid transform (but stored in the form
>> of an affine transform).
>>
>>
>>
>> The code will be something like
>>
>>
>>
>>   typedef itk::AffineTransform< 2, double >  AffineType;
>>
>>   AffineType::Pointer affine = AffineType::New();
>>
>>   finalTransform->SetParameters( parameters );
>>
>>   affine->SetMatrix( finalTransform->GetRotationMatrix() );
>>   affine->SetOffset( finalTransform->GetOffset() );
>>
>>   AffineType::Pointer invTransform = affine->Inverse();
>>
>>   AffineType::MatrixType matrix = invTransform->GetMatrix();
>>   AffineType::OffsetType offset = invTransform->GetOffset();
>>
>>
>>
>>
>> Regards,
>>
>>
>>    Luis
>>
>>
>> -----------------------------
>> N.E. Mackenzie Mackay wrote:
>>
>>> Hi,
>>>     I have been able to register two images together successfully.  
>>> Right now I am trying to find the inverse of the Transformation 
>>> between the two but having problems.  I am using 
>>> CenteredRigid2DTansform as my transformation.
>>>     Two questions:
>>>         First, how do I get the inverse of the transform.  I tried this:
>>>             TransformType::Pointer finalTransform = 
>>> TransformType::New();
>>>             finalTransform->SetParameters ( finalParameters );
>>>             TransformType::Pointer finalTrasnformInvers = 
>>> TransformType::New();
>>>             finalTransformInverse = finalTransform->Inverse();
>>>         When I compile this code I get a compile error :
>>>             binary '=' operator defined which takes a right-hand 
>>> operand of type 'class itk::SmartPointer<class 
>>> itk::Rigid3DTransform<double> >' (or there is no acceptable conversion)
>>>         I tried changing my code to:
>>>             TransformType::Pointer finalTransform = 
>>> TransformType::New();
>>>             finalTransform->SetParameters ( finalParameters );
>>>                    finalTransform->Inverse();
>>>             TransformType::Pointer finalTrasnformInvers = 
>>> TransformType::New();
>>>             finalTransformInverse = finalTransform;
>>>         This compiled but didn't give the actual inverse.  I gave the 
>>> original one.
>>>     My second question is (and probably answered before) how do I 
>>> output the transform as a 4x4 matrix.  My goal is to eventually use 
>>> it in vtk.
>>> Thanks for all the help,
>>> Neilson
>>>     _______________________________________________
>>> 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