| apply_thr {rcaiman} | R Documentation |
Apply threshold
Description
Global or local thresholding of images.
Usage
apply_thr(r, thr)
Arguments
r |
SpatRaster. A greyscale image. |
thr |
Numeric vector of length one or a single-layer raster from the class SpatRaster. Threshold. |
Details
It is a wrapper function around the operator > from the terra package. If
a single threshold value is provided as the thr argument, it is applied to
every pixel of the object r. If instead a SpatRaster is provided,
a particular threshold is applied to each particular pixel.
Value
An object of class SpatRaster with values 0 and 1.
See Also
Other Binarization Functions:
obia(),
ootb_mblt(),
ootb_obia(),
regional_thresholding(),
thr_isodata(),
thr_mblt()
Examples
r <- read_caim()
bin <- apply_thr(r$Blue, thr_isodata(r$Blue[]))
plot(bin)
## Not run:
# This function is useful in combination with the ‘autothresholdr’
# package. For example:
require(autothresholdr)
thr <- auto_thresh(r$Blue[], "IsoData")[1]
bin <- apply_thr(r$Blue, thr)
plot(bin)
## End(Not run)
[Package rcaiman version 1.2.2 Index]