Scaling Problems with LandmarkBasedTransformInitializer

Hi,

I am a little bit confused about the results I get from the LandmarkBasedTransformInitializer in combination with the similarity Transform.
Lets say I have to sets of landmarks (points_a and points_b) where points_b is simply an uspscaled version of points_a (in reference to the origin). For some reason the TransformInitializer only tries to fit the translation, while the scale stays 1. Here is a minimal example in python using simpleITK:

import SimpleITK as sitk
import numpy as np

points_a = [[0,0], [0,1], [1,0], [1,1]]
points_b = [[0,0], [0,2], [2,0], [2,2]]
a_flat = [c for p in points_a for c in p]
b_flat = [c for p in points_b for c in p]
similarity_transform = sitk.LandmarkBasedTransformInitializer(
            sitk.Similarity2DTransform(),
            a_flat,
            b_flat
        )
matrix = np.reshape(similarity_transform.GetMatrix(), (2,2))
translation = similarity_transform.GetTranslation()
scale = similarity_transform.GetScale()
print(matrix)
print(translation)
print(scale)

Output:
[[1, 0]
[0, 1]]
[0.5, 0.5]
1.0

I don’t understand why the scaling is not set correctly to 2 in this example.
Best regards,
Jan

1 Like

I suspect it has to do with the following line in the [documentation](https://Currently, the following transforms are supported by the class: VersorRigid3DTransform Rigid2DTransform AffineTransform BSplineTransform) of the class:


Additional useful information can be obtained if SimpleITK's object oriented interface is used and  "Debug" mode is enabled.

I would try with a Rigid2DTransform or AffineTransform class to compare results.

The dynamic_casting of the transform occurs here in ITK:
https://github.com/InsightSoftwareConsortium/ITK/blob/3c574f611d983e3c1f763d630a48a30c87940cd9/Modules/Registration/Common/include/itkLandmarkBasedTransformInitializer.hxx#L36
Currently, the following transforms are supported by the class: VersorRigid3DTransform Rigid2DTransform AffineTransform BSplineTransform

Thank you very much for the fast reply :slight_smile: Using AffineTransform instead works like a charm. I must have overlooked this in the documentation. I am still quite a bit overwhelmed with the steep learning curve.