Description
I have not been able to successfully alter the translation-based python registration example to use rigid-2d-based translation (adding just a rotation angle).
Steps to Reproduce
- Verify the unmodified demo works, using the downloaded images from that page.
Command:
python reg.py BrainProtonDensitySliceBorder20.png BrainProtonDensitySliceShifted13x17y.png output.png diff_after.png diff_before.png
- Apply the following patch, which alters the transform type and handles the extra parameter.
$ diff reg.py reg_2drigid.py
30c30
< TransformType = itk.TranslationTransform[itk.D, Dimension]
---
> TransformType = itk.Rigid2DTransform[itk.D]
53a54
> initialParameters[2] = 0
69,70c70,72
< translationAlongX = finalParameters.GetElement(0)
< translationAlongY = finalParameters.GetElement(1)
---
> rigid0 = finalParameters.GetElement(0)
> rigid1 = finalParameters.GetElement(1)
> rigid2 = finalParameters.GetElement(2)
77,78c79,81
< print(" Translation X = " + str(translationAlongX))
< print(" Translation Y = " + str(translationAlongY))
---
> print(" Rigid 0 = " + str(rigid0))
> print(" Rigid 1 = " + str(rigid1))
> print(" Rigid 2 = " + str(rigid2))
Expected behavior
The modified code should give the same results for X & Y translation, and give a result consistent with zero rotation angle.
The original code gives:
Result =
Translation X = 13.00123653240422
Translation Y = 16.999943471681494
Iterations = 22
Metric value = 0.0006793961893802234
Actual behavior
The code seems to get zero metric and error out immediately.
Result =
Rigid 0 = -3.9967219658711683
Rigid 1 = 0.11854330443492171
Rigid 2 = 0.1102769808099171
Iterations = 2
Metric value = 0.0
Reproducibility
100%
Versions
5.1.2
Environment
Ubuntu 20.04
python 3.8.12