Skip to contents

Applies an edge-preserving smoothing filter that reduces noise while preserving important edges in the image.

Usage

wbw_bilateral_filter(x, sigma_dist = 0.75, sigma_int = 1)

Arguments

x

Raster object of class WhiteboxRaster. See wbw_read_raster() for more details.

sigma_dist

double, standard deviation distance parameter in pixels.

sigma_int

double, standard deviation intensity parameter, in the same units as z-units of input raster x (usually, meters).

Value

WhiteboxRaster object containing filtered values

Details

Bilateral filtering is a non-linear technique introduced by Tomasi and Manduchi (1998). The filter combines spatial and intensity domains to preserve edges while smoothing. Unlike the Gaussian filter, the bilateral filter weights pixels based on both their spatial distance and intensity similarity to the center pixel.

The size of the filter is determined by setting the standard deviation distance parameter (sigma_dist); the larger the standard deviation the larger the resulting filter kernel. The standard deviation can be any number in the range 0.5-20 and is specified in the unit of pixels. The standard deviation intensity parameter (sigma_int), specified in the same units as the z-values, determines the intensity domain contribution to kernel weightings.

References

Tomasi, C., & Manduchi, R. (1998, January). Bilateral filtering for gray and color images. In null (p. 839). IEEE.

For more information, see https://www.whiteboxgeo.com/manual/wbw-user-manual/book/tool_help.html#bilateral_filter

Examples

f <- system.file("extdata/dem.tif", package = "wbw")
wbw_read_raster(f) |>
  wbw_bilateral_filter(sigma_dist = 1.5, sigma_int = 1.1)
#> +-----------------------------------------------+ 
#> | WhiteboxRaster                                |
#> | dem.tif                                       |
#> |...............................................| 
#> | bands       : 1                               |
#> | dimensions  : 726, 800  (nrow, ncol)          |
#> | resolution  : 5.002392, 5.000243  (x, y)      |
#> | EPSG        : 2193  (Linear_Meter)            |
#> | extent      : 1925449 1929446 5582091 5585717 |
#> | min value   : 64.258514                       |
#> | max value   : 360.483490                      |
#> +-----------------------------------------------+