Skip to content

Anisotropic Diffusion for Image Filtering

Anisotropic diffusion repeatedly updates a grayscale image using differences between neighboring pixels. The amount of diffusion changes according to those local differences.

1. Why Anisotropic Diffusion?

Smoothing can reduce unwanted variations in pixel intensity. However, smoothing can also change important intensity transitions such as edges.

Anisotropic diffusion changes how strongly different neighboring pixel differences contribute to the smoothing process.

Noisy Image → Anisotropic Diffusion → Filtered Image
Noisy Image
Local intensity variation
→
Filtered Image
Reduced local variation while a larger transition remains
Unlike uniform smoothing, the diffusion strength can change according to the local intensity differences.

2. Directional Gradients

For each interior pixel, the center intensity is compared with its immediate north, south, east, and west neighbors.

Center Pixel and Four Neighboring Directions
North
\(I_N\)
West
\(I_W\)
Center
\(I_C\)
East
\(I_E\)
South
\(I_S\)
\[ \nabla_N I = I_N-I_C \] \[ \nabla_S I = I_S-I_C \] \[ \nabla_E I = I_E-I_C \] \[ \nabla_W I = I_W-I_C \]
A smaller gradient means the neighboring intensity is more similar to the center. A larger gradient means the intensities are more different.

3. Diffusion Coefficients

Each directional gradient is passed through a conduction function. The result is a diffusion coefficient for that direction.

\(c_N\)
Controls how much the north gradient contributes.
\(c_S\)
Controls how much the south gradient contributes.
\(c_E\)
Controls how much the east gradient contributes.
\(c_W\)
Controls how much the west gradient contributes.
A coefficient closer to 1 allows more of the directional gradient to contribute. A coefficient closer to 0 reduces its contribution.

4. Conduction Functions

The conduction function determines the diffusion coefficient from the gradient magnitude.

Exponential Conduction Function

\[ g(s,K) = \exp \left[ – \left( \frac{s}{K} \right)^2 \right] \]

Reciprocal Conduction Function

\[ g(s,K) = \frac{ 1 }{ 1+ \left( \frac{s}{K} \right)^2 } \]

Both functions also use the parameter \(K\). \(K\) changes how the gradient magnitude affects the diffusion coefficient.

For the same gradient, changing \(K\) changes how strongly that gradient contributes to the diffusion process.
Diffusion Coefficient as the Gradient Becomes Larger
Exponential Reciprocal Gradient Magnitude Relative to K Diffusion Coefficient
Both functions reduce the diffusion coefficient when the gradient becomes large relative to \(K\), but they decrease differently.

5. The Diffusion Constant \(\lambda\)

After the four weighted directional gradients are combined, \(\lambda\) controls the size of the update.

1. Combine the Weighted Directional Gradients
\[ c_N\nabla_N I + c_S\nabla_S I + c_E\nabla_E I + c_W\nabla_W I \]
↓
2. Scale the Combined Value
\[ \lambda \left( c_N\nabla_N I + c_S\nabla_S I + c_E\nabla_E I + c_W\nabla_W I \right) \]
↓
3. Use It as the Pixel Update The scaled value is added to the current pixel.
\(\lambda\) controls how large a change is made during one diffusion iteration.

6. Updating the Pixel

The four directional contributions are combined to determine the next value of the center pixel.

\[ I_{i,j}^{t+1} = I_{i,j}^{t} + \lambda \left( c_N\nabla_N I + c_S\nabla_S I + c_E\nabla_E I + c_W\nabla_W I \right) \]
Read the center pixel and four neighbors
↓
Calculate the four directional gradients
↓
Calculate the four diffusion coefficients
↓
Multiply each gradient by its coefficient
↓
Add the four weighted contributions
↓
Scale the result by \(\lambda\)
↓
Add the update to the center pixel

7. Iterations

Anisotropic diffusion is repeated. Each new iteration uses the result produced by the previous iteration.

\[ I^{(0)} = I \] \[ I^{(t+1)} = \operatorname{Diffusion} \left( I^{(t)} \right) \]
Iteration 0
Original noisy image
Iteration 5
Some local variation is reduced
Iteration 20
More repeated diffusion
Iteration 100
Many repeated updates
More iterations mean the diffusion update has been applied more times. The result also depends on the conduction function, \(K\), \(\lambda\), and the image.

8. Line Profile

A line profile shows how grayscale intensity changes along one selected row of an image.

Selected Image Row
selected row
Intensity Along the Row
Position Along Row Intensity
A large change in the line profile corresponds to a strong intensity transition along that row.

9. Range-Threshold Segmentation

A binary result can be created by selecting pixels whose grayscale intensities fall inside a chosen range.

\[ 80 \lt I \lt 120 \]
Select Intensities Between 80 and 120
80
120
Binary Result
Pixels inside the selected intensity range become foreground. Pixels outside the range become background.

10. Interactive Example

The interactive visualizer below lets you change grayscale pixel intensities, inspect one diffusion update, and then apply repeated anisotropic diffusion to a complete grayscale image.

Select one of the five pixels
↓
Change its 8-bit grayscale intensity
↓
Choose the conduction function, \(K\), and \(\lambda\)
↓
Inspect the directional gradients, coefficients, and weighted values
↓
Step through repeated diffusion on the whole image
↓
Compare the image, line profile, and segmentation

Summary

Concept Meaning
Directional Gradient Intensity difference between the center pixel and one neighboring pixel.
Diffusion Coefficient Weight applied to a directional gradient.
Conduction Function Calculates a diffusion coefficient using the gradient magnitude and \(K\).
\(K\) Parameter used by the conduction function.
\(\lambda\) Controls the size of the update during one iteration.
Iteration One complete anisotropic-diffusion update.
Line Profile Grayscale intensities along a selected image row.
Range-Threshold Segmentation Selects pixels whose intensities fall inside a chosen range.

Anisotropic Diffusion Visualizer
Pixel and Four Neighbors

Click a pixel to select it. Its grayscale shade represents its 8-bit intensity.

Center Selected
Selected Pixel
Center Pixel
Current pixel being updated
100
0 = black 255 = white
Directional Calculations
North
Gradient
Coefficient
Weighted
South
Gradient
Coefficient
Weighted
East
Gradient
Coefficient
Weighted
West
Gradient
Coefficient
Weighted
New Center Value
0
Original Noisy Image
0 → grayscale intensity → 255
Diffused Image
Current diffusion result
Iteration
0
K
30
Lambda
0.25
Center-Row Line Profile
Range-Threshold Segmentation

Published inDigital Image Processing

Be First to Comment

Leave a Reply

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