Main Content

Calculate Statistical Measures of Texture

The toolbox includes several texture analysis functions that filter an image using standard statistical measures. These statistics can characterize the texture of an image because they provide information about the local variability of the intensity values of pixels in an image. For example, in areas with smooth texture, the range of values in the neighborhood around a pixel is a small value; in areas of rough texture, the range is larger. Similarly, calculating the standard deviation of pixels in a neighborhood can indicate the degree of variability of pixel values in that region. The table lists these functions.

rangefiltCalculates the local range of pixel intensities of an image.
stdfiltCalculates the local standard deviation of an image.
entropyfiltCalculates the local entropy of a grayscale image. Entropy is a statistical measure of randomness.

The functions all operate in a similar way: they define a neighborhood around the pixel of interest, calculate the statistic for that neighborhood, and use that value as the value of the pixel of interest in the output image.

This example shows how the rangefilt function operates on a simple array.

A = [ 1 2 3 4 5; 6 7 8 9 10; 11 12 13 14 15; 16 17 18 19 20 ]
A =

     1     2     3     4     5
     6     7     8     9    10
    11    12    13    14    15
    16    17    18    19    20
B = rangefilt(A)
B =

     6     7     7     7     6
    11    12    12    12    11
    11    12    12    12    11
     6     7     7     7     6

The following figure shows how the value of element B(2,4) was calculated from A(2,4). By default, the rangefilt function uses a 3-by-3 neighborhood but you can specify neighborhoods of different shapes and sizes.

Determining Pixel Values in Range Filtered Output Image

In the input image, the 3-by-3 pixel neighborhood surrounding pixel (2,4) has a maximum value of 15 and a minimum value of 9. In the output image, the value of the pixel (2,4) is the difference between 15 and 9, which is 12.

The stdfilt and entropyfilt functions operate similarly, defining a neighborhood around the pixel of interest and calculating the statistic for the neighborhood to determine the pixel value in the output image. The stdfilt function calculates the standard deviation of all the values in the neighborhood.

The entropyfilt function calculates the entropy of the neighborhood and assigns that value to the output pixel. By default, the entropyfilt function defines a 9-by-9 neighborhood around the pixel of interest. To calculate the entropy of an entire image, use the entropy function.

See Also

| |

Related Topics