Fast MATLAB function to calculate the mutual information of two images. Designed specifically for speed and to emulate functionality of MATLAB native entropy
function. For details on usage, see function docstring or execute help mutualInfo
.
Based on the mi
function created by J. Delpiano.
Requirements and compatibility:
- Developed and tested in MATLAB 2023a.
- At least 2021a is required for the name=value syntax function arguments. Replace these with comma-separated syntax (lines 39-43) if you are using a version older than 2021a.
- At least 2015b is required for the
histcounts
andhistcounts2
functions. - Requires the
im2uint8
function from the Image Processing Toolbox (lines 30-31.) If this toolbox is not available to you, replace those lines with code that will scale the gray-levels of your image to values in the range of 0 to 255, then cast the images touint8
.
The mutual information
Where
The information entropy
Where
The joint entropy of two images
And the conditional entropy accordingly by [2]:
The mutual information of the images can then be expressed in terms of entropy by [2]:
The mutual information of an image with itself is then [2]:
Therefore, the mutual information of an image with itself is equal to its entropy. For a given image A
in MATLAB, mutualInfo(A, A)
will yield a numerical result that is close to but not exactly identical to the result of entropy(A)
due to floating point error.
[1] F. Maes, D. Loeckx, D. Vandermeulen, and P. Suetens, “Image registration using mutual information,” in Handbook of Biomedical Imaging: Methodologies and Clinical Research, N. Paragios, J. Duncan, and N. Ayache, Eds., Boston, MA: Springer US, 2015, pp. 295–308. doi: 10.1007/978-0-387-09749-7_16.
[2] T. M. Cover and J. A. Thomas, “Entropy, Relative Entropy, and Mutual Information,” in Elements of Information Theory, 2nd ed.Hoboken, NJ: Wiley-Interscience, 2006, pp. 13–55.