Skip to contents

Plot an image index

Usage

plot_index(
  img = NULL,
  object = NULL,
  index = NULL,
  remove_bg = TRUE,
  viewer = get_pliman_viewer(),
  all_layers = TRUE,
  layer = 1,
  max_pixels = 5e+05,
  downsample = NULL,
  downsample_fun = NULL,
  color_regions = custom_palette(),
  ncol = NULL,
  nrow = NULL,
  aspect_ratio = NA
)

Arguments

img

An optional Image object or an object computed with image_index(). If object is provided, then the input image is obtained internally.

object

An object computed with analyze_objects_shp(). By using this object you can ignore img.

index

The index to plot. Defaults to the index computed from the object if provided. Otherwise, the B index is computed. See image_index() for more details.

remove_bg

Logical value indicating whether to remove the background when object is provided. Defaults to TRUE.

viewer

The viewer option. If not provided, the value is retrieved using get_pliman_viewer(). This option controls the type of viewer to use for interactive plotting. The available options are "base" and "mapview". If set to "base", the base R graphics system is used for interactive plotting. If set to "mapview", the mapview package is used. To set this argument globally for all functions in the package, you can use the set_pliman_viewer() function. For example, you can run set_pliman_viewer("mapview") to set the viewer option to "mapview" for all functions.

all_layers

Render all layers when img is an object computed with image_index() and viewer = "mapview"?.

layer

The layer to plot when img is an object computed with image_index() and viewer = "mapview". Defaults to the first layer (first index computed).

max_pixels

integer > 0. Maximum number of cells to plot the index. If max_pixels < npixels(img), downsampling is performed before plotting the index. Using a large number of pixels may slow down the plotting time.

downsample

integer; for each dimension the number of pixels/lines/bands etc that will be skipped; Defaults to NULL, which will find the best downsampling factor to approximate the max_pixels value.

downsample_fun

function; if given, downsampling will apply downsample_fun`` to each of the the subtiles.

color_regions

The color palette for displaying index values. Default is custom_palette().

nrow, ncol

The number of rows or columns in the plot grid. Defaults to NULL, i.e., a square grid is produced.

aspect_ratio

Numeric, giving the aspect ratio y/x. Defaults to NA. See graphics::plot.window() for more details.

Value

None

Examples

if(interactive()){
# Example usage:
library(pliman)
img <- image_pliman("sev_leaf.jpg")
plot_index(img, index = "B")
}