Plot an image index
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
)
None
An optional Image
object or an object computed with
image_index()
. If object
is provided, then the input image is obtained
internally.
An object computed with analyze_objects_shp()
. By using this
object you can ignore img
.
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.
Logical value indicating whether to remove the background
when object
is provided. Defaults to TRUE
.
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.
Render all layers when img
is an object computed with
image_index()
and viewer = "mapview"
?.
The layer to plot when img
is an object computed with
image_index()
and viewer = "mapview"
. Defaults to the first layer
(first index computed).
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.
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.
function; if given, downsampling will apply
downsample_fun``
to each of the the subtiles.
The color palette for displaying index values. Default
is custom_palette()
.
The number of rows or columns in the plot grid. Defaults to
NULL
, i.e., a square grid is produced.
Numeric, giving the aspect ratio y/x. Defaults to NA
.
See graphics::plot.window()
for more details.
if(interactive()){
# Example usage:
library(pliman)
img <- image_pliman("sev_leaf.jpg")
plot_index(img, index = "B")
}
Run the code above in your browser using DataLab