# How to calculate the reverse 3d affine transform?

Hi all,

I tried to calculate the reverse affine transform matrix and the returned translation vector is always wrong, which bother me a lot. Anyone has any ideas? I appreciate for any suggestions. Thank you!

Here are some details steps I did:
Assume I have two 3d images, A & B. I’ve calculated the transform from A to B and get a 12d vector (V). Now I want to get the transform matrix for B->A directly from the learned 12d vector: V.

I know the first 9 elements corresponding to M matrix, and the last 3 corresponding to the translation vector.

So I calculated the reverse M matrix as reverse(M) and reversed translation vector as -np.matmul(reverse(M), V(-3:)) and it turned out the reversed translation vector is wrong. May anyone know why this happens? Thank you!

Have you tried simply negating the translation (instead of multiplying it with the inverse of rotation/scaling/shear)? Have you tried appending 0 0 0 1 as the fourth row and then inverting the resulting 4x4 matrix? If you are using itk::AffineTransform class, you can use GetInverse() method.

1 Like