skimage2.metrics.normalized_mutual_information#

skimage2.metrics.normalized_mutual_information(image0, image1, *, bins=100)[source]#

Compute the normalized mutual information (NMI).

The normalized mutual information of \(A\) and \(B\) is given by:

\[Y(A, B) = \frac{H(A) + H(B)}{H(A, B)}\]

where \(H(X) := - \sum_{x \in X}{p(x) \log p(x)}\) is the entropy, \(X\) is the set of image values, and \(p(x)\) is the probability of occurrence of value \(x \in X\).

It was proposed to be useful in registering images by Colin Studholme and colleagues [1]. It ranges from 1 (perfectly uncorrelated image values) to 2 (perfectly correlated image values, whether positively or negatively).

Parameters:
image0, image1ndarray

Images to be compared. The two input images must have the same number of dimensions.

binsint or sequence of int, optional

The number of bins along each axis of the joint histogram.

Returns:
nmifloat

The normalized mutual information between the two arrays, computed at the granularity given by bins. Higher NMI implies more similar input images.

Raises:
ValueError

If the images don’t have the same number of dimensions.

Notes

If the two input images are not the same shape, the smaller image is padded with zeros.

References

[1]

C. Studholme, D.L.G. Hill, & D.J. Hawkes (1999). An overlap invariant entropy measure of 3D medical image alignment. Pattern Recognition 32(1):71-86 DOI:10.1016/S0031-3203(98)00091-0