# NOT RUN {
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)
# }
Run the code above in your browser using DataLab