r.smooth.edgepreserve(1grass)
β¨ r.smooth.edgepreserve β¨
okay bestie, welcome to r.smooth.edgepreserve, the GRASS module that does smoothing with anisotropic diffusion π
it lives in the GRASS User's Manual and it is genuinely so iconic for denoising raster while keeping your edges crisp. no cap.
KEYWORDS: raster, smoothing, edge detection, parallel, denoise π
πΈ SYNOPSIS πΈ
r.smooth.edgepreserve
r.smooth.edgepreserve --help
r.smooth.edgepreserve [-p] input=name output=name threshold=float
lambda=float steps=integer function=string [memory=memory in MB]
[nprocs=integer] [--overwrite] [--help] [--verbose] [--quiet]
[--ui]
π Flags
-pβ Preserve details with Tukey π¦--overwriteβ Allow output files to overwrite existing files--helpβ Print usage summary--verboseβ Verbose module output--quietβ Quiet module output--uiβ Force launching GUI dialog
π Parameters
input=name[required] β Name of input raster mapoutput=name[required] β Name for output raster mapthreshold=float[required] β Gradient magnitude threshold (in map units)- Options:
0.000000001- - Default:
5
- Options:
lambda=float[required] β Rate of diffusion- Options:
0-1 - Default:
0.1
- Options:
steps=integer[required] β Number of diffusion steps- Options:
1- - Default:
10
- Options:
function=string[required] β Diffusivity function- Options:
exponential,quadratic,tukey - Default:
tukey
- Options:
memory=memory in MBβ Maximum memory to be used (in MB)- Cache size for raster rows
- Default:
300
nprocs=integerβ Number of threads for parallel computing0: use OpenMP default;>0: use nprocs;<0: use MAX-nprocs- Default:
0
π DESCRIPTION π
So this module does adaptive, edge-preserving raster smoothing using anisotropic diffusion. the way it works is: you get back a denoised raster that still keeps its important features, especially edges. it's giving main character energy among smoothing tools tbh.
unlike traditional smoothing methods (think a uniform average filter, like the one you'd get in r.neighbors), this module only smooths areas with similar values and works hard to preserve sharp transitions between different regions. π«Ά there's a pic in the docs btw: "A" is the original and "B" is the smoothed version.
The module supports three types of diffusivity (conductance) functions:
- Exponential
- Quadratic (both as proposed by Perona & Malik, 1990)
- Tukey's biweight (as proposed by Black et al., 1998)
The Tukey's biweight function is more aggressive than the others and tends to produce large, smoothly blended areas. that makes it particularly useful for raster segmentation, slay. 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. π
π§ PARAMETERS π§
- threshold β Defines how small a difference in raster values should be treated as noise. The unit depends on the raster (e.g., digital numbers, meters, etc.), and should be adjusted individually for each map. literally per-map, don't skip this.
- lambda β Controls the smoothing rate.
- For exponential and quadratic functions, the value is automatically clamped between 0 and 0.25 for numeric stability.
- For Tukey, the full range is used.
- steps β Specifies the number of smoothing iterations. Higher values result in stronger smoothing. Note that:
- Excessive iterations can cause loss of fine detail. π
- Detail preservation improves in this order: quadratic β exponential β Tukey β Tukey with
-pflag.
π NOTES π
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.
π₯ EXAMPLES π₯
# 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
π¦ SEE ALSO π¦
- Smooth with statistics:
r.neighbours - The Mumford-Shah variational model for image segmentation (an add-on):
r.smooth.seg
π REFERENCES π
- Perona P. and Malik J. 1990. Scale-space and edge detection using anisotropic diffusion. IEEE transactions on pattern analysis and machine intelligence, 12(7).
- Black M.J., Sapiro G., Marimont D.H. and Heeger D. 1998. Robust anisotropic diffusion. IEEE transactions on image processing, 7(3).
π AUTHORS π
Maris Nartiss, University of Latvia.
β SOURCE CODE β
Available at: r.smooth.edgepreserve source code (history)
Latest change: Saturday Oct 25 22:50:58 2025 in commit: ee87f21833475fd40805f58d1702f7d64478a27b
Main index | Raster index | Topics index | Keywords index | Graphical index | Full index
π okay that's the whole page bestie, go smooth something gorgeous. and fr fr, remember: this was GRASS 8.5.0 (r.smooth.edgepreserve(1grass)), Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual. periodt. π
β¨
π¦ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 Β· GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms