Applies an adaptive filter to reduce random noise (shot noise) in a raster image. The filter modifies pixel values only where they differ substantially from their neighbors.
Arguments
- x
 Raster object of class WhiteboxRaster. See
wbw_read_raster()for more details.- filter_size_x
 integer, X dimension of the neighbourhood size- filter_size_y
 integer, Y dimension of the neighbourhood size- threshold
 double
Value
WhiteboxRaster object containing filtered values
Details
The algorithm calculates the average value in a moving window centered on each grid cell. If the absolute difference between the window mean and the center cell value exceeds the user-defined threshold, the output cell is assigned the mean value. Otherwise, it retains its original value.
Neighbourhood size, or filter size, is specified in the x and y dimensions
using filter_size_x and filter_size_y These dimensions should
be odd, positive integer values (e.g. 3L, 5L, 7L, 9L, etc.).
References
For more information, see https://www.whiteboxgeo.com/manual/wbw-user-manual/book/tool_help.html#adaptive_filter
Examples
f <- system.file("extdata/dem.tif", package = "wbw")
wbw_read_raster(f) |>
  wbw_adaptive_filter(filter_size_x = 3L, filter_size_y = 3L)
#> +-----------------------------------------------+ 
#> | 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   : 63.698193                       |
#> | max value   : 361.020721                      |
#> +-----------------------------------------------+ 
