# SimpleITK Registration

**URL:** https://discourse.itk.org/t/simpleitk-registration/5709
**Category:** Algorithms
**Tags:** registration, simpleitk
**Created:** [February 15, 2023, 9:20pm UTC](https://discourse.itk.org/t/simpleitk-registration/5709 "2023-02-15T21:20:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![elapins](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/96bed5/32.png) [@elapins](https://discourse.itk.org/u/elapins)
#### Post date: [February 15, 2023, 9:20pm UTC](https://discourse.itk.org/t/simpleitk-registration/5709/1 "2023-02-15T21:20:07Z")

</div>

Hello,

I have been trying to implement a SimpleITK registration framework to register a reference image that has no change with a deformed image (warped image).

I split the reference image up into subregions and try to register each reference subregion to the deformed image.

So far, I have implemented a Translation only registration, but would like to extend this to use Affine Transforms.  
For whatever reason though, when I switch to Affine Transformations, my results are extremely wrong and make no sense.

Would someone be able to help me with moving forward with extending to Affine Registration?  
Any help is much appreciated.  
Thank you so much

The attached files include one singular subregion that I am trying to register, but I would ultimately like to do this for every subregion of the reference image.

Reference Image: entire reference image  
Deformed Image: entire deformed image  
Fixed Image: Search Region of the deformed image  
Moving Image: Subregion of the reference image

Subset00.tif corresponds to area00.tif, …, etc.  
[DeformedImg.tif](https://discourse.itk.org/uploads/short-url/6cmka2g4FiVaQ2RpLoFmDFPi3EA.tif) (345.5 KB)  
[ReferenceImg.tif](https://discourse.itk.org/uploads/short-url/4B2nT12wWIJ9WdmzBSpsNCmDEtE.tif) (256.2 KB)  
[subset00\_ref.tif](https://discourse.itk.org/uploads/short-url/yj9tBWtK14KPZNCJbAPUDWGz0fn.tif) (3.1 KB)  
[subset01\_ref.tif](https://discourse.itk.org/uploads/short-url/8u8szWBkmyUlx72YgqItoFXWDad.tif) (3.0 KB)  
[area00.tif](https://discourse.itk.org/uploads/short-url/tmLBnNrmxFiNJ5CQZXNaSJuNFjg.tif) (43.6 KB)  
[area01.tif](https://discourse.itk.org/uploads/short-url/fsD0VKE5GB9lTNQOEDDQ88Mok0m.tif) (50.2 KB)

Code:

[code.cpp.txt](https://discourse.itk.org/uploads/short-url/gtEGKt0VhjuWbOpqXioQIsAXCAz.txt) (2.7 KB)

Initial Vals:  
[initGuess.txt](https://discourse.itk.org/uploads/short-url/uoSFbO0wBiSSckq8vQKeGhZmenb.txt) (860 Bytes)

---

<div class="post-metadata">

### Author: ![Keyn34](https://discourse.itk.org/letter_avatar_proxy/v4/letter/k/9fc29f/32.png) [@Keyn34](https://discourse.itk.org/u/Keyn34)
#### Post date: [February 16, 2023, 9:16am UTC](https://discourse.itk.org/t/simpleitk-registration/5709/2 "2023-02-16T09:16:38Z")

</div>

Hello @elapins,

You can paste code directly into the forum and keep the formatting. Use the ‘preformatted text’ option in the editor, or hit CTRL+E.

I quickly looked through your code.cpp.txt  
Two things, more like guesses as I didn’t try it out as of now:

1. Your initial transform is still a `sitk::TranslationTransform`. For an affine, you can use [`AffineTransform`](https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1AffineTransform.html), or if you only want to consider translation and rotation, you might want to use [`2DEulerTransform`](https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1Euler2DTransform.html).
2. If you are including rotation in registration, you probably need to call [`SetOptimizerScalesFromPhysicalShift()`](https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1ImageRegistrationMethod.html#a53934282121e152d37781ffa5224ec5f) for your registration method.

Again, these are just my first guesses. I don’t know if it fixes the issue.

---

<div class="post-metadata">

### Author: ![elapins](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/96bed5/32.png) [@elapins](https://discourse.itk.org/u/elapins)
#### Post date: [February 17, 2023, 9:10pm UTC](https://discourse.itk.org/t/simpleitk-registration/5709/3 "2023-02-17T21:10:28Z")

</div>

Thank you so much! I had no idea I could post code within the post.

I tried adding the two things you suggested, and again it did not seem to work.
