thresh | R Documentation |
Compute a threshold to divide the values of a SpatRaster into two groups, and use that threshold to classify the raster.
## S4 method for signature 'SpatRaster'
thresh(x, method="otsu", maxcell=1000000, combine=FALSE,
as.raster=TRUE, filename="", ...)
x |
SpatRaster |
method |
character. One of "mean", "median" or "otsu" for Otsu's method |
maxcell |
positive integer. Maximum number of cells to use to compute the threshold |
combine |
logical. If |
as.raster |
logical. If |
filename |
character. Output filename |
... |
additional arguments for writing files as in |
numeric or SpatRaster
Otsu, N. (1979). A Threshold Selection Method from Gray-Level Histograms. IEEE Transactions on Systems, Man, and Cybernetics, 9(1), 62-66. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1109/TSMC.1979.4310076")}
divide
s <- rast(system.file("ex/logo.tif", package="terra"))
thresh(s, "mean", as.raster=FALSE)
thresh(s, "mean", combine=TRUE, as.raster=FALSE)
plot(thresh(s, "otsu"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.