This function calls measure_disease()
in each image polygon of a shapefile
object generated with image_shp()
and bind the results into read-ready data
frames.
measure_disease_shp(
img,
nrow = 1,
ncol = 1,
buffer_x = 0,
buffer_y = 0,
prepare = FALSE,
viewer = "mapview",
index_lb = "HUE2",
index_dh = "NGRDI",
pattern = NULL,
threshold = NULL,
invert = FALSE,
dir_original = NULL,
show_features = FALSE,
interactive = FALSE,
plot = TRUE,
parallel = FALSE,
workers = NULL,
verbose = TRUE,
...
)
An object of class plm_disease_byl
. See more details in the Value
section of measure_disease()
.
The image to be analyzed. Either an image of class Image
or a
character string containing the image name. In the last, the image will be
searched in the root directory. Declare dir_original to inform a subfolder
that contains the images to be processed.
The number of rows and columns to generate the shapefile.
Defaults to 1
.
Buffering factor for the width and height, respectively, of each individual shape's side. A value between 0 and 0.5 where 0 means no buffering and 0.5 means complete buffering (default: 0). A value of 0.25 will buffer the shape by 25% on each side.
Logical value indicating whether to prepare the image for
analysis using image_prepare()
function. This allows to align and crop
the image before processing. Defaults to FALSE
.
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.
The index used to segment the foreground (e.g., leaf) from the background. If not declared, the entire image area (pixels) will be considered in the computation of the severity.
The index used to segment diseased from healthy tissues when
img_healthy
and img_symptoms
are not declared. Defaults to "GLI"
. See
image_index()
for more details.
A pattern of file name used to identify images to be
processed. For example, if pattern = "im"
all images that the name
matches the pattern (e.g., img1.-, image1.-, im2.-) will be analyzed.
Providing any number as pattern (e.g., pattern = "1"
) will select
images that are named as 1.-, 2.-, and so on.
By default (threshold = NULL
), a threshold value based on
Otsu's method is used to reduce the grayscale image to a binary image. If a
numeric value is informed, this value will be used as a threshold. Inform
any non-numeric value different than "Otsu" to iteratively choose the
threshold based on a raster plot showing pixel intensity of the index. Must
be a vector of length 2 to indicate the threshold for index_lb
and
index_dh
, respectively.
Inverts the binary image if desired. This is useful to process
images with black background. Defaults to FALSE
.
The directory containing the original and processed images.
Defaults to NULL
. In this case, the function will search for the image img
in the
current working directory.
If TRUE
returnS the lesion features such as number,
area, perimeter, and radius. Defaults to FALSE
.
If FALSE
(default) the grid is created automatically
based on the image dimension and number of rows/columns. If interactive = TRUE
, users must draw points at the diagonal of the desired bounding box
that will contain the grid.
Show image after processing? Defaults to TRUE
.
Processes the images asynchronously (in parallel) in separate
R sessions running in the background on the same machine. It may speed up
the processing time, especially when pattern
is used is informed. The
number of sections is set up to 30% of available cores.
A positive numeric scalar or a function specifying the maximum number of parallel processes that can be active at the same time.
If TRUE
(default) a summary is shown in the console.
Aditional arguments passed on to measure_disease.
if(interactive()){
# severity for the three leaflets (from left to right)
img <- image_pliman("mult_leaves.jpg", plot = TRUE)
sev <-
measure_disease_shp(img = img,
nrow = 1,
ncol = 3,
index_lb = "B",
index_dh = "NGRDI")
sev$severity
}
Run the code above in your browser using DataLab