Computes the percentage of symptomatic leaf area using color palettes or RGB
indexes by each leaf of an image. This allows, for example, processing
replicates of the same treatment and obtaining the results for each
replication with a single image. To do that, leaf samples are first splitten
with object_split() and then, measure_disease() is applied to the list of
leaves.
Usage
measure_disease_byl(
img,
index = "B",
index_lb = "B",
index_dh = "NGRDI",
lower_size = NULL,
watershed = TRUE,
invert = FALSE,
fill_hull = FALSE,
opening = c(10, 0),
closing = c(0, 0),
filter = c(0, 0),
erode = c(0, 0),
dilate = c(0, 0),
threshold = "Otsu",
extension = NULL,
tolerance = NULL,
object_size = "large",
img_healthy = NULL,
img_symptoms = NULL,
plot = TRUE,
save_image = FALSE,
dir_original = NULL,
dir_processed = NULL,
pattern = NULL,
parallel = FALSE,
workers = NULL,
show_features = FALSE,
verbose = TRUE,
...
)Arguments
- img
The image to be analyzed.
- index
A character value specifying the target mode for conversion to binary to segment the leaves from background. Defaults to "B" (blue). See
image_index()for more details. Personalized indexes can be informed as, e.g.,index = "R*G/B.- 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
img_healthyandimg_symptomsare not declared. Defaults to"GLI". Seeimage_index()for more details.- lower_size
To prevent dust from affecting object segmentation, objects with lesser than
10%of the mean of all objects are removed. . One can set a known area or uselower_limit = 0to select all objects (not advised).- watershed
If
TRUE(default) performs watershed-based object detection.- invert
Inverts the binary image if desired.
- fill_hull
Fill holes in the binary image? Defaults to
FALSE.- opening, closing, filter, erode, dilate
Morphological operations (brush size), applied in hierarchical order.
- threshold
The threshold method (
"Otsu","Adaptive", or numeric).- extension
Neighborhood radius for watershed segmentation.
- tolerance
Minimum height for watershed segmentation.
- object_size
The size of the object (
"small","medium","large","elarge"). Used to automatically set uptoleranceandextensionparameters.- img_healthy
A color palette of healthy tissues.
- img_symptoms
A color palette of lesioned tissues.
- plot
Show image after processing?
- save_image
Save the image after processing? The image is saved in the current working directory named as
proc_*where*is the image name given inimg.- dir_original, dir_processed
The directory containing the original and processed images. Defaults to
NULL. In this case, the function will search for the imageimgin the current working directory. After processing, whensave_image = TRUE, the processed image will be also saved in such a directory. It can be either a full path, e.g.,"C:/Desktop/imgs", or a subfolder within the current working directory, e.g.,"/imgs".- pattern
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.- 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
patternis used is informed. The number of sections is set up to 30% of available cores.- workers
A positive numeric scalar or a function specifying the maximum number of parallel processes that can be active at the same time.
- show_features
If
TRUEreturnS the lesion features such as number, area, perimeter, and radius. Defaults toFALSE.- verbose
If
TRUE(default) shows progress summary in console.- ...
Additional arguments passed on to
measure_disease().
Value
A list with the following objects:
severityA data frame with the percentage of healthy and symptomatic areas for each leaf in the image(s).shape,statisticsIfshow_features = TRUEis used, returns the shape (area, perimeter, etc.) for each lesion and a summary statistic of the results.
Examples
if (FALSE) { # interactive()
library(pliman)
img <- image_pliman("mult_leaves.jpg", plot = TRUE)
sev <-
measure_disease_byl(img = img,
index_lb = "B",
index_dh = "NGRDI",
workers = 2)
sev$severity
}
