mosaic_segment_pick: Segments a mosaic interactively

View source: R/utils_mosaic.R

mosaic_segment_pickR Documentation

Segments a mosaic interactively

Description

The function segments a mosaic using an interative process where the user picks samples from background (eg., soil) and foreground (eg., plants).

Usage

mosaic_segment_pick(
  mosaic,
  basemap = NULL,
  g = 2,
  r = 3,
  b = 1,
  max_pixels = 2e+06,
  downsample = NULL,
  quantiles = c(0, 1),
  return = c("mosaic", "mask")
)

Arguments

mosaic

A mosaic of class SpatRaster, generally imported with mosaic_input().

basemap

An optional mapview object.

r, g, b

The layer for the Red, Green and Blue band, respectively. Defaults to 1, 2, and 3.

max_pixels

Maximum number of pixels to render in the map or plot (default: 500000).

downsample

Downsampling factor to reduce the number of pixels (default: NULL). In this case, if the number of pixels in the image (width x height) is greater than max_pixels a downsampling factor will be automatically chosen so that the number of plotted pixels approximates the max_pixels.

quantiles

the upper and lower quantiles used for color stretching.

return

The output of the function. Either 'mosaic' (the segmented mosaic), or 'mask' (the binary mask).

Value

An SpatRaster object with the segmented mosaic (if return = 'mosaic') or a mask (if return = 'mask').

Examples

if(interactive()){
 mosaic <- mosaic_input(system.file("ex/elev.tif", package="terra"))
 seg <- mosaic_segment_pick(mosaic)
 mosaic_plot(seg)
}

TiagoOlivoto/pliman documentation built on Sept. 14, 2024, 2:24 a.m.