Reputation: 930
I am reading an ITK transform from a file. I cannot figure out the API for getting the Translation or the Matrix directly from the transform.
t = sitk.ReadTransform('sample_transform.h5')
print(t)
Here is the result of printing:
itk::simple::Transform
VersorRigid3DTransform (0x55c3e22f5de0)
RTTI typeinfo: itk::VersorRigid3DTransform<double>
Reference Count: 1
Modified Time: 802
Debug: Off
Object Name:
Observers:
none
Matrix:
0.999862 0.016289 0.00333268
-0.0161218 0.998848 -0.0451944
-0.00406501 0.0451344 0.998973
Offset: [-1.3857, 0.238944, 0.984074]
Center: [36.1356, 6.81771, -27.0756]
Translation: [-1.36988, 0.872183, 1.17271]
Inverse:
0.999862 -0.0161218 -0.00406501
0.016289 0.998848 0.0451344
0.00333268 -0.0451944 0.998973
Singular: 0
Versor: [ 0.0225887, 0.00184996, -0.00810505, 0.99971 ]
Are there functions to get the Matrix and Translation directly?
It looks likes that translation can be retrieved from the last three items of the t.GetParameters():
print(t.GetParameters())
would give:
(0.02258874140769294,
0.0018499585651891462,
-0.00810504740162434,
-1.3698806341361933,
0.8721829896773953,
1.1727120470384382)
Upvotes: 2
Views: 2216
Reputation: 1431
The ReadTransform
methods always returns a std::Transform base class. That common interface can be useful. Sometime you the derived interface is wanted which provides the useful methods like GetTranslation
and GetMatrix
[1]. This can simply be done by converting/casting the base transform:
myVersorTransform = VersorRigid3DTransform(t)
[1] https://itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1VersorRigid3DTransform.html
Upvotes: 2