Skip to contents

Using threshold-based segmentation, objects are first isolated from background. Then, a new image is created for each single object. A list of images is returned.

Usage

object_split(
  img,
  index = "NB",
  lower_size = NULL,
  watershed = TRUE,
  invert = FALSE,
  fill_hull = FALSE,
  opening = 3,
  closing = FALSE,
  filter = FALSE,
  erode = FALSE,
  dilate = FALSE,
  threshold = "Otsu",
  extension = NULL,
  tolerance = NULL,
  object_size = "medium",
  edge = 3,
  remove_bg = FALSE,
  plot = TRUE,
  verbose = TRUE,
  ...
)

Arguments

img

The image to be analyzed.

index

A character value specifying the index for conversion to binary image.

lower_size

Plant images often contain dirt and dust. To prevent dust from affecting the image analysis, objects with lesser than 10% of the mean of all objects are removed. Set lower_limit = 0 to keep all the objects.

watershed

If TRUE (default) performs watershed-based object detection.

invert

Inverts the binary image if desired.

fill_hull

Fill holes in the binary image? Defaults to FALSE.

opening, closing, filter, erode, dilate

Morphological operations (brush size), applied in hierarchical order.

threshold

The threshold method ("Otsu", "Adaptive", or numeric).

extension

Neighborhood radius for watershed segmentation.

tolerance

Minimum height for watershed segmentation.

object_size

The size of the object ("small", "medium", "large", "elarge"). Used to automatically set up tolerance and extension parameters.

edge

The number of pixels to be added in the edge of the segmented object. Defaults to 5.

remove_bg

If TRUE, the pixels that are not part of objects are converted to white.

plot

Show image after processing?

verbose

If TRUE (default) shows progress summary in console.

...

Additional arguments passed on to image_combine()

Value

A list of objects of class image.

Examples

if (FALSE) { # interactive()
library(pliman)
img <- image_pliman("la_leaves.jpg", plot = TRUE)
imgs <- object_split(img) # set to NULL to use 50% of the cores
}