View source: R/binarize_by_region.R
binarize_by_region | R Documentation |
Perform thresholding of greyscale images by applying a method regionally, using a segmentation map.
binarize_by_region(r, segmentation, method)
r |
numeric terra::SpatRaster of one layer. Typically the blue channel of a canopy photograph. |
segmentation |
numeric terra::SpatRaster of one layer. A labeled
segmentation map defining the regions over which to apply the thresholding
method. Ring segmentation (see |
method |
character vector of length one. Name of the thresholding method to apply. See Details. |
This function supports several thresholding methods applied within the
regions defined by segmentation
:
autothresholdr
package:Any method supported by
autothresholdr::auto_thresh()
can be used by specifying its name.
For example, "IsoData"
applies the classic iterative intermeans algorithm
\insertCiteisodata;textualrcaiman, which is among the most recommended
for canopy photography \insertCiteJonckheere2005rcaiman.
Use "thr_isodata"
to apply
thr_isodata()
, a native implementation of the same algorithm
Use "thr_twocorner"
to apply
thr_twocorner()
, which implements a geometric thresholding strategy based
on identifying inflection points in the histogram, first introduced to
canopy photography by \insertCiteMacfarlane2011;textualrcaiman. Since
this method tend to fail, the fallback is thr_isodata
Logical terra::SpatRaster (TRUE
for sky, FALSE
for
non-sky) of the same dimensions as r
.
When methods from the autothresholdr
package are used, r
values
should be constrained to the range [0, 1]
. See normalize_minmax()
.
## Not run:
path <- system.file("external/DSCN4500.JPG", package = "rcaiman")
zenith_colrow <- c(1276, 980)
diameter <- 756*2
caim <- read_caim(path, zenith_colrow - diameter/2, diameter, diameter)
z <- zenith_image(ncol(caim), lens("Nikon_FCE9"))
r <- invert_gamma_correction(caim$Blue)
r <- correct_vignetting(r, z, c(0.0638, -0.101)) %>% normalize_minmax()
rings <- ring_segmentation(z, 15)
bin <- binarize_by_region(r, rings, "thr_isodata")
plot(bin)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.