apply_thr | R Documentation |
Global or local thresholding of images.
apply_thr(r, thr)
r |
SpatRaster. A greyscale image. |
thr |
Numeric vector of length one or a single-layer raster from the class SpatRaster. Threshold. |
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.
An object of class SpatRaster with values 0
and 1
.
Other Binarization Functions:
obia()
,
ootb_mblt()
,
ootb_obia()
,
regional_thresholding()
,
thr_isodata()
,
thr_mblt()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.