# Implementation of a Custom ImageToImage Similarity Metric for Registration

**URL:** <https://discourse.itk.org/t/implementation-of-a-custom-imagetoimage-similarity-metric-for-registration/6047>\
**Category:** Beginner Questions\
**Tags:** itk, registration\
**Created:** [July 7, 2023, 12:13pm UTC](https://discourse.itk.org/t/implementation-of-a-custom-imagetoimage-similarity-metric-for-registration/6047 "2023-07-07T12:13:32Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![JRopers](https://discourse.itk.org/letter_avatar_proxy/v4/letter/j/77aa72/32.png) [@JRopers](https://discourse.itk.org/u/JRopers)\
**Post date:** [July 8, 2023, 3:49pm UTC](https://discourse.itk.org/t/implementation-of-a-custom-imagetoimage-similarity-metric-for-registration/6047/5 "2023-07-08T15:49:57Z")

</div>

Okay so the other problem with this is that I am trying to stack metrics using ObjectToObjectMultiMetricv4. Therefore the MatchCardinalityImageToImageMetric is not compatible. Maybe it helps explaining my overall idea.

I have the moving and fixed CT image. In addition to that, I have binary segmentation masks of various anatomies such as the lung for each image. I would like the registration to basically focus on both MSE between the two CTs, but also at the same time on the DICE metric between the masks I am passing and potentially even multiple masks of different anatomies, for which each DICE metric is weighted differently.  
I thought that if I successfully implement a DICE metric by inheriting from ImageToImageMetricv4, that I could stack and weight the different inputs, and their corresponding similarity metrics and weights, kind of like you explained [here](https://discourse.itk.org/t/similarity-measure/4680/8). Is my logic off? Is there no MatchCardinalityImageToImageMetricv4? If not, are there any resources on implementing your own metric in the v4 registration?

---

_[View the full topic](https://discourse.itk.org/t/implementation-of-a-custom-imagetoimage-similarity-metric-for-registration/6047)._
