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, threshold = c("Otsu", "adaptive"), k = 0.1, windowsize = NULL, col_background = NULL, has_white_bg = FALSE, fill_hull = FALSE, filter = FALSE, re = NULL, nir = NULL, 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, ... )
An image object or a list of image objects.
image_segment(), a character value (or a vector of characters) specifying the target mode for conversion to binary image. See the available indexes with
image_index()for more details.
image_segment_iter()a character or a vector of characters with the same length of
nseg. It can be either an available index (described above) or any operation involving the RGB values (e.g.,
The theshold method to be used.
By default (
threshold = "Otsu"), a threshold value based on Otsu's method is used to reduce the grayscale image to a binary image. If a numeric value is informed, this value will be used as a threshold.
threshold = "adaptive", adaptive thresholding (Shafait et al. 2008) is used, and will depend on the
If any non-numeric value different than
"adaptive"is used, an iterative section will allow you to choose the threshold based on a raster plot showing pixel intensity of the index.
a numeric in the range 0-1. when
kis high, local threshold values tend to be lower. when
kis low, local threshold value tend to be higher.
windowsize controls the number of local neighborhood in adaptive thresholding. By default it is set to
1/3 * minxy, where
minxyis the minimum dimension of the image (in pixels).
The color of the segmented background. Defaults to
Logical indicating whether a white background is present. If
TRUE, pixels that have R, G, and B values equals to 1 will be considered as
NA. This may be useful to compute an image index for objects that have, for example, a white background. In such cases, the background will not be considered for the threshold computation.
Fill holes in the objects? Defaults to
Performs median filtering in the binary image? See more at
image_filter(). Defaults to
FALSE. Use a positive integer to define the size of the median filtering. Larger values are effective at removing noise, but adversely affect edges.
Respective position of the red-edge band at the original image file.
Respective position of the near-infrared band at the original image file.
Inverts the binary image, if desired. For
image_segmentation_iter()use a vector with the same length of
Show image after processing?
- nrow, ncol
The number of rows or columns in the plot grid. Defaults to
NULL, i.e., a square grid is produced.
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
imageis a list. The number of sections is set up to 70% of available cores.
A positive numeric scalar or a function specifying the maximum number of parallel processes that can be active at the same time.
TRUE(default) a summary is shown in the console.
The number of iterative segmentation steps to be performed.
Additional arguments passed on to
image_segment()returns list containing
nis the number of indexes used. Each objects contains:
imagean image with the RGB bands (layers) for the segmented object.
maskA 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.
Nobuyuki Otsu, "A threshold selection method from gray-level histograms". IEEE Trans. Sys., Man., Cyber. 9 (1): 62-66. 1979. doi:10.1109/TSMC.1979.4310076
Tiago Olivoto firstname.lastname@example.org