Skip to content

Research on plant leaf diseases requires the acquisition of quantitative data to characterize the symptoms caused by different pathogens. These symptoms are frequently lesions that are differentiated from the leaf blade by their color and texture. Among the variables used to characterize the impact of a disease, the most relevant are the number …

License

Notifications You must be signed in to change notification settings

sravel/LeAFtool_R

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeAFtool Logo

Table of Contents

About this package

⚠️ WARNING
This package is no longer maintained. Maintaining R updates is too complicated and libraries do not backward compatibility.

Research on plant leaf diseases requires the acquisition of quantitative data to characterize the symptoms caused by different pathogens. These symptoms are frequently lesions that are differentiated from the leaf blade by their color and texture. Among the variables used to characterize the impact of a disease, the most relevant are the number of lesions per unit of leaf area, the area and the shape of the lesions. Since visual measurements are only possible on small numbers of images, it is necessary to use computerized image analysis procedures.

Existing procedures can partially meet the needs but are not always adapted to the particularities of the images obtained in the laboratory. From a scanned image under laboratory conditions containing several leaves of plants showing symptoms of a known disease, the algorithm developed makes it possible to obtain for each sheet of the image the number and the characteristics of surface and shape. lesions.

The method used is based on a supervised classification of the pixels characterized by the intensities of the red, green, blue channels. The learning set, made from a reference image, contains samples of the three classes: background, limb and lesions, each class can be subdivided into subclasses to improve the accuracy of the detection. Several methods of supervised classification can be used (discriminant factorial analysis, neural networks, machine vector support ...). Noise filtering is done using basic morphological operations. The code is developed under the R software, the image processing operations using the EBImage package.

The LeAFtool (Lesion Area Finding tool) is the created R package. The tool can be used in command line mode, or GUI mode via the Shiny package. For the learning game and the analysis the same options are available whatever the mode used. The interface contains an editing part of the results. It allows the editing of lesions (suppression of false detection), or to filter the information according to the maximum surface, the shape (round, elongated), ...

The tools are being developed and a first functional version is available. The first tests carried out on 7 patho-systems showed promising results and similar to manual (visual) expertise. We will also improve the portability between different OS and see how to implement it on a shiny server.

Installation

  • Main Program: Please copy and paste the following command to R console.
  • Upgrading R and Rstudio to the latest version (R >= 3.5, Rstudio > 1.0.0) is strongly recommended.
#### Install or update LeAFtool
install.packages("remotes")
remotes::install_github("sravel/LeAFtool_R")

