# The Similarity Measure

**URL:** https://discourse.itk.org/t/the-similarity-measure/3399
**Category:** Beginner Questions
**Tags:** registration, python, simpleitk
**Created:** [August 19, 2020, 2:44am UTC](https://discourse.itk.org/t/the-similarity-measure/3399 "2020-08-19T02:44:06Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![TJH123456](https://discourse.itk.org/user_avatar/discourse.itk.org/tjh123456/32/1654_2.png) [@TJH123456](https://discourse.itk.org/u/TJH123456)
#### Post date: [August 19, 2020, 2:44am UTC](https://discourse.itk.org/t/the-similarity-measure/3399/1 "2020-08-19T02:44:06Z")

</div>

Hello

I have a question. In the similarity measure, there is a “jointhistogrammutualinformation”. I want to know whether this is to calculate the mutual information value, rather than calculate the derived value of mutual information (such as mattes mutual information value, maximum mutual information value, etc.)?Any help would be appreciated.

---

<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: [August 20, 2020, 12:51am UTC](https://discourse.itk.org/t/the-similarity-measure/3399/2 "2020-08-20T00:51:50Z")

</div>

Hello @TJH123456,

This class computes the mutual information using the method described in P. Thevenaz and M. Unser, “Optimization of Mutual Information for MultiResolution Image Registration” IEEE Transactions on Image Processing, 9(12), 2000.

---

<div class="post-metadata">

### Author: ![TJH123456](https://discourse.itk.org/user_avatar/discourse.itk.org/tjh123456/32/1654_2.png) [@TJH123456](https://discourse.itk.org/u/TJH123456)
#### Post date: [August 24, 2020, 11:06am UTC](https://discourse.itk.org/t/the-similarity-measure/3399/3 "2020-08-24T11:06:50Z")

</div>

Thank you for your answer.  
I have a doubt about this “jointhistogrammutualinformation”, because when I use it to calculate two identical graphs, the result is -0.8, but I think it should be -1. Do you know the reason?

---

<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: [August 24, 2020, 1:02pm UTC](https://discourse.itk.org/t/the-similarity-measure/3399/4 "2020-08-24T13:02:09Z")

</div>

Hello @TJH123456,

Mutual Information is in the range [0, +inf). In ITK/SimpleITK we negate it because our optimizers are set to minimize. Various normalized mutual information versions have been developed, but they are not implemented in SimpleITK.

---

<div class="post-metadata">

### Author: ![TJH123456](https://discourse.itk.org/user_avatar/discourse.itk.org/tjh123456/32/1654_2.png) [@TJH123456](https://discourse.itk.org/u/TJH123456)
#### Post date: [August 24, 2020, 1:50pm UTC](https://discourse.itk.org/t/the-similarity-measure/3399/5 "2020-08-24T13:50:58Z")

</div>

Yes, I understand that mutual information is greater than or equal to 0, and in simpleitk, to negate it means that the smaller the value, the better. I read the paper you introduced. There is a normalization factor in it, so I think the index is normalized, but these works still can’t solve my problem - the value of two identical images is - 0.8, not - 1. Do you have any opinion on this? Thank you in advance.

---

<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: [August 24, 2020, 2:47pm UTC](https://discourse.itk.org/t/the-similarity-measure/3399/6 "2020-08-24T14:47:36Z")

</div>

The [SetMetricAsJointHistogramMutualInformation](https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1ImageRegistrationMethod.html#a27dee297880d3dde2d84d51580f60909)  
is **not** computing Normalized Mutual Information, it’s just Mutual Information so can be any value in [0,-inf), there is no reason that it be -1 even when the images are aligned.

---

<div class="post-metadata">

### Author: ![TJH123456](https://discourse.itk.org/user_avatar/discourse.itk.org/tjh123456/32/1654_2.png) [@TJH123456](https://discourse.itk.org/u/TJH123456)
#### Post date: [August 24, 2020, 3:11pm UTC](https://discourse.itk.org/t/the-similarity-measure/3399/7 "2020-08-24T15:11:19Z")

</div>

I get it. Since he is not normalized, it means that even two identical graphs will not be equal to 1. By the way, I wonder if you have a formula for mattes mutual information. I didn’t find it online. If you have it, I hope you can provide it. If you don’t have it, it doesn’t matter. Thank you for your help.

---

<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: [August 24, 2020, 3:32pm UTC](https://discourse.itk.org/t/the-similarity-measure/3399/8 "2020-08-24T15:32:02Z")

</div>

For details, please see [this presentation](https://courses.cs.washington.edu/courses/cse577/11au/notes/Z5-Mutual-Information.pdf).

---

<div class="post-metadata">

### Author: ![TJH123456](https://discourse.itk.org/user_avatar/discourse.itk.org/tjh123456/32/1654_2.png) [@TJH123456](https://discourse.itk.org/u/TJH123456)
#### Post date: [August 24, 2020, 4:01pm UTC](https://discourse.itk.org/t/the-similarity-measure/3399/9 "2020-08-24T16:01:06Z")

</div>

Is this mattes mutual information formula? It looks very similar to the formula of “JointHistogramMutualInformation”.By the way, is there only a negative sign difference between mutual information and mattes mutual information?  
 ![image](https://discourse.itk.org/uploads/default/original/2X/c/c7516143c85e38dd2d049c8b7f629a1207a87fb0.png)

---

<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: [August 24, 2020, 4:12pm UTC](https://discourse.itk.org/t/the-similarity-measure/3399/10 "2020-08-24T16:12:48Z")

</div>

The differences are not in the formula, they are in the implementation. Options for estimating the probability density function, Parzen windowing (Mattes) vs. JointHistogram (Histogram).

If you are interested in the theory underlying the algorithms in ITK/SimpleITK you will have to study on your own or take a course on medical image analysis.

This forum is not the venue for learning the theory behind the algorithms, it is intended to help you use the toolkits.

---

<div class="post-metadata">

### Author: ![TJH123456](https://discourse.itk.org/user_avatar/discourse.itk.org/tjh123456/32/1654_2.png) [@TJH123456](https://discourse.itk.org/u/TJH123456)
#### Post date: [August 24, 2020, 4:18pm UTC](https://discourse.itk.org/t/the-similarity-measure/3399/11 "2020-08-24T16:18:30Z")

</div>

Thank you for your answer, and I’m sorry to ask some basic questions here. I will pay attention to this behavior in the future.
