This module performs adaptive, edge-preserving raster smoothing using anisotropic diffusion. The result is a denoised raster that retains important features, especially edges. Unlike traditional smoothing methods (such as a uniform average filter, like the one available in r.neighbors), this module smooths only areas with similar values and works to preserve sharp transitions between different regions. An example is provided in the picture below: "A" is the original and "B" is the smoothed version.
The module supports three types of diffusivity (conductance) functions:
The Tukey’s biweight function is more aggressive than the others and tends to produce large, smoothly blended areas. This makes it particularly useful for raster segmentation. If you prefer a gentler effect that preserves smaller features, you can use the -p flag, which switches to a softer variant of the Tukey function — ideal for applications like visualization.
Internally calculations are performed in double precision and only at the end converted to the same type as the input map.
The module will try to keep all temporary data in RAM. Thus it is important to set the memory parameter as high as possible. If the map does not fit into RAM, a temporary file will be used instead.
The original Perona & Malik paper uses von Neumann (4-connected) neighbourhood for value calculation, but this module uses Moore (8-connected) neighbourhood. Computed gradients of neighbouring cells are adjusted to equalise distances for diagonals and non-square cells.
# Set computational region to orthophoto map g.region raster=ortho_2001_t792_1m -p # Smooth with average in a 3x3 window. Note how all edges have became blurry # but at the same time streets and roofs are still noisy r.neighbors input=ortho_2001_t792_1m output=ortho_smoothed_avg \ size=3 method=average # Smooth with median in a 3x3 window. Although better than average smoothing, # thin lines still are lost and noise on streets and roofs is still present. r.neighbors input=ortho_2001_t792_1m output=ortho_smoothed_med \ size=3 method=median # Smooth with quadratic diffusivity function. Note better preservation of # small details and reduction of noise on streets and roofs. r.smooth.edgepreserve function=quadratic input=ortho_2001_t792_1m \ output=ortho_smoothed_qa threshold=15 lambda=0.4 steps=20 # Smooth with exponential diffusivity function. Even better edge delineation # but at the same time increase of noise in really noisy areas. r.smooth.edgepreserve function=exponential input=ortho_2001_t792_1m \ output=ortho_smoothed_ex threshold=15 lambda=0.4 steps=20 # Smooth with aggressive Tukey's diffusivity function. Better preservation of # minor details e.g. as road markings but little smoothing in areas with # fine, well expressed texture. r.smooth.edgepreserve function=tukey input=ortho_2001_t792_1m \ output=ortho_smoothed_ta threshold=15 lambda=0.4 steps=20 # Smooth with preserving Tukey's diffusivity function. Only low noise areas # have been smoothed. r.smooth.edgepreserve function=tukey input=ortho_2001_t792_1m \ output=ortho_smoothed_tp threshold=15 lambda=0.4 steps=20 -p
Available at: r.smooth.edgepreserve source code (history)
Latest change: Friday May 23 21:47:35 2025 in commit: 3702a479838afa599193af84c97daefeb7b8d2c3
Main index | Raster index | Topics index | Keywords index | Graphical index | Full index
© 2003-2025 GRASS Development Team, GRASS GIS 8.5.0dev Reference Manual