utils_objects {pliman}R Documentation

Utilities for working with image objects

Description

Usage

object_coord(
  image,
  id = NULL,
  index = "NB",
  watershed = TRUE,
  invert = FALSE,
  fill_hull = FALSE,
  threshold = "Otsu",
  edge = 2,
  extension = NULL,
  tolerance = NULL,
  object_size = "medium",
  parallel = FALSE,
  workers = NULL,
  show_image = TRUE
)

object_contour(
  image,
  index = "NB",
  invert = FALSE,
  fill_hull = FALSE,
  threshold = "Otsu",
  watershed = TRUE,
  extension = NULL,
  tolerance = NULL,
  object_size = "medium",
  parallel = FALSE,
  workers = NULL,
  show_image = TRUE
)

object_isolate(image, id = NULL, parallel = FALSE, workers = NULL, ...)

object_id(image, parallel = FALSE, workers = NULL, ...)

Arguments

image

An image of class Image or a list of Image objects.

id
  • For object_coord(), a vector (or scalar) of object id to compute the bounding rectangle. Object ids can be obtained with object_id(). Set id = "all" to compute the coordinates for all objects in the image. If id = NULL (default) a bounding rectangle is drawn including all the objects.

  • For object_isolate(), a scalar that identifies the object to be extracted.

index

The index to produce a binary image used to compute bounding rectangle coordinates. See image_binary() for more details.

watershed

If TRUE (default) performs watershed-based object detection. This will detect objects even when they are touching one other. If FALSE, all pixels for each connected set of foreground pixels are set to a unique object. This is faster but is not able to segment touching objects.

invert

Inverts the binary image, if desired. Defaults to FALSE.

fill_hull

Fill holes in the objects? Defaults to FALSE.

threshold

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. Inform any non-numeric value different than "Otsu" to iteratively chosen the threshold based on a raster plot showing pixel intensity of the index.

edge

The number of pixels in the edge of the bounding rectangle. Defaults to 2.

extension, tolerance, object_size

Controls the watershed segmentation of objects in the image. See analyze_objects() for more details.

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 image is a list. The number of sections is set up to 50% of available cores.

workers

A positive numeric scalar or a function specifying the maximum number of parallel processes that can be active at the same time.

show_image

Shows the image with bounding rectangles? Defaults to TRUE.

...

Value

Examples


library(pliman)
img <- image_pliman("la_leaves.jpg")
# Get the object's (leaves) identification
object_id(img)

# Get the coordinates and draw a bounding rectangle around leaves 1 and 3
object_coord(img, id = c(1, 3))

# Isolate leaf 3
isolated <- object_isolate(img, id = 3)
plot(isolated)



[Package pliman version 1.1.0 Index]