View source: R/tree_detection.R
dem_filtering | R Documentation |
applies two filters to an image:
A non-linear filter: closing (mclosing
) with disk
kernel, or median (medianblur
) with square kernel
A 2D Gaussian smoother (The deriche
filter is
applied on both dimensions). Value-dependent smoothing is possible
dem_filtering(
dem,
nl_filter = "Closing",
nl_size = 5,
sigma = 0.3,
padding = TRUE,
sigmap = NULL
)
dem |
cimg object (e.g. obtained with |
nl_filter |
string. type of non-linear filter to apply: "None", "Closing" or "Median" |
nl_size |
numeric. kernel width in pixels for non-linear filtering |
sigma |
numeric or matrix. If a single number is provided, |
padding |
boolean. Whether image should be padded by duplicating edge values before filtering to avoid border effects |
sigmap |
deprecated (numeric or matrix). (old name for |
A list of two cimg objects or a SpatRaster object with image after non-linear filter and image after both filters
maxima_detection
, filters of imager package:
mclosing
, medianblur
,
deriche
data(chm_chablais3)
chm_chablais3 <- terra::rast(chm_chablais3)
# filtering with median and Gaussian smoothing
im <- dem_filtering(chm_chablais3, nl_filter = "Median", nl_size = 3, sigma = 0.8)
# filtering with median filter and value-dependent Gaussian smoothing
# (less smoothing for values between 0 and 15)
im2 <- dem_filtering(chm_chablais3,
nl_filter = "Median", nl_size = 3,
sigma = cbind(c(0.2, 0.8), c(0, 15))
)
# plot original image
terra::plot(chm_chablais3, main = "Initial image")
# plot image after median filter
terra::plot(im$non_linear_image, main = "Median filter")
# plot image after median and Gaussian filters
terra::plot(im$smoothed_image, main = "Smoothed image")
# plot image after median and value-dependent Gaussian filters
terra::plot(im2$smoothed_image, main = "Value-dependent smoothing")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.