# How do we set up rotation center for masked rigid registration?

**URL:** <https://discourse.itk.org/t/how-do-we-set-up-rotation-center-for-masked-rigid-registration/480>\
**Category:** Uncategorized\
**Created:** [December 4, 2017, 5:34pm UTC](https://discourse.itk.org/t/how-do-we-set-up-rotation-center-for-masked-rigid-registration/480 "2017-12-04T17:34:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ray](https://discourse.itk.org/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@Ray](https://discourse.itk.org/u/Ray)\
**Post date:** [December 4, 2017, 5:34pm UTC](https://discourse.itk.org/t/how-do-we-set-up-rotation-center-for-masked-rigid-registration/480/1 "2017-12-04T17:34:10Z")

</div>

Hello!

I’m using VersorRigid3DTransform with a mask on the moving image. I would like to set up the center for the rotation.

The CenteredTransformInitializer can call MomentsOn() to automatically get the center of the mass. However, it’s for the entire image, and I want the center of the mask.

Is there any way to do it automatically or manually?

Thanks!  
-Ray

---

<div class="post-metadata">

**Author:** ![tim-evain](https://discourse.itk.org/user_avatar/discourse.itk.org/tim-evain/32/220_2.png) [@tim-evain](https://discourse.itk.org/u/tim-evain)\
**Post date:** [December 4, 2017, 6:07pm UTC](https://discourse.itk.org/t/how-do-we-set-up-rotation-center-for-masked-rigid-registration/480/2 "2017-12-04T18:07:21Z")

</div>

Hello Ray,

Last time I had to do the same, I had to do it manually : I masked my image with [MaskImageFilter](https://itk.org/Doxygen/html/classitk_1_1MaskImageFilter.html) and computed the center of gravity with [ImageMomentCalculator](https://itk.org/Doxygen/html/classitk_1_1ImageMomentsCalculator.html) (or manually) (as the 0 values do not impact the computation).  
Then you can set the center of the transform manually.

HTH,

Tim

---

<div class="post-metadata">

**Author:** ![Ray](https://discourse.itk.org/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@Ray](https://discourse.itk.org/u/Ray)\
**Post date:** [December 4, 2017, 8:50pm UTC](https://discourse.itk.org/t/how-do-we-set-up-rotation-center-for-masked-rigid-registration/480/3 "2017-12-04T20:50:16Z")

</div>

Thanks Tim!

A follow-up question: When we use transform-\>SetCenter(), this center is set up for the moving image or the fixed image? I have a mask for my moving image, so I want the center of that mask to be the rotation center.

Best,

-Ray

---

<div class="post-metadata">

**Author:** ![tim-evain](https://discourse.itk.org/user_avatar/discourse.itk.org/tim-evain/32/220_2.png) [@tim-evain](https://discourse.itk.org/u/tim-evain)\
**Post date:** [December 5, 2017, 10:55am UTC](https://discourse.itk.org/t/how-do-we-set-up-rotation-center-for-masked-rigid-registration/480/4 "2017-12-05T10:55:50Z")

</div>

Hi Ray,

ITK registration is done in “physical” space, images are considered in the same space so the center applies to both.  
You can refer to the Software Guide Registration chapter to fully comprehend the specificities of ITK’s implementation.

HTH,

Tim
