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 = 1e+06,
downsample = NULL,
downsample_fun = NULL,
color_regions = custom_palette(n = 100),
ncol = NULL,
nrow = NULL,
aspect_ratio = NA
)
Arguments
- img
An optional
Image
object or an object computed withimage_index()
. Ifobject
is provided, then the input image is obtained internally.- object
An object computed with
analyze_objects()
using the argumentreturn_mask = TRUE
.- index
The index to plot. Defaults to the index computed from the
object
if provided. Otherwise, theB
index is computed. Seeimage_index()
for more details.- remove_bg
Logical value indicating whether to remove the background when
object
is provided. Defaults toTRUE
.- 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 theset_pliman_viewer()
function. For example, you can runset_pliman_viewer("mapview")
to set the viewer option to "mapview" for all functions.- all_layers
Render all layers when
img
is an object computed withimage_index()
andviewer = "mapview"
?.- layer
The layer to plot when
img
is an object computed withimage_index()
andviewer = "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 themax_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
. Seegraphics::plot.window()
for more details.
Examples
if (interactive() && requireNamespace("EBImage")) {
# Example usage:
library(pliman)
img <- image_pliman("sev_leaf.jpg")
plot_index(img, index = c("R", "G"))
}