Skip to content

Statistical Texture Analysis

Texture can be described not only by frequency and orientation, but also by the statistical relationships among nearby gray levels. Statistical texture analysis asks which gray values tend to occur together, how different neighboring values are, and how local patterns repeat across an image.

The Gabor page asks, “Which local directions and spatial frequencies are present?” This page asks a different question: “How are gray levels spatially related?”

1. Why a Gray-Level Histogram Is Not Enough

A histogram records how often each gray level occurs, but it does not record where those gray levels occur. Therefore, two image regions can have the same histogram while having very different textures.

Same Gray-Level Counts, Different Spatial Arrangement

Block Pattern

0
0
3
3
0
0
3
3
0
0
3
3
0
0
3
3

Large regions contain similar neighboring values.

Checkerboard Pattern

0
3
0
3
3
0
3
0
0
3
0
3
3
0
3
0

Neighboring values alternate rapidly even though the gray-level counts are unchanged.

Level 0
8
Level 3
8
A histogram answers “Which gray levels are present?” Statistical texture methods add information about spatial relationships among those gray levels.

2. Pixel Pairs, Distance, and Direction

One of the simplest ways to describe spatial texture is to examine pairs of pixels separated by a chosen displacement.

\[ \Delta=(\Delta x,\Delta y). \]

The displacement determines both the distance and direction of the relationship being measured.

One Reference Pixel and One Displaced Neighbor
1
1
2
2
3
1
1
2
3
3
0
1
3
3
2
0
1
2
2
2
0
0
1
2
3
Orange is the reference pixel and blue is the displaced neighbor. In this example the pair is \((1,3)\): the first pixel has gray level 1 and the second has gray level 3.
→
Horizontal
\((d,0)\)
↘
Down-Right
one diagonal direction
↓
Vertical
\((0,d)\)
↙
Down-Left
the opposite diagonal
Image-processing angle conventions can differ because image row coordinates increase downward. On this page, the interactive tool names directions explicitly and also displays the actual row/column offset, so the relationship is unambiguous.

3. Spatial Gray-Level Dependence Matrix (SGLDM)

The spatial gray-level dependence matrix records how often one gray level occurs at the selected displacement from another gray level. It is closely related to what is commonly called a gray-level co-occurrence matrix.

Let the possible gray levels be \(Q=\{0,1,\ldots,L-1\}\). For a selected distance \(d\) and direction \(\theta\), define the count matrix

