image_otsu {image.Otsu} | R Documentation |
An implementation of the Otsu's image segmentation algorithm explained at https://doi.org/10.5201/ipol.2016.158.
image_otsu(x, threshold = 0)
x |
an object of class magick-image or a greyscale matrix of image pixel values in the 0-255 range |
threshold |
integer value in range of 0-255. To override the threshold. Defaults to 0 indicating not to override the threshold. |
A list with elements threshold and img containing the thresholded image (which is of class magick-image
or of class matrix depending on the class of x
)
library(magick) path <- system.file(package="image.Otsu", "extdata", "coins.jpeg") x <- image_read(path) x img <- image_otsu(x) img img <- image_otsu(x, threshold = 180) img img <- image_data(x, channels = "gray") img <- as.integer(img) img <- img[, , 1] img <- image_otsu(img) str(img)