edge_detection {lidaRtRee} | R Documentation |
Edge detection in gap image
Description
Performs edge detection on a gap image (e.g. output from function
gap_detection
). The gap image is compared to a gap image which
has undergone a dilation or erosion to identify edges of gaps.
Usage
edge_detection(gaps, inside = TRUE)
Arguments
gaps |
SpatRaster object. gaps image where 1 represents gaps and 0 non-gaps areas |
inside |
boolean. defines where the edge is extracted: either inside the gaps (an erosion is applied to the gaps image) or outside (a dilation is applied) |
Value
A SpatRaster object where edges are labelled as 1.
See Also
Examples
data(chm_chablais3)
chm_chablais3 <- terra::rast(chm_chablais3)
# fill NA values in canopy height model
chm_chablais3[is.na(chm_chablais3)] <- 0
# gap detection with distance larger than canopy height / 2
gaps <- gap_detection(chm_chablais3,
ratio = 2, gap_max_height = 1, min_gap_surface = 10,
gap_reconstruct = TRUE
)
# edge detection
edges_inside <- edge_detection(!is.na(gaps$gap_id))
edges_outside <- edge_detection(!is.na(gaps$gap_id), inside = FALSE)
# edge proportion
sum(terra::values(edges_inside)) / (nrow(edges_inside) * ncol(edges_inside))
sum(terra::values(edges_outside)) / (nrow(edges_outside) * ncol(edges_outside))
# plot original image
terra::plot(chm_chablais3, main = "Initial image")
# plot binary image of gaps
terra::plot(gaps$gap_id > 0, main = "Gaps", col = "green", legend = FALSE)
# plot edges
terra::plot(edges_inside, main = "Edges (inside)", legend = FALSE)
terra::plot(edges_outside, main = "Edges (outside)", legend = FALSE)
[Package lidaRtRee version 4.0.5 Index]