Is it possible to transform the result of a VTK IterativeClosestPointTransform into an ITK AffineTransformation? My intention was to apply the ICP to some points, then use the transformation and apply it to images in ITK.
I hoped to be able to just transform the homogeneous matrix into the paramaters and FixedParameters of the AffineTransformation but it does not be that simple.
Right now, I get the following 4x4 matrix from the ICP:
[[ 1.03483326e+00 -5.71344952e-02 0.00000000e+00 5.90081011e+01]
[ 5.71344952e-02 1.03483326e+00 0.00000000e+00 -4.94724879e+01]
[ 0.00000000e+00 0.00000000e+00 1.03640930e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00]]
I only transform 2D points, hence, I’m only interested in the 2x2 matrix in the left upper corner and the two translational values in the 4th column.
Thus, my Parameter list is [1.035, -0.057, 0.057, 1.035, 59, -49.4] and the fixed Parameters set to [0.0, 0.0].
I confirmed that both transformations are able to transform single points the same way (AffineTransform.TransformPoint() and vtkIterativeClosestPointTransform.TransformPoint()), however if I apply the Inverse of the transformation to an Image, it does not give the correct result.
I also tried to swap translation and center. That seems to give a better result, but the resulting image is still offset. I see that there is the offset set in the transformation (this is already the inverse):
itk::simple::AffineTransform
AffineTransform (0x9645370)
RTTI typeinfo: itk::AffineTransform<double, 2u>
Reference Count: 1
Modified Time: 2867
Debug: Off
Object Name:
Observers:
none
Matrix:
0.957818 0.0543163
-0.0543163 0.957818
Offset: [-5.31175, -0.582364]
Center: [-54.0624, 55.8078]
Translation: [0, 0]
Inverse:
1.04069 -0.059016
0.059016 1.04069
Singular: 0
Is that the right way? At least it looks like that there is only a translational component wrong. Rotation and scaling seems to be correct that way.
What do I miss here? Is the center of rotation saved somewhere in the VTK transformation or does it use 0/0?
In general, what is the correct way to load such homogeneous transformation matrices into ITK?