This function allows users to interactively edit and analyze an image using mapview and mapedit packages.
Usage
image_view(
img,
object = NULL,
r = 1,
g = 2,
b = 3,
edit = FALSE,
alpha = 0.7,
attribute = "area",
title = "Edit the image",
show = c("rgb", "index"),
index = "B",
max_pixels = 1e+06,
downsample = NULL,
color_regions = custom_palette(),
quantiles = c(0, 1),
...
)
Arguments
- img
An
Image
object.- object
(Optional). An object computed with
analyze_objects()
. If an object is informed, an additional layer is added to the plot, showing the contour of the analyzed objects, with a color gradient defined byattribute
.- r, g, b
The layer for the Red, Green and Blue band, respectively. Defaults to
1
,2
, and3
.- edit
If
TRUE
enable editing options usingmapedit::editMap()
.- alpha
The transparency level of the rectangles' color (between 0 and 1).
- attribute
The name of the quantitative variable in the
object_index
to be used for coloring the rectangles.- title
The title of the map view. Use to provide short orientations to the user.
- show
The display option for the map view. Options are "rgb" for RGB view and "index" for index view.
- index
The index to use for the index view. Defaults to "B".
- max_pixels
integer > 0. Maximum number of cells to use for the plot. If
max_pixels < npixels(img)
, regular sampling is used before plotting.- 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.- color_regions
The color palette for displaying index values. Default is
custom_palette()
.- quantiles
the upper and lower quantiles used for color stretching. Set to
c(0, 1)
- ...
Additional arguments to be passed to
downsample_fun
.
Value
An sf
object, the same object returned by mapedit::editMap()
.
Examples
if (interactive() && requireNamespace("EBImage")) {
# Example usage:
img <- image_pliman("sev_leaf.jpg")
image_view(img)
}