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 TRUE the layers of x are combined to compute a single threshold
as.raster: logical. If TRUE a classified SpatRaster is returned. Otherwise the threshold(s) are returned
filename: character. Output filename
...: additional arguments for writing files as in writeRaster
Returns
numeric or SpatRaster
References
Otsu, N. (1979). A Threshold Selection Method from Gray-Level Histograms. IEEE Transactions on Systems, Man, and Cybernetics, 9(1) , 62-66. tools:::Rd_expr_doi("10.1109/TSMC.1979.4310076")
See Also
divide
Examples
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"))