This matlab tutorial shows how you can calculate the entropy of any Picture in
Matlab. Entropy of a source gives indication of how much the image can
be compressed and other information. Since the probability distribution
of image pixel intensity not known a priori this becomes a problem. Here
it is shown how you can get this information in Matlab.

Consider this image of a football player,

First this image is loaded into the program, that is matlab. Then if the image is in 3D array which can be checked by size function it is converted into 2D array. Then its height and weight is calculated using the size function. The imhist function is used to calculate the number of counts and the histogram bin number. The count number is then used to calculate the source probability which is then subsequently used to calculate the entropy. A probability of occurrence vs the bin is also plotted.

The image entropy was calculated to be 7.7 bpp.

Entropy of Image is = 7.7236

The result probability distribution graph is shown below,

Consider this image of a football player,

First this image is loaded into the program, that is matlab. Then if the image is in 3D array which can be checked by size function it is converted into 2D array. Then its height and weight is calculated using the size function. The imhist function is used to calculate the number of counts and the histogram bin number. The count number is then used to calculate the source probability which is then subsequently used to calculate the entropy. A probability of occurrence vs the bin is also plotted.

clear all clc x = imread('image.jpg'); x = reshape(x,[],3); [h,w] = size(x); [p,bin] = imhist(x); p = p/(h*w); H = sum(-p.*log2(p+1e-08)); sprintf('Entropy of Image is = %g',H) figure, plot(bin,p,'k') xlabel('Pixel value'), ylabel('relative count')

The image entropy was calculated to be 7.7 bpp.

Entropy of Image is = 7.7236

The result probability distribution graph is shown below,

## No Comment to " How to determine Entropy of any Picture in Matlab "