image_binary {pliman}R Documentation

Creates a binary image

Description

Reduce a color, color near-infrared, or grayscale images to a binary image using a given color channel (red, green blue) or even color indexes. The Otsu's thresholding method (Otsu, 1979) is used to automatically perform clustering-based image thresholding.

Usage

image_binary(
  image,
  index = NULL,
  my_index = NULL,
  threshold = "Otsu",
  resize = 30,
  fill_hull = FALSE,
  re = NULL,
  nir = NULL,
  invert = FALSE,
  show_image = TRUE,
  nrow = NULL,
  ncol = NULL,
  parallel = FALSE,
  workers = NULL,
  verbose = TRUE
)

Arguments

image

An image object.

index

A character value (or a vector of characters) specifying the target mode for conversion to binary image. See the available indexes with pliman_indexes() and image_index() for more details.

my_index

User can calculate a different index using the band names, e.g. my_index = "R+B/G".

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.

resize

Resize the image before processing? Defaults to FALSE. Use a numeric value as the percentage of desired resizing. For example, if resize = 30, the resized image will have 30% of the size of original image.

fill_hull

Fill holes in the objects? Defaults to FALSE.

re

Respective position of the red-edge band at the original image file.

nir

Respective position of the near-infrared band at the original image file.

invert

Inverts the binary image, if desired.

show_image

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.

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 70% 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.

verbose

If TRUE (default) a summary is shown in the console.

Value

A list containing binary images. The length will depend on the number of indexes used.

Author(s)

Tiago Olivoto tiagoolivoto@gmail.com

References

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

Examples

library(pliman)
img <- image_pliman("soybean_touch.jpg")
image_binary(img, index = c("R, G"))

[Package pliman version 1.1.0 Index]