Mryka Hall-Beyer

Tutorial: GLCM Texture


What is texture?  Texture Calculations  Practical Notes   More Information and References

 Exercises   Examples   Equations


The Grey Level Co-occurrence Matrix, GLCM (also called the Grey Tone Spatial Dependency Matrix)

Definition: The GLCM is a tabulation of how often different combinations of pixel brightness values (grey levels) occur in an image.

The test image:

Here is a simple "test image" for working out examples. The values are image grey levels (GLs). It will be used throughout this tutorial.




0 0 1 1
0 0 1 1
0 2 2 2
2 2 3 3

Definition: Order:

The GLCM described here is used for a series of "second order" texture calculations.

First order texture measures are statistics calculated from the original image values, like variance, and do not consider pixel neighbour relationships.

Second order measures consider the relationship between groups of two (usually neighbouring) pixels in the original image.

Third and higher order textures (considering the relationships among three or more pixels) are theoretically possible but not commonly implemented due to calculation time and interpretation difficulty. There has been some recent development of a more efficient way to calculate third-order textures: see Akono et al. 2003.

Framework for the GLCM:

Spatial relationship between two pixels:

GLCM texture considers the relation between two pixels at a time, called the reference and the neighbour pixel. In the illustration below, the neighbour pixel is chosen to be the one to the east (right) of each reference pixel. This can also be expressed as a (1,0) relation: 1 pixel in the x direction, 0 pixels in the y direction.

Each pixel within the window becomes the reference pixel in turn, starting in the upper left corner and proceeding to the lower right. Pixels along the right edge have no right hand neighbour, so they are not used for this count.

To see images of the effect of different spatial relationships, click here.

Separation between two pixels:

All the examples in this tutorial use 1 pixel offset (a reference pixel and its immediate neighbour). If the window is large enough, using a larger offset is perfectly possible. There is no difference in calculation method. The sum of all the entries in the GLCM (i.e. the number of pixel combinations) will just be smaller for a given window size.

Combinations of the grey levels that are possible for the test image, and their position in the matrix.

This is the only time that the labels in the top row and left column will be shown. All further representations of the GLCM include only the 16 data cells.

neighbour pixel value ->

ref pixel value:

0 1 2 3
0 0,0 0,1 0,2 0,3
1 1,0 1,1 1,2 1,3
2 2,0 2,1 2,2 2,3
3 3,0 3,1 3,2 3,3

How to read the matrix framework:

The top left cell will be filled with the number of times the combination 0,0 occurs, i.e. how many times within the image area a pixel with grey level 0 (neighbour pixel) falls to the right of another pixel with grey level 0 (reference pixel).

A different co-occurrence matrix exists for each spatial relationship (above, next to, diagonal). More information: click here.

Example: Fill in the matrix framework for the east (1,0) spatial relationship:

2 2 1 0
0 2 0 0
0 0 3 1
0 0 0 1

How to read the east matrix:

Twice in the test image the reference pixel is 0 and its eastern neighbour is also 0. Twice the reference pixel is 0 and its eastern neighbour is 1. Three times the reference pixel is 2 and its neighbour is also 2.