[Insight-users] Finding the inverse of a Transformation

Luis Ibanez luis.ibanez at kitware.com
Wed Jun 23 13:16:02 EDT 2004


Hi Nelson,

Thanks for filing the bug report.

There is not a particular method for getting
the transform in the 4x4 matrix format
(homogeneous coordinates).

It may be a nice little class to have, maybe
to put it in InsightApplications/Auxiliary/vtk.

It could accept an itk::Matrix<double,3,3>, and
an itk::Vector<double,3> and produce a vtkTransform.

If you feel compelled to write such a class, we
will be happy to have it included in InsightApplications.


Please let us know,



    Thanks


       Luis


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

> Considered the bug reported.  One down.
> 
> I was wondering if itk had anything to convert the final parameters into 
> a 4x4 homogeneous matrix.  I am going to use the result in vtk.
> 
> Thanks again,
> 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
>>
>>
>>
>>
> 
> _______________________________________________
> 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