# [Insight-users] Going from 4x4 matrix to Similarity3DTransform and back during registration

Luis Ibanez luis.ibanez at kitware.com
Tue Jan 24 11:41:22 EST 2006

```
Hi Jan,

In order to convert your 4x4 transform in to an
ITK Similarity transform you can do the following

Your 4x4 matrix can be interpreted as:

R11  R12  R13  T1
R21  R22  R23  T2
R31  R32  R33  T3
Sh1  Sh2  Sh3  SC

Where

T1,T2,T3       are Translations
SC             is a Scalinig factor
Sh1,Sh2,Sh3    are Shearing factors
R11... R33     are the rotations

If your 4x4 matrix is formed correctly
representing a Similarit transform, then
the following constrains may be maintained

1) Sh1, Sh2, Sh3  MUST be null
2) The 3x3 submatrix R11..R22  MUST be orthogonal

It that holds true, then you can use SVD in order
to find the Versor that matches the 3x3 matrix.

You will find and example on how to do this on
the Registration example:

Insight/
Examples/
Registration/
ImageRegistration9.cxx

Then you can setup the ITK Similarity transform
by using:

A) an ITK Versor for the rotation
B) an ITK Vector for the translation
C) a scalar value for the Scaling

Please let us know if you have further questions.

Thanks

Luis

----------------
Jan Owoc wrote:
> Hi,
>
>
> I am writing a registration program that is to use a
> Similarity3DTransform as its transform; I need
> rotation/translation/isotropic scaling.
> I am using a different program to pick points for an initial guess, and
> it returns the "best" 4x4 matrix to map the moving image to the fixed image.
>
> I read in the mailing lists that use of SetMatrix() is incorrect, as it
> is meant as an internal function.
> Could someone please tell me what is the correct way to (properly) give
> the transform the 4x4 matrix and let it work out the closest
> Similarity3DTransform to match the matrix?
>
> Likewise, after the registration is finished, I would like a convenient
> way to recover the new 4x4 matrix.
>
>
> Thank you.
>
>
> Jan Owoc
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users

```