# 2D affine registration metric/performance

**URL:** <https://discourse.itk.org/t/2d-affine-registration-metric-performance/5967>\
**Category:** Uncategorized\
**Created:** [May 26, 2023, 6:02pm UTC](https://discourse.itk.org/t/2d-affine-registration-metric-performance/5967 "2023-05-26T18:02:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![banikr](https://discourse.itk.org/user_avatar/discourse.itk.org/banikr/32/3296_2.png) [@banikr](https://discourse.itk.org/u/banikr)\
**Post date:** [May 26, 2023, 6:02pm UTC](https://discourse.itk.org/t/2d-affine-registration-metric-performance/5967/1 "2023-05-26T18:02:06Z")

</div>

Fixed image:  
 ![image](https://discourse.itk.org/uploads/default/original/2X/2/29cb1d526a38e7774e9aafc07b52278f37d72b04.png)  
Moving image:  
 ![image](https://discourse.itk.org/uploads/default/original/2X/4/430ed587f47496791204b5c7fe8647ebf62d6799.png)  
the images come from different modalities and do not have labels/annotations. Though visually the center elliptical anatomy overlap, is there a way I can come up with a metric that only considers the center elliptical match/overlap performance?

I head about mutual histogram matching or mutual info. optimization but dont know how to implement that with ITK platform.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)\
**Post date:** [May 26, 2023, 9:10pm UTC](https://discourse.itk.org/t/2d-affine-registration-metric-performance/5967/2 "2023-05-26T21:10:47Z")

</div>

Hello @banikr,

If you have a region of interest and you want to use that in the registration you will need to explicitly create a mask representing it. Given this mask, the registration will only use voxels/pixels that are inside it for computing similarity.

---

<div class="post-metadata">

**Author:** ![banikr](https://discourse.itk.org/user_avatar/discourse.itk.org/banikr/32/3296_2.png) [@banikr](https://discourse.itk.org/u/banikr)\
**Post date:** [May 28, 2023, 3:07pm UTC](https://discourse.itk.org/t/2d-affine-registration-metric-performance/5967/3 "2023-05-28T15:07:14Z")

</div>

Thanks  
Even if I create an ellipsoid mask based on fixed image, how do I incorporate it in the codes? And how do I work with the metrics analysis?

---

<div class="post-metadata">

**Author:** ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)\
**Post date:** [May 28, 2023, 6:33pm UTC](https://discourse.itk.org/t/2d-affine-registration-metric-performance/5967/4 "2023-05-28T18:33:02Z")

</div>

Hello @banikr,

The `ImageRegistrationMethod` has [SetMetricFixedMask](https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1ImageRegistrationMethod.html#a1e39b4a959a08c85ef65ab7bc5fe25a7) and [SetMetricMovingMask](https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1ImageRegistrationMethod.html#a3d4bcd5443c7bf8b5fe18f4fcd23ca63) methods. Use those to set the mask(s) and then work with the `ImageRegistrtaionMethod` as usual, using the `MetricEvaluate` or `SetOptimizerAsExhaustive` to compute the metric values, see [this notebook](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/Python/63_Registration_Initialization.ipynb) for code.