# if need
if (!require("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("EBImage")

Implemented methods

For moments, LeAFtool support 3 methods:

  • LDA: Linear Discriminant Analysis
  • QDA: Quantitative Descriptive Analysis
  • SVM: Support Vector Machine

Running LeAFtool with GUI

  • To run the application LeAFtool
library(LeAFtool)
runLeAFtool()

Running LeAFtool without GUI (call direct function)

Training

Compute and saves on disk the parameters of the training set Training input folder must include sub-folders:

  • limb
  • background
  • lesion

This sub-folder can contain either image files or sub-folders containing different groups of image files

The function return the confusion matrix and error rate.

library(LeAFtool)
pathTraining <- '../Exemple1/learning/' ## FOR all OS (Linux Mac Windows)
pathTraining <- '..\\Exemple1\\learning' ## FOR windows only
training(pathTraining,
         method = "lda",
         transform = NULL,
         colormodel = "rgb"
        )
  • pathTraining The path of the folder containing sampled images for training. This folder must contain at least 3 sub-folders with name 'background', 'limb' and 'lesion'.
  • method Method of discrimainant analysis: "lda" (default), "qda" or "svm"
  • transform transformation before analysis (e.g. sqrt) # not avail on GUI
  • colormodel Model of color for the analysis: "rgb" (default) or "hsv"
#### Examples
pathTraining <- '/media/sebastien/LaAFtool/exemples/exemple1/learning'
confusionMatrix <- training(pathTraining)
training(pathTraining, transform=function(x) log1p(x),colormodel='rgb', method='svm')
training(pathTraining, colormodel='hsv', method='lda')
training(pathTraining, transform=function(x) (sin(pi*(x-0.5))+1)/2, method='qda')
training(pathTraining, transform=function(x) asin(2*x-1)/pi+0.5)
training(pathTraining, transform=log1p)

Analysis

Analyse an image or a set of images. Analysis step can use many ram on parallel mode.

The function return a dataframe with file name, exit status and message if error.

library(LeAFtool)
analyseImages(pathTraining, pathResult, pathImages, fileImage = NA,
  leafAreaMin = 1000, leafBorder = 5, lesionBorder = 3,
  lesionAreaMin = 10, lesionAreaMax = 120000,
  lesionEccentricityMin = 0, lesionEccentricityMax = 1,
  lesionColorBorder = "#0000FF11", lesionColorBodies = "#FE8E0000",
  blurDiameter = 0, outPosition = "right", parallelThreadsNum = 1)
  • pathTraining The path of the directory containing the sampled images used for training. After the training step, this directory contains the parameters of the training set.
  • pathResult The path of the directory where to store the result files (created by the function if it does not exist).
  • pathImages The path of the directory containing the images to analyse.
  • fileImage A character vector containg the fils names of the images to analyse in pathImages (NA to analyse all the images in pathImages).
  • leafAreaMin The minimum area of a leaf (in pixels) Default: 1000.
  • leafBorder The diameter of the brush (in pixels) used to erode the leafBorder Default: 5.
  • lesionBorder The diameter of the brush (in pixels) used to erode the lesionBorder Default: 3.
  • lesionAreaMin The minimum area of a lesion (in pixels) Default: 10.
  • lesionAreaMax The maximum area of a lesion (in pixels) Default: 120000.
  • lesionEccentricityMin The minimum eccentricity of a lesion Default: 0.
  • lesionEccentricityMax The maximum eccentricity of a lesion Default: 1.
  • lesionColorBorder hexadecimal code for output fill color for lesion in the output image Default: #0000FF (blue).
  • lesionColorBodies hexadecimal code for output bodies color for lesion in the output image Default: #FE8E0000 (transparent).
  • blurDiameter The diameter of the brush (in pixels) used to blur the image (0 for no blur) Default: 0'.
  • outPosition join origale and color lesion image at right or buttom Default: right'.
  • parallelThreadsNum number of thread use, 1 thread analysis 1 image if >= 2 Default: 1'.
#### Examples
dataframeExitStatus <- analyseImages(pathTraining = "../exemple1/learning",
             pathResult = "../exemple1/results",
             pathImages = "../exemple1/samples",
             parallelThreadsNum = 8
             )

analyseImages(pathTraining = "../exemple1/learning",
              pathResult = "../exemple1/results",
              pathImages = "../exemple1/samples",
              leafAreaMin = 600,
              leafBorder = 130,
              parallelThreadsNum = 22)

Toolbox

Resize function

Resize all images into directory in order to reduce size. The function create new directory with factor resize.

library(LeAFtool)
pathImages <- '../exemple1/samples'
resizeImageDirectory(path = pathImages, factor = 1.5)
  • path The path of the directory containing the sampled images to resize.
  • factor The factor of reduce size Default: 2.

Split function

The function split image on n horizontal / m vertical. For exemple if you want to split on 2 equal part The function create new directory with split images.

library(LeAFtool)
pathImages <- '../exemple1/samples'
splitImages(pathImages, splitVertical = 2, splitHorizontal = 3,
            marginTop = 10,
            marginRight = 300,
            marginBottom = 300,
            marginLeft = 170,
            numOrder = "bottum"
            ) # split on 6 part (2x3)
  • path The path of the directory containing the sampled images to resize.
  • splitVertical The number of part split vertical Default: 1.
  • splitHorizontal The number of part split horizontal Default: 1.
  • numOrder The order to numerote output image left from right or top to buttom. Default: bottum.
  • marginTop The crop margin top. Default: 0
  • marginRight The crop margin right. Default: 0
  • marginBottom The crop margin bottom. Default: 0
  • marginLeft The crop margin left. Default: 0

Troubleshooting

install on linux

if install devtools fail please check you have the library:

sudo apt install libxml2-dev libcurl4-openssl-dev libssl-dev -y

if install LeAFtool fail please check you have the library:

sudo apt install libtiff5-dev libfftw3-dev -y

Citation

The paper is currently in prep.

License

LGPL-3 | file LICENSE

Other

Poster

LeAFtool poster

About

Research on plant leaf diseases requires the acquisition of quantitative data to characterize the symptoms caused by different pathogens. These symptoms are frequently lesions that are differentiated from the leaf blade by their color and texture. Among the variables used to characterize the impact of a disease, the most relevant are the number …

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published