Skip to content
Advertisement

Manual registration with SimpleElastix

I’m using SimpleElastix (https://simpleelastix.github.io/) for the registration (Affine) of the two 2D images (see attached) enter image description here. For this I’m using this code :

JavaScript

After the execution of the latter, I obtain the following TransformParameters0.txt that contains the transformation matrix :

JavaScript

My aim is to use this matrix-tranformation to register the floating image and get a registrered image similar to the one obtained by SimpleElastix. For this I’m using this small script :

JavaScript

I obtain this registered image which I compare with the result of SimpleElastix (see image attached)enter image description here. We can observe that the scaling hasn’t been operated and there is a problem with the translation. I wonder if I missed something in the transformation matrix, since SimpleElastix provide a good registration result.

Any ideas ?

Thank you

Advertisement

Answer

The best and safest way to apply the transformation is with the sitk.TransformixImageFilter(), but I assume you have reasons to do it a different way. With that out of the way…

First issue: you have to take into account the center of rotation. The total matrix does the following:

  1. transforms the center to the origin
  2. applies the matrix T you have
  3. translates the result back, like this
JavaScript

I strongly recommend using scikit-image to do the transforming for you.

JavaScript

If you really must do the transforming yourself, there are two things that need changing in your code:

  1. the axes are flipped relative to elastix expectations
  2. the transformation is from fixed coordinates to moving coordinates
JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement