| Title: | Otsu's Image Segmentation Method |
|---|---|
| Description: | An implementation of the Otsu's Image Segmentation Method described in the paper: "A C++ Implementation of Otsu's Image Segmentation Method". The algorithm is explained at <doi:10.5201/ipol.2016.158>. |
| Authors: | Jan Wijffels [aut, cre, cph] (R wrapper), BNOSAC [cph] (R wrapper), Juan Pablo Balarini [ctb, cph] (Otsu C++ code), Sergio Nesmachnow [ctb, cph] (Otsu C++ code) |
| Maintainer: | Jan Wijffels <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-05-26 07:11:09 UTC |
| Source: | https://github.com/bnosac/image |
An implementation of the Otsu's image segmentation algorithm explained at doi:10.5201/ipol.2016.158.
image_otsu(x, threshold = 0)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. |
In case x is a matrix, a list with elements x (containing the thresholded image) and threshold is returned
In case x is a magick-image, the thresholded magick-image is returned alongside
which also now has an attribute called threshold with the exact Otsu threshold value
library(magick) path <- system.file(package="image.Otsu", "extdata", "coins.jpeg") x <- image_read(path) x img <- image_otsu(x) img attr(img, "threshold") img <- image_otsu(x, threshold = 180) img img <- image_data(x, channels = "gray") img <- as.integer(img, transpose = TRUE) img <- img[, , 1] img <- image_otsu(img) str(img)library(magick) path <- system.file(package="image.Otsu", "extdata", "coins.jpeg") x <- image_read(path) x img <- image_otsu(x) img attr(img, "threshold") img <- image_otsu(x, threshold = 180) img img <- image_data(x, channels = "gray") img <- as.integer(img, transpose = TRUE) img <- img[, , 1] img <- image_otsu(img) str(img)