Skip to contents

Givin an image with multiple objects, object_export() will split the objects into a list of objects using object_split() and then export them to multiple images into the current working directory (or a subfolder). Batch processing is performed by declaring a file name pattern that matches the images within the working directory.

Usage

object_export(
  img,
  pattern = NULL,
  dir_original = NULL,
  dir_processed = NULL,
  format = ".jpg",
  squarize = FALSE,
  augment = FALSE,
  times = 12,
  index = "NB",
  lower_size = NULL,
  watershed = FALSE,
  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 = 20,
  remove_bg = FALSE,
  parallel = FALSE,
  workers = NULL,
  verbose = TRUE
)

Arguments

img

The image to be analyzed.

pattern

A pattern of file name used to identify images to be processed. For example, if pattern = "im" all images in the current working directory that the name matches the pattern (e.g., img1.-, image1.-, im2.-) will be imported and processed. Providing any number as pattern (e.g., pattern = "1") will select images that are named as 1.-, 2.-, and so on. An error will be returned if the pattern matches any file that is not supported (e.g., img1.pdf).

dir_original

The directory containing the original images. Defaults to NULL. It can be either a full path, e.g., "C:/Desktop/imgs", or a subfolder within the current working directory, e.g., "/imgs".

dir_processed

Optional character string indicating a subfolder within the current working directory to save the image(s). If the folder doesn't exist, it will be created.

format

The format of image to be exported.

squarize

Squarizes the image before the exportation? If TRUE, image_square() will be called internally.

augment

A logical indicating if exported objects should be augmented using image_augment(). Defaults to FALSE.

times

The number of times to rotate the image.

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.

parallel

If TRUE processes the images asynchronously in parallel.

workers

Number of parallel processes.

verbose

If TRUE (default) shows progress summary in console.

Value

A NULL object.

Examples

if (FALSE) { # interactive()
library(pliman)
img <- image_pliman("potato_leaves.jpg")
object_export(img,
              remove_bg = TRUE)
}