image_segment | R Documentation |
image_segment()
reduces a color, color near-infrared, or grayscale images
to a segmented image using a given color channel (red, green blue) or even
color indexes (See image_index()
for more details). The Otsu's thresholding
method (Otsu, 1979) is used to automatically perform clustering-based image
thresholding.
image_segment_iter()
Provides an iterative image segmentation, returning
the proportions of segmented pixels.
image_segment(
img,
index = NULL,
r = 1,
g = 2,
b = 3,
re = 4,
nir = 5,
threshold = c("Otsu", "adaptive"),
k = 0.1,
windowsize = NULL,
col_background = NULL,
has_white_bg = FALSE,
fill_hull = FALSE,
filter = FALSE,
invert = FALSE,
plot = TRUE,
nrow = NULL,
ncol = NULL,
parallel = FALSE,
workers = NULL,
verbose = TRUE
)
image_segment_iter(
img,
nseg = 2,
index = NULL,
invert = NULL,
threshold = NULL,
k = 0.1,
windowsize = NULL,
has_white_bg = FALSE,
plot = TRUE,
verbose = TRUE,
nrow = NULL,
ncol = NULL,
parallel = FALSE,
workers = NULL,
...
)
img |
An image object or a list of image objects. |
index |
|
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. |
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 |
col_background |
The color of the segmented background. Defaults to
|
has_white_bg |
Logical indicating whether a white background is present.
If |
fill_hull |
Fill holes in the objects? Defaults to |
filter |
Performs median filtering in the binary image? See more at
|
invert |
Inverts the binary image, if desired. For
|
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 |
nseg |
The number of iterative segmentation steps to be performed. |
... |
Additional arguments passed on to |
image_segment()
returns list containing n
objects where n
is the
number of indexes used. Each objects contains:
image
an image with the RGB bands (layers) for the segmented object.
mask
A mask with logical values of 0 and 1 for the segmented image.
image_segment_iter()
returns a list with (1) a data frame with the
proportion of pixels in the segmented images and (2) the segmented images.
Tiago Olivoto tiagoolivoto@gmail.com
Nobuyuki Otsu, "A threshold selection method from gray-level histograms". IEEE Trans. Sys., Man., Cyber. 9 (1): 62-66. 1979. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1109/TSMC.1979.4310076")}
library(pliman)
img <- image_pliman("soybean_touch.jpg", plot = TRUE)
image_segment(img, index = c("R, G, B"))
# adaptive thresholding
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.