measure_disease {pliman} | R Documentation |
Performs plant disease measurements
Description
-
measure_disease()
computes the percentage of symptomatic leaf area and (optionally) counts and compute shapes (area, perimeter, radius, etc.) of lesions in a sample or entire leaf using color palettes. See more at Details. -
measure_disease_iter()
provides an iterative section formeasure_disease()
, where the user picks up samples in the image to create the needed color palettes.
Usage
measure_disease(
img,
img_healthy = NULL,
img_symptoms = NULL,
img_background = NULL,
pattern = NULL,
filter = 10,
parallel = FALSE,
workers = NULL,
resize = FALSE,
fill_hull = TRUE,
index_lb = NULL,
index_dh = "GLI",
has_white_bg = FALSE,
threshold = NULL,
invert = FALSE,
lower_size = NULL,
upper_size = NULL,
topn_lower = NULL,
topn_upper = NULL,
randomize = TRUE,
nsample = 3000,
watershed = FALSE,
lesion_size = "medium",
tolerance = NULL,
extension = NULL,
show_features = FALSE,
show_segmentation = FALSE,
plot = TRUE,
show_original = TRUE,
show_background = TRUE,
show_contour = TRUE,
contour_col = "white",
contour_size = 1,
col_leaf = NULL,
col_lesions = NULL,
col_background = NULL,
marker = FALSE,
marker_col = NULL,
marker_size = NULL,
save_image = FALSE,
prefix = "proc_",
name = NULL,
dir_original = NULL,
dir_processed = NULL,
verbose = TRUE
)
measure_disease_iter(
img,
has_background = TRUE,
r = 2,
viewer = get_pliman_viewer(),
show = "rgb",
index = "NGRDI",
...
)
Arguments
img |
The image to be analyzed. |
img_healthy |
A color palette of healthy tissues. |
img_symptoms |
A color palette of lesioned tissues. |
img_background |
A color palette of the background (if exists). These
arguments can be either an |
pattern |
A pattern of file name used to identify images to be
processed. For example, if |
filter |
Performs median filtering in the binary image that segments the
leaf from background? By default, a median filter of |
parallel |
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 |
workers |
A positive numeric scalar or a function specifying the maximum number of parallel processes that can be active at the same time. |
resize |
Resize the image before processing? Defaults to |
fill_hull |
Fill holes in the image? Defaults to |
index_lb |
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. |
index_dh |
The index used to segment diseased from healthy tissues when
|
has_white_bg |
Logical indicating whether a white background is present.
If |
threshold |
By default ( |
invert |
Inverts the binary image if desired. This is useful to process
images with black background. Defaults to |
lower_size |
Lower limit for size for the image analysis. Leaf images
often contain dirt and dust. To prevent dust from affecting the image
analysis, the lower limit of analyzed size is set to 0.1, i.e., objects
with lesser than 10% of the mean of all objects are removed. One can set a
known area or use |
upper_size |
Upper limit for size for the image analysis. Defaults to
|
topn_lower , topn_upper |
Select the top |
randomize |
Randomize the lines before training the model? Defaults to
|
nsample |
The number of sample pixels to be used in training step.
Defaults to |
watershed |
If |
lesion_size |
The size of the lesion. Used to automatically tune
|
tolerance |
The minimum height of the object in the units of image
intensity between its highest point (seed) and the point where it contacts
another object (checked for every contact pixel). If the height is smaller
than the tolerance, the object will be combined with one of its neighbors,
which is the highest. Defaults to |
extension |
Radius of the neighborhood in pixels for the detection of neighboring objects. Defaults to 20. Higher value smooths out small objects. |
show_features |
If |
show_segmentation |
Shows the object segmentation colored with random
permutations. Defaults to |
plot |
Show image after processing? Defaults to |
show_original |
Show the symptoms in the original image? |
show_background |
Show the background? Defaults to |
show_contour |
Show a contour line around the lesions? Defaults
to |
contour_col , contour_size |
The color and size for the contour line
around objects. Defaults to |
col_leaf |
Leaf color after image processing. Defaults to |
col_lesions |
Symptoms color after image processing. Defaults to
|
col_background |
Background color after image processing. Defaults to
|
marker , marker_col , marker_size |
The type, color and size of the object
marker. Defaults to |
save_image |
Save the image after processing? The image is saved in the
current working directory named as |
prefix |
The prefix to be included in the processed images. Defaults to
|
name |
The name of the image to save. Use this to overwrite the name of
the image in |
dir_original , dir_processed |
The directory containing the original and
processed images. Defaults to |
verbose |
If |
has_background |
A logical indicating if the image has a background to be segmented before processing. |
r |
The radius of neighborhood pixels. Defaults to |
viewer |
The viewer option. If not provided, the value is retrieved
using |
show |
The show option for the mapview viewer, either |
index |
The index to be shown when |
... |
Further parameters passed on to |
Details
In measure_disease()
, a general linear model (binomial family) fitted to
the RGB values is used to segment the lesions from the healthy leaf. If a
pallet of background is provided, the function takes care of the details to
isolate it before computing the number and area of lesions. By using pattern
it is possible to process several images with common pattern names that are
stored in the current working directory or in the subdirectory informed in
dir_original
.
If img_healthy
and img_symptoms
are not declared, RGB-based phenotyping of
foliar disease severity is performed using the index informed in index_lb
to
first segment leaf from background and index_dh
to segment diseased from
healthy tissues.
measure_disease_iter()
only run in an interactive section. In this function,
users will be able to pick up samples of images to iteratively create the
needed color palettes. This process calls pick_palette()
internally. If
has_background
is TRUE (default) the color palette for the background is
first created. The sample of colors is performed in each left-button mouse
click and continues until the user press Esc. Then, a new sampling process is
performed to sample the color of healthy tissues and then diseased tissues.
The generated palettes are then passed on to measure_disease(). All the
arguments of such function can be passed using the ... (three dots).
When show_features = TRUE
, the function computes a total of 36 lesion
features (23 shape features and 13 texture features). The Haralick texture
features for each object based on a gray-level co-occurrence matrix (Haralick
et al. 1979). See more details in analyze_objects()
.
Value
-
measure_disease()
returns a list with the following objects:-
severity
A data frame with the percentage of healthy and symptomatic areas. -
shape
,statistics
Ifshow_features = TRUE
is used, returns the shape (area, perimeter, etc.) for each lesion and a summary statistic of the results.
-
-
measure_disease_iter()
returns a list with the following objects:-
results
A list with the objects returned bymeasure_disease()
. -
leaf
The color palettes for the healthy leaf. -
disease
The color palettes for the diseased leaf. -
background
The color palettes for the background.
-
Author(s)
Tiago Olivoto tiagoolivoto@gmail.com
Examples
library(pliman)
img <- image_pliman("sev_leaf_nb.jpg")
healthy <- image_pliman("sev_healthy.jpg")
lesions <- image_pliman("sev_sympt.jpg")
image_combine(img, healthy, lesions, ncol = 3)
sev <-
measure_disease(img = img,
img_healthy = healthy,
img_symptoms = lesions,
lesion_size = "large",
plot = TRUE)
# an interactive section
measure_disease_iter(img)