# image registration using mutual information

**URL:** https://discourse.itk.org/t/image-registration-using-mutual-information/1746
**Category:** Algorithms
**Created:** [April 4, 2019, 1:39pm UTC](https://discourse.itk.org/t/image-registration-using-mutual-information/1746 "2019-04-04T13:39:31Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![lorystays](https://discourse.itk.org/letter_avatar_proxy/v4/letter/l/5daacb/32.png) [@lorystays](https://discourse.itk.org/u/lorystays)
#### Post date: [April 4, 2019, 1:39pm UTC](https://discourse.itk.org/t/image-registration-using-mutual-information/1746/1 "2019-04-04T13:39:31Z")

</div>

Hi,  
i am trying to do image registration between 2 (natural scene) grayscale images using similarity transform and the mutual information similarity metric.  
I started by trying to repeat the results from the following (ITK Forum) link : [Simple image registration](https://discourse.itk.org/t/simple-image-registration/615/27) running the code of registration example #7 on the 2 bottle images given in the link.  
so far i run the code successfully using the MeanSquares similarity metric.  
however using MattesMutualInformation metric (with the exact same code) i failed to reach good registration results.

following is the algorithm output (after 500 iterations) and the input images as well as the transformed result image.

Matrix:  
0.876671 -0.41851  
0.41851 0.876671  
Offset: [57.864, -18.4414]  
Center: [97.6345, 116.739]  
Translation: [-3.03366, 8.02229]  
Inverse:  
0.92897 0.443476  
-0.443476 0.92897  
Singular: 0  
Angle = 0.445393  
Scale =0.971444

![image](https://discourse.itk.org/uploads/default/original/1X/fbb76aa62c46ab78f08ccde0b29d4a8472db5745.png)  
 ![image](https://discourse.itk.org/uploads/default/original/1X/fe5ba299c029b758da92a81980ef9f0cbcceeebd.png)

 ![image](https://discourse.itk.org/uploads/default/original/1X/76917db05977bef7e63bbfb0d3777e760f9f1641.png)

will appreciate your help with this issue.  
Thanks, Omer 🙂 .

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [April 4, 2019, 2:10pm UTC](https://discourse.itk.org/t/image-registration-using-mutual-information/1746/2 "2019-04-04T14:10:38Z")

</div>

Welcome to the community Omer!

Mutual Information is designed for multi-modality registration, such as CT-MRI or visible light-infrared etc. It is less good for registering images of the same modality. But if you insist on using it, try increasing [the number of histogram bins](https://itk.org/Doxygen/html/classitk_1_1MattesMutualInformationImageToImageMetric.html#ab54745141e07f416a48c5da8100186ae).

---

<div class="post-metadata">

### Author: ![lorystays](https://discourse.itk.org/letter_avatar_proxy/v4/letter/l/5daacb/32.png) [@lorystays](https://discourse.itk.org/u/lorystays)
#### Post date: [April 7, 2019, 7:54am UTC](https://discourse.itk.org/t/image-registration-using-mutual-information/1746/3 "2019-04-07T07:54:35Z")

</div>

Hi Dženan,  
Thanks for the quick answer 🙂  
we touched upon the bottles example just as a way to familiarise ourselves with ITK registration methods.  
our original problem is trying to register 2 medical images (from 2 cameras with different optical settings and image quality) using ITK.  
We have successfully accomplished this using MATLAB (using similarity and mutual information) but are having a hard time emulating the results using ITK.  
We tried to follow the code of [https://github.com/InsightSoftwareConsortium/ITK/blob/master/Examples/RegistrationITKv4/ImageRegistration4.cxx](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Examples/RegistrationITKv4/ImageRegistration4.cxx) with minor modifications  
(mainly replacing the translation transform by similarity), and obtained poor results.  
We would appriciate any help and would be happy to provide the 2 images either by mail or directly here.  
again thanks, Omer

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [April 8, 2019, 3:23pm UTC](https://discourse.itk.org/t/image-registration-using-mutual-information/1746/4 "2019-04-08T15:23:29Z")

</div>

If you provide your images here, more people will have a chance to help you.

---

<div class="post-metadata">

### Author: ![lorystays](https://discourse.itk.org/letter_avatar_proxy/v4/letter/l/5daacb/32.png) [@lorystays](https://discourse.itk.org/u/lorystays)
#### Post date: [April 10, 2019, 7:34am UTC](https://discourse.itk.org/t/image-registration-using-mutual-information/1746/5 "2019-04-10T07:34:29Z")

</div>

Thanks,  
attached are my input images and the Matlab derived similarity transform (using mutual information). also adding the transformed images using Matlab’s imwarp function.  
we would like to obtain similar result using ITK with the same settings (similarity transform and mutual information) , any help would be appreciated.  
Thanks, Omer 🙂

resulting similarity transform using Matlab was:  
0.7120 0.1054 0  
-0.1054 0.7120 0  
40.1383 10.0875 1.0000

scale = 0.7198  
angle = 8.4221

input moving image:  
[endGray.bmp](https://discourse.itk.org/uploads/default/original/1X/1c08861a306c57cafe776f77e89b879342259eed.bmp) (26.1 KB)

input fixed image:  
[colGray.bmp](https://discourse.itk.org/uploads/default/original/1X/5d41b9d95ec88bb1d3835119a833e8ac5d0db6d2.bmp) (26.1 KB)

---

<div class="post-metadata">

### Author: ![lorystays](https://discourse.itk.org/letter_avatar_proxy/v4/letter/l/5daacb/32.png) [@lorystays](https://discourse.itk.org/u/lorystays)
#### Post date: [April 10, 2019, 7:35am UTC](https://discourse.itk.org/t/image-registration-using-mutual-information/1746/6 "2019-04-10T07:35:14Z")

</div>

also adding the transformed image (using Matalb’s imwarp):  
[res.bmp](https://discourse.itk.org/uploads/default/original/1X/2ebd53b4f746f968a054a7f5b0fe26b4ff8fa7e9.bmp) (723.6 KB)

---

<div class="post-metadata">

### Author: ![maiada](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/7ea924/32.png) [@maiada](https://discourse.itk.org/u/maiada)
#### Post date: [September 29, 2019, 12:52pm UTC](https://discourse.itk.org/t/image-registration-using-mutual-information/1746/7 "2019-09-29T12:52:05Z")

</div>

have you figure it out ? , cause i’m having a similar problem
