View source: R/optim_dist_to_black.R
optim_dist_to_black | R Documentation |
Estimate an optimal buffer (dist_to_black
) to keep sampled sky points away
from candidate canopy pixels (black pixels).
optim_dist_to_black(r, z, a, m, bin, g)
r |
numeric terra::SpatRaster of one layer. Typically the blue band of a canopy image. |
z |
terra::SpatRaster generated with |
a |
terra::SpatRaster generated with |
m |
logical terra::SpatRaster with one layer. A binary mask with
|
bin |
logical terra::SpatRaster of one layer. Binary image where
|
g |
numeric terra::SpatRaster of one layer. Segmentation grid,
usually built with |
The heuristic seeks the largest buffer that still yields uniform angular
coverage. It iteratively decreases dist_to_black
while monitoring the
percentage of 30 deg sky‑grid cells covered by sampled points. If coverage
is low, the buffer is relaxed (and may be removed). This balances border
avoidance with representativeness across the sky vault.
numeric vector of length one to be passed as dist_to_black
to
extract_sky_points()
, or NULL
if no buffer is advised.
## Not run:
caim <- read_caim()
z <- zenith_image(ncol(caim), lens())
a <- azimuth_image(z)
m <- !is.na(z)
r <- caim$Blue
bin <- binarize_by_region(r, ring_segmentation(z, 15), "thr_isodata") &
select_sky_region(z, 0, 88)
g <- sky_grid_segmentation(z, a, 10, first_ring_different = TRUE)
dist_to_black <- optim_dist_to_black(r, z, a, m, bin, g)
dist_to_black
bin <- grow_black(bin, 11)
plot(bin)
dist_to_black <- optim_dist_to_black(r, z, a, m, bin, g)
dist_to_black
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.