# Scaling Problems with LandmarkBasedTransformInitializer

**URL:** <https://discourse.itk.org/t/scaling-problems-with-landmarkbasedtransforminitializer/7503>\
**Category:** Beginner Questions\
**Created:** [April 24, 2025, 1:42pm UTC](https://discourse.itk.org/t/scaling-problems-with-landmarkbasedtransforminitializer/7503 "2025-04-24T13:42:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rextorian](https://discourse.itk.org/letter_avatar_proxy/v4/letter/r/73ab20/32.png) [@Rextorian](https://discourse.itk.org/u/Rextorian)\
**Post date:** [April 24, 2025, 1:42pm UTC](https://discourse.itk.org/t/scaling-problems-with-landmarkbasedtransforminitializer/7503/1 "2025-04-24T13:42:32Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

**Author:** ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)\
**Post date:** [April 24, 2025, 1:53pm UTC](https://discourse.itk.org/t/scaling-problems-with-landmarkbasedtransforminitializer/7503/2 "2025-04-24T13:53:47Z")

</div>

> [@Rextorian](#):
>
> is not set correctly to 2 in this example.  
> Best regards,

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

```auto

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

```

---

<div class="post-metadata">

**Author:** ![Rextorian](https://discourse.itk.org/letter_avatar_proxy/v4/letter/r/73ab20/32.png) [@Rextorian](https://discourse.itk.org/u/Rextorian)\
**Post date:** [April 25, 2025, 4:45pm UTC](https://discourse.itk.org/t/scaling-problems-with-landmarkbasedtransforminitializer/7503/3 "2025-04-25T16:45:39Z")

</div>

Thank you very much for the fast reply 🙂 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.
