sravel / LeAFtool_R

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. The LeAFtool (Lesion Area Finding tool)
GNU General Public License v3.0
2 stars 1 forks source link
detection gui image-processing lesion

LeAFtool Logo

Table of Contents

About this package

:warning: 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

#### 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:

Running LeAFtool with GUI

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:

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"
        )
#### 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)
#### 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)

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)

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