# (Just) isotropic scaling

**URL:** https://discourse.itk.org/t/just-isotropic-scaling/3306
**Category:** Beginner Questions
**Tags:** python, simpleitk
**Created:** [July 20, 2020, 9:50pm UTC](https://discourse.itk.org/t/just-isotropic-scaling/3306 "2020-07-20T21:50:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![david.russell](https://discourse.itk.org/user_avatar/discourse.itk.org/david.russell/32/1637_2.png) [@david.russell](https://discourse.itk.org/u/david.russell)
#### Post date: [July 20, 2020, 9:50pm UTC](https://discourse.itk.org/t/just-isotropic-scaling/3306/1 "2020-07-20T21:50:51Z")

</div>

I’m trying to do registration in 2D using only one scale parameter applied to to both axes. I believe this is called isotropic scaling. I’ve been struggling because the [scale transform](http://insightsoftwareconsortium.github.io/SimpleITK-Notebooks/Python_html/22_Transforms.html) is ansiotropic. I was thinking that perhaps I could use a similarity transform and constrain the translation and rotation terms, but I haven’t found a way to do this.

Does anyone know whether this is possible? I’d prefer to stay within Python SimpleITK but could migrate to something else if needed.

---

<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: [July 21, 2020, 1:57am UTC](https://discourse.itk.org/t/just-isotropic-scaling/3306/2 "2020-07-21T01:57:04Z")

</div>

> [@david.russell](#):
>
> I was thinking that perhaps I could use a similarity transform and constrain the translation and rotation terms, but I haven’t found a way to do this.

Have you experimented with the [ImageRegistrationMethod:: SetOptimizerWeights](https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1ImageRegistrationMethod.html#ad6017d559ec79cc761983b25b86016eb) method?

---

<div class="post-metadata">

### Author: ![david.russell](https://discourse.itk.org/user_avatar/discourse.itk.org/david.russell/32/1637_2.png) [@david.russell](https://discourse.itk.org/u/david.russell)
#### Post date: [July 21, 2020, 12:36pm UTC](https://discourse.itk.org/t/just-isotropic-scaling/3306/3 "2020-07-21T12:36:16Z")

</div>

Thanks Bradley! I think that was exactly what I was looking for. For those interested in the full snippet, here it is below.  
`initial_transform = sitk.Similarity2DTransform()`  
`# set the transform to rotate and scale about the center of the moving image`  
`initial_transform.SetCenter([int(x / 2) for x in moving_image.GetSize()])`  
`R = sitk.ImageRegistrationMethod()`  
`# parameters are ordered as (scale, rotation, x, y)`  
`R.SetOptimizerWeights((1, 0, 0, 0))`

---

<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: [July 21, 2020, 1:36pm UTC](https://discourse.itk.org/t/just-isotropic-scaling/3306/4 "2020-07-21T13:36:54Z")

</div>

Thanks for sharing your solution.

> [@david.russell](#):
>
> `# set the transform to rotate and scale about the center of the moving image`  
> `initial_transform.SetCenter([int(x / 2) for x in moving_image.GetSize()])`

Another tip you can use the [CenterTransformInitializer](https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1CenteredTransformInitializerFilter.html) to robustly do this center initialization. Your code only will work when the origin, spacing and direction cosine matrix are trivial (identity/unit).

Here is a notebook on the topic: [63\_Registration\_Initialization](http://insightsoftwareconsortium.github.io/SimpleITK-Notebooks/Python_html/63_Registration_Initialization.html)
