image_binary | R Documentation |
Reduce a color, color near-infrared, or grayscale images to a binary image using a given color channel (red, green blue) or even color indexes. The Otsu's thresholding method (Otsu, 1979) is used to automatically perform clustering-based image thresholding.
image_binary(
img,
index = "R",
r = 1,
g = 2,
b = 3,
re = 4,
nir = 5,
return_class = "ebimage",
threshold = c("Otsu", "adaptive"),
k = 0.1,
windowsize = NULL,
has_white_bg = FALSE,
resize = FALSE,
fill_hull = FALSE,
filter = FALSE,
invert = FALSE,
plot = TRUE,
nrow = NULL,
ncol = NULL,
parallel = FALSE,
workers = NULL,
verbose = TRUE
)
img |
An image object. |
index |
A character value (or a vector of characters) specifying the
target mode for conversion to binary image. See the available indexes with
|
r, g, b, re, nir |
The red, green, blue, red-edge, and near-infrared bands of the image, respectively. Defaults to 1, 2, 3, 4, and 5, respectively. If a multispectral image is provided (5 bands), check the order of bands, which are frequently presented in the 'BGR' format. |
return_class |
The class of object to be returned. If |
threshold |
The theshold method to be used.
|
k |
a numeric in the range 0-1. when |
windowsize |
windowsize controls the number of local neighborhood in
adaptive thresholding. By default it is set to |
has_white_bg |
Logical indicating whether a white background is present.
If |
resize |
Resize the image before processing? Defaults to |
fill_hull |
Fill holes in the objects? Defaults to |
filter |
Performs median filtering in the binary image? (Defaults to
|
invert |
Inverts the binary image, if desired. |
plot |
Show image after processing? |
nrow, ncol |
The number of rows or columns in the plot grid. Defaults to
|
parallel |
Processes the images asynchronously (in parallel) in separate
R sessions running in the background on the same machine. It may speed up
the processing time when |
workers |
A positive numeric scalar or a function specifying the maximum number of parallel processes that can be active at the same time. |
verbose |
If |
A list containing binary images. The length will depend on the number of indexes used.
Tiago Olivoto tiagoolivoto@gmail.com
Otsu, N. 1979. Threshold selection method from gray-level histograms. IEEE Trans Syst Man Cybern SMC-9(1): 62–66. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1109/tsmc.1979.4310076")}
Shafait, F., D. Keysers, and T.M. Breuel. 2008. Efficient implementation of local adaptive thresholding techniques using integral images. Document Recognition and Retrieval XV. SPIE. p. 317–322 \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1117/12.767755")}
library(pliman)
img <- image_pliman("soybean_touch.jpg")
image_binary(img, index = c("R, G"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.