Skip to content

r.denoise

r.denoise - denoise topographic data

r.denoise input=string output=string [iterations=integer] [threshold=float] [epsg=integer] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]

Example:

r.denoise input=string output=string

grass.script.run_command("r.denoise", input, output, iterations=5, threshold=0.93, epsg=None, overwrite=None, verbose=None, quiet=None, superquiet=None)

Example:

gs.run_command("r.denoise", input="string", output="string")

grass.tools.Tools.r_denoise(input, output, iterations=5, threshold=0.93, epsg=None, overwrite=None, verbose=None, quiet=None, superquiet=None)

Example:

tools = Tools()
tools.r_denoise(input="string", output="string")

This grass.tools API is experimental in version 8.5 and expected to be stable in version 8.6.

Parameters

input=string [required]
    Raster input map
output=string [required]
    Denoised raster output map
iterations=integer
    Number of normal-updating iterations
    Allowed values: 1-50
    Default: 5
threshold=float
    Edge-sharpness threshold
    Allowed values: 0.0-1.0
    Default: 0.93
epsg=integer
    EPSG projection code (required if current location is not projected)
--overwrite
    Allow output files to overwrite existing files
--help
    Print usage summary
--verbose
    Verbose module output
--quiet
    Quiet module output
--qq
    Very quiet module output
--ui
    Force launching GUI dialog

input : str, required
    Raster input map
    Used as: input, raster
output : str, required
    Denoised raster output map
    Used as: output, raster
iterations : int, optional
    Number of normal-updating iterations
    Allowed values: 1-50
    Default: 5
threshold : float, optional
    Edge-sharpness threshold
    Allowed values: 0.0-1.0
    Default: 0.93
epsg : int, optional
    EPSG projection code (required if current location is not projected)
overwrite : bool, optional
    Allow output files to overwrite existing files
    Default: None
verbose : bool, optional
    Verbose module output
    Default: None
quiet : bool, optional
    Quiet module output
    Default: None
superquiet : bool, optional
    Very quiet module output
    Default: None

input : str | np.ndarray, required
    Raster input map
    Used as: input, raster
output : str | type(np.ndarray) | type(np.array) | type(gs.array.array), required
    Denoised raster output map
    Used as: output, raster
iterations : int, optional
    Number of normal-updating iterations
    Allowed values: 1-50
    Default: 5
threshold : float, optional
    Edge-sharpness threshold
    Allowed values: 0.0-1.0
    Default: 0.93
epsg : int, optional
    EPSG projection code (required if current location is not projected)
overwrite : bool, optional
    Allow output files to overwrite existing files
    Default: None
verbose : bool, optional
    Verbose module output
    Default: None
quiet : bool, optional
    Quiet module output
    Default: None
superquiet : bool, optional
    Very quiet module output
    Default: None

Returns:

result : grass.tools.support.ToolResult | np.ndarray | tuple[np.ndarray] | None
If the tool produces text as standard output, a ToolResult object will be returned. Otherwise, None will be returned. If an array type (e.g., np.ndarray) is used for one of the raster outputs, the result will be an array and will have the shape corresponding to the computational region. If an array type is used for more than one raster output, the result will be a tuple of arrays.

DESCRIPTION

Sun et al.'s (2007) denoising algorithm is a feature-preserving mesh denoising algorithm that smooths the surfaces of computer models of three dimensional objects such as those used in computer-aided design and graphics. It removes random noise while preserving sharp features and smoothing with minimal changes to the original data. r.denoise is a Python script that allows the algorithm to be run on DEMs from within GRASS. Denoising DEMs can improve clarity and quality of derived products such as slope and hydraulic maps.

The amount of smoothing is controlled by the threshold and iterations parameters. Increasing the threshold decreases how sharp a feature needs to be in order to be preserved e.g. decreases the smoothing. To preserve ridge crests in mountain areas, T > 0.9 is recommended. Setting T too high results in the preservation of noise. For SRTM data, which is already partly smoothed by NASA, T = 0.99 can be used. Increasing the number of iterations increases the smoothing and the range of spatial correlation of the output dataset. A small number, e.g. 5 or fewer, typically gives the best results. See the REFERENCES for more detailed information.

NOTES

r.denoise works with a Cartesian coordinate system. Thus data in geographic (lat-long) coordinates require projection during processing. The script is able to do this if the EPSG code of a suitable coordinate system is provided.

REQUIREMENTS

r.denoise requires that mdenoise, the executable version of Sun et al.'s (2007) denoising algorithm, is available on the $PATH. mdenoise can be compiled and installed as follows:

wget http://www.cs.cf.ac.uk/meshfiltering/index_files/Doc/mdsource.zip
unzip mdsource.zip
cd mdenoise
g++ -o mdenoise mdenoise.cpp triangle.c
ln -s `pwd`/mdenoise /some/directory/on/the/$PATH

The python version of r.denoise uses pyproj:

pip install pyproj

REFERENCES

SEE ALSO

r.stats, r.in.xyz, r.neighbors, r.topidx

AUTHORS

John A Stevenson
johnalexanderstevenson at yahoo dot co dot uk

The module was written as part of a project funded by EPSRC Grant no. EP/C007972/1 (P.I. Paul Rosin, Cardiff University).

Module ported to Python by Carlos H. Grohmann
Institute of Energy and Environment, University of Sao Paulo, Brazil

SOURCE CODE

Available at: r.denoise source code (history)
Latest change: Friday Feb 21 10:10:05 2025 in commit 7d78fe3