Main Content


Entropy of grayscale image



e = entropy(I) returns the entropy of grayscale image I.


collapse all

Read image into the workspace.

I = imread('circuit.tif');

Calculate the entropy.

J = entropy(I)
J = 6.9439

Input Arguments

collapse all

Grayscale image, specified as a numeric array of any dimension.

Data Types: double | uint8 | uint16 | uint32 | logical

Output Arguments

collapse all

Entropy of image I, returned as a numeric scalar.

Data Types: double

More About

collapse all


Entropy is a statistical measure of randomness that can be used to characterize the texture of the input image.

Entropy is defined as -sum(p.*log2(p)), where p contains the normalized histogram counts returned from imhist.


  • By default, entropy uses two bins for logical arrays and 256 bins for uint8, uint16, or double arrays. entropy converts any class other than logical to uint8 for the histogram count calculation so that the pixel values are discrete and directly correspond to a bin value.


[1] Gonzalez, R. C., R. E. Woods, and S. L. Eddins. Digital Image Processing Using MATLAB. New Jersey, Prentice Hall, 2003, Chapter 11.

Extended Capabilities

Version History

Introduced before R2006a

expand all