\[ C(i,j;d,\theta) = \#\{\text{valid pixel pairs with values }(i,j)\}. \]

Row \(i\) represents the gray level of the reference pixel, and column \(j\) represents the gray level of its displaced neighbor.

Example Count Matrix for Four Gray Levels
\(i\backslash j\) 0123
00000
10500
20040
30000

Here all nine observed pairs contain equal gray levels, so the nonzero counts lie on the main diagonal.

Entries near \(i=j\) describe pairs with similar gray levels. Entries farther from the main diagonal describe larger gray-level changes between the two selected locations.

4. Building an SGLDM Step by Step

The matrix is easiest to understand as a counting procedure. Choose one valid pair, read its two gray levels, and increment the corresponding matrix entry.

Choose \(d\) and direction \(\theta\)
↓
Find every valid pixel pair with that displacement
↓
Read the pair values \((i,j)\)
↓
Increment \(C(i,j;d,\theta)\)
↓
Repeat until every valid pair has been counted
\[ (i,j)=(1,3) \quad\Longrightarrow\quad C(1,3)\leftarrow C(1,3)+1. \]
The interactive visualizer later on the page exposes this exact process: each step highlights one image pair and the matrix cell that receives the next count.

5. From Counts to a Normalized SGLDM

Raw counts depend on how many valid pairs are available. To compare matrices or compute probability-based features, divide each entry by the total number of counted pairs.

\[ P(i,j;d,\theta) = \frac{C(i,j;d,\theta)} {\displaystyle\sum_a\sum_b C(a,b;d,\theta)}. \]

The normalized entries satisfy

\[ \sum_i\sum_j P(i,j;d,\theta)=1. \]
On this page, \(C(i,j;d,\theta)\) denotes the raw pair-count matrix and \(P(i,j;d,\theta)\) denotes its normalized probability matrix. Keeping count and probability notation separate makes it easier to see which quantities are being measured and which are being used to compute features.

Count Matrix

How many times did the pair occur?

Normalized Matrix

What fraction of all valid pairs had that value combination?

6. Energy from the SGLDM

One texture feature built from the normalized SGLDM is energy:

\[ E(d,\theta) = \sum_i\sum_j \left[P(i,j;d,\theta)\right]^2. \]
More Concentrated

Higher Energy

If probability is concentrated in relatively few SGLDM cells, squaring the entries produces a larger total.

More Distributed

Lower Energy

If probability is spread over many matrix cells, the squared entries are generally smaller and the total energy decreases.

Energy measures concentration of co-occurrence probability. Its interpretation should be tied to the selected distance, direction, and image content rather than treated as a universal “smoothness score.”

7. SGLDM Entropy — Same Entropy Idea, Different Distribution

Entropy can also summarize how spread out the normalized SGLDM is. Using base-2 logarithms for consistency with the morphological entropy page,

\[ H_{\mathrm{SGLDM}}(d,\theta) = -\sum_i\sum_j P(i,j;d,\theta) \log_2 P(i,j;d,\theta). \]

Terms with \(P(i,j;d,\theta)=0\) contribute zero.

Concentrated Pair Probability

Lower SGLDM Entropy

If most probability is concentrated in a small number of gray-level pair combinations, the pair distribution is more predictable and its entropy tends to be lower.

Spread Pair Probability

Higher SGLDM Entropy

If probability is distributed across many different gray-level pair combinations, the pair distribution is more varied and its entropy tends to be higher.

Is This the Same as Morphological Entropy?

Morphological Entropy

\[ H_{\mathrm{morph}}(X|B) = -\sum_r f(r)\log_2 f(r) \]

The distribution is the pattern spectrum across morphological scales. It describes how an object’s area is distributed across scales of opening.

SGLDM Entropy

\[ H_{\mathrm{SGLDM}} = -\sum_i\sum_j P(i,j)\log_2 P(i,j) \]

The distribution is the gray-level pair probability for a chosen displacement. It describes how varied the pair relationships are in a texture.

The two features use the same Shannon-entropy operation, but they apply it to different distributions. Morphological entropy measures spread across scale; SGLDM entropy measures spread across gray-level pairs. They are related mathematically, but they are not duplicate descriptors.

8. Gray-Level Difference Method (GLDM)

The SGLDM keeps the ordered pair \((i,j)\). The gray-level difference method compresses each pair to the magnitude of its gray-level difference:

\[ k=|i-j|. \]

For four gray levels \(Q=\{0,1,2,3\}\), the possible differences are

\[ k\in\{0,1,2,3\}. \]
Difference Distribution

The GLDM groups pixel pairs by the absolute difference \(k=|i-j|\), rather than keeping the full ordered pair \((i,j)\).

\(k=0\)
Equal gray levels Both pixels have the same gray value.
\(k=1\)
Difference of 1 The pair differs by one gray-level step.
\(k=2\)
Difference of 2 The pair differs by two gray-level steps.
\(k=3\)
Difference of 3 This is the largest possible difference for \(Q=\{0,1,2,3\}\).
For \(Q=\{0,1,2,3\}\), every valid pixel pair contributes to exactly one of the four difference categories \(k=0,1,2,3\).

If \(N_k\) is the number of valid pairs whose absolute difference equals \(k\), then the normalized GLDM probability is

\[ p_{\Delta}(k) = \frac{N_k}{\displaystyle\sum_r N_r}. \]
SGLDM asks “Which pair \((i,j)\) occurred?” GLDM asks “How large was the difference between the two values?”

9. Contrast from the GLDM

The GLDM can be summarized by a contrast feature that weights large gray-level differences more heavily:

\[ \operatorname{CON}(\Delta) = \sum_k k^2 p_{\Delta}(k). \]
Difference 0

Weight \(0^2=0\)

Equal neighboring values contribute nothing to contrast.

Difference 1

Weight \(1^2=1\)

Small gray-level changes contribute modestly.

Difference 3

Weight \(3^2=9\)

Large gray-level changes receive much greater weight.

Contrast is sensitive to how strongly neighboring gray levels differ at the selected displacement. Because the difference is squared, large differences dominate the feature.

10. Why Direction and Distance Matter

Texture can be directional. A pattern that looks highly regular along one direction may look very different along another. SGLDM and GLDM therefore depend on the displacement used to select pixel pairs.

\[ \Delta=(\Delta r,\Delta c) \]

Here \(\Delta r\) is the change in image row and \(\Delta c\) is the change in image column. The same idea is often described by a distance \(d\) and a direction \(\theta\). Using a discrete offset makes it especially clear which pixels are actually paired.

Direction Changes Which Pairs Are Counted
The diagrams below are static comparisons. The reference pixel \(A\) stays in the same location while the displaced pixel \(B\) moves to a different direction.
Effect of Direction at \(d=1\)
All four examples use the same one-pixel separation, but they select different spatial relationships.
Horizontal →

\(\Delta=(0,1)\)

Vertical ↓

\(\Delta=(1,0)\)

Diagonal ↘

\(\Delta=(1,1)\)

Diagonal ↗

\(\Delta=(-1,1)\)

Effect of Distance with Direction Fixed
Keeping the direction horizontal while increasing \(d\) moves the second pixel farther from the reference pixel.
Distance \(d=1\)
A B

immediate-neighbor relationship

Distance \(d=2\)
A · B

wider spatial relationship

Distance \(d=3\)
A · · B

still larger-scale relationship

Choose \((d,\theta)\)
→
Select valid pixel pairs
→
Build SGLDM or GLDM
Image boundaries also affect the number of valid pairs. For an \(H\times W\) image and a directed offset \(\Delta=(\Delta r,\Delta c)\), the number of valid pairs is
\[ N_{\text{pairs}} = (H-|\Delta r|)(W-|\Delta c|). \]
For example, a \(4\times4\) image with \(\Delta=(1,1)\) has \((4-1)(4-1)=9\) valid directed pairs. This is why a one-pixel diagonal displacement on this 4 × 4 example produces nine pairs.
Reference pixel \(A\) Displaced pixel \(B\)
Changing direction changes which orientations are sampled. Changing distance changes how far apart the paired pixels are. In both cases, the underlying pair set can change, so the resulting matrix and feature values can also change.
Important: the pair \((d,\theta)\), or equivalently the discrete displacement \(\Delta\), is part of the descriptor definition. Feature values from different displacement settings should not be treated as though they were the same measurement.

11. Comparing Statistical Texture Methods

Method What It Records What It Describes
SGLDM Gray-level pair counts or probabilities \((i,j)\) Which gray levels tend to occur together?
GLDM Distribution of \(|i-j|\) How strongly do paired gray levels differ?
NGLDM Local dependence on similar neighboring gray levels How many neighbors behave similarly to a center pixel?
GLRLM Runs of equal gray level and their lengths How long do repeated same-level sequences persist?
These methods are related, but they do not measure exactly the same property. A useful texture descriptor often combines several complementary features rather than relying on one number.

12. Neighboring Gray-Level Dependence Statistics (NGLDM)

NGLDM shifts attention from a single pixel pair to a center pixel and its surrounding neighborhood. A neighboring pixel is considered dependent on the center when it is sufficiently similar according to the selected dependence rule.

Local Dependence Example
2
0
2
2
2
2
3
2
0

Dependence Count

The center value is compared with nearby values. Green cells satisfy the chosen similarity rule; the others do not.

NGLDM-based descriptors summarize how these local dependence counts are distributed throughout a texture.

NGLDM has additional choices such as neighborhood size and the tolerance used to decide whether two gray levels are sufficiently similar. Those choices should be stated whenever NGLDM features are compared.

13. Gray-Level Run-Length Matrix (GLRLM)

A run is a consecutive sequence of pixels with the same gray level along a selected direction. GLRLM records both the gray level of each run and how long that run continues.

Example 1-D Run Sequence
1
1
1
3
3
0
2
2
2
2
Run 1 gray level \(1\)
length \(3\)
Run 2 gray level \(3\)
length \(2\)
Run 3 gray level \(0\)
length \(1\)
Run 4 gray level \(2\)
length \(4\)
GLRLM does not only record which gray levels occur. It also records how long equal-gray-level sequences persist along the selected direction.

One way to express a GLRLM entry is

\[ R(i,r;\theta) = \#\{ \text{runs of gray level }i \text{ having length }r \text{ along }\theta \}. \]
SGLDM focuses on pixel pairs, while GLRLM focuses on extended same-level sequences. The two methods therefore capture different aspects of texture structure.

14. Texture Feature Vectors and Discrimination

A texture classifier usually does not need the entire matrix as its final input. Instead, several numerical descriptors can be combined into a feature vector.

\[ \mathbf{x} = [ E(d_1,\theta_1), H_{\mathrm{SGLDM}}(d_1,\theta_1), E(d_2,\theta_2), \operatorname{CON}(\Delta_1), \operatorname{CON}(\Delta_2), \ldots ]. \]
Texture image or texture region
↓
Compute statistical texture representation
↓
Extract numerical features
↓
Form feature vector \(\mathbf{x}\)
↓
Compare, cluster, or classify textures
A useful feature separates different texture classes while keeping samples from the same texture class relatively close together in feature space.

15. Interactive Statistical Texture Visualizer

The visualizer below lets you edit a four-level image, \(Q=\{0,1,2,3\}\), choose a displacement, and build the statistical texture descriptors directly from the selected pixel relationships.

SGLDM Builder

Step through valid pixel pairs and watch the corresponding \(C(i,j)\) entry increase. The normalized matrix \(P(i,j)\), energy, and SGLDM entropy update from the pairs that have been processed.

GLDM and Contrast

The same processed pairs are converted to \(k=|i-j|\). The GLDM difference distribution and contrast therefore remain aligned with the SGLDM calculation.

16. Summary

Concept Main Idea
HistogramCounts gray levels but ignores spatial arrangement
DisplacementDefines the distance and direction between compared pixels
SGLDMCounts gray-level pairs \((i,j)\) at a selected displacement
NormalizationConverts counts to \(P(i,j)\), a pair-probability distribution whose total is 1
EnergyMeasures concentration of normalized SGLDM probability
SGLDM EntropyMeasures spread of the gray-level pair probability distribution
Morphological vs. SGLDM EntropySame Shannon formula, but scale distribution versus gray-level pair distribution
GLDMDescribes the distribution of absolute gray-level differences
ContrastWeights large gray-level differences more strongly
NGLDMDescribes local dependence on similar neighbors
GLRLMCounts equal-gray-level runs by gray level and run length
Feature VectorCombines numerical descriptors for comparison or classification

Interactive Statistical Texture Explorer
Edit a four-level image, choose a displacement, and build the SGLDM and GLDM from the same sequence of valid pixel pairs. Energy, SGLDM entropy, and GLDM contrast update from exactly the pairs that have been processed.
Preset
Direction
Distance d
Matrix Display
4 × 4 Gray-Level Image
Q = {0,1,2,3}. Click any pixel to cycle its value.
reference pixel displaced neighbor
The selected direction is treated as a directed displacement. Each valid reference location contributes exactly one pair; the matrix is not automatically symmetrized.
SGLDM
GLDM Difference Distribution
Processed Pairs
0 / 0
counted / total valid
Energy
—
Σ P(i,j)²
SGLDM Entropy
—
−Σ P log₂ P
GLDM Contrast
—
Σ k² pΔ(k)
Current Difference
—
|i − j| for next pair
Ready.

Published inDigital Image Processing

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *