Skip to contents

This tool performs a high-pass median filter on a raster image. High-pass filters can be used to emphasize the short-range variability in an image. The algorithm operates essentially by subtracting the value at the grid cell at the centre of the window from the median value in the surrounding neighbourhood (i.e. window.)

Usage

wbw_high_pass_median_filter(
  x,
  filter_size_x = 11L,
  filter_size_y = 11L,
  sig_digits = 2L
)

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

sig_digits

integer, default 2. Required for rounding of floating points inputs.

Value

WhiteboxRaster object containing filtered values

Details

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.).

Examples

f <- system.file("extdata/dem.tif", package = "wbw")
wbw_read_raster(f) |>
  wbw_high_pass_median_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   : -3.650000                       |
#> | max value   : 9.320000                        |
#> +-----------------------------------------------+