Sample a connected patch of cells within an image

patch_subsample(
  cells,
  k.cells = NULL,
  k.pavement = NULL,
  k.stomata = NULL,
  plot.patch = FALSE,
  seed = NULL,
  stom.val = 85,
  subs.val = 170,
  pave.val = 255
)

Arguments

cells

SpatialPolygonsDataFrame of all cells, with edge cells removed.

k.cells

Numeric. Desired number of cells to be sampled in patch

k.pavement

Numeric. Desired number of pavement cells to be sampled in patch

k.stomata

Numeric. Desired number of stomata to be sampled in patch

plot.patch

Logical. Plot the sampling iterations? Defaults to FALSE.

seed

Numeric. For reproducibility, the starting cell can be set using this argument.

stom.val

Numeric vector of length 1. The value of stomatal cells (guard cells + pore)

subs.val

Numeric vector of length 1. The value of subsidiary cells

pave.val

Numeric vector of length 1. The value of pavement cells

Value

A numeric vector containing the indices of the sampled polygons

Details

If setting a seed using the seed argument, cell numbers can be displayed on a plot of the cells using: text(cells, labels = 1:length(cells)).

Examples

if (FALSE)  #
#minimum patch size of 40 cells
patch_subsample(cells, k.cells=40)
#patch must include at least 10 stomatal complexes and 30 pavement cells
patch_subsample(cells,k.pavement=30, k.stomata=10)
#> NULL