This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Local entropy of grayscale image


J = entropyfilt(I)
J = entropyfilt(I,nhood)



J = entropyfilt(I) returns the array J, where each output pixel contains the entropy value of the 9-by-9 neighborhood around the corresponding pixel in the input image I.

For pixels on the borders of I, entropyfilt uses symmetric padding. In symmetric padding, the values of padding pixels are a mirror reflection of the border pixels in I.

J = entropyfilt(I,nhood) performs entropy filtering of the input image I where you specify the neighborhood in nhood. nhood is a multidimensional array of zeros and ones where the nonzero elements specify the neighbors.


collapse all

This example shows how to perform entropy filtering using entropyfilt. Brighter pixels in the filtered image correspond to neighborhoods in the original image with higher entropy.

Read an image into the workspace.

I = imread('circuit.tif');

Perform entropy filtering using entropyfilt.

J = entropyfilt(I);

Show the original image and the processed image.

title('Original Image')

title('Result of Entropy Filtering')

Input Arguments

collapse all

Image to be filtered, specified as a real, nonsparse numeric array. I can have any dimension. If I has more than two dimensions, entropyfilt treats it as a multidimensional grayscale image and not as a truecolor (RGB) image.

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

Neighborhood, specified as a multidimensional, logical or numeric array containing zeros and ones. The size of nhood must be odd in each dimension.

By default, entropyfilt uses the neighborhood true(9). entropyfilt determines the center element of the neighborhood by floor((size(NHOOD) + 1)/2).

To specify neighborhoods of other shapes, such as a disk, use the strel function to create a structuring element object of the desired shape. Then, extract the neighborhood from the structuring element object’s neighborhood property.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Output Arguments

collapse all

Filtered image, returned as a numeric array the same size as the input image and of class double.


entropyfilt 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, S.L. Eddins, Digital Image Processing Using MATLAB, New Jersey, Prentice Hall, 2003, Chapter 11.

Introduced before R2006a