skimage2.measure.shannon_entropy#

skimage2.measure.shannon_entropy(image, base=2)[source]#

Calculate the Shannon entropy of an image.

The Shannon entropy is defined as S = -sum(pk * log(pk)), where pk are frequency/probability of pixels of value k.

Parameters:
imagendarray of shape (M, N)

Grayscale input image.

basefloat, optional

The logarithmic base to use.

Returns:
entropyfloat

Notes

The returned value is measured in bits or shannon (Sh) for base=2, natural unit (nat) for base=np.e and hartley (Hart) for base=10.

References

Examples

>>> from _skimage2 import data
>>> from _skimage2.measure import shannon_entropy
>>> shannon_entropy(data.camera())
7.231695011055706