LEAF DISEASE IDENTIFICATION AND REMEDY RECOMMENDATION SYSTEM USINGCNN
RSI_ReportPDF
1. Visual Identification of Apple
Diseases using Image
Processing Techniques on
Android Mobile Devices
Abstract
Apple diseases can cost a gardener their season’s harvest. Using technology that
empowers the average grower to self identify apple diseases will save the grower time,
money, and their season’s crop. An algorithm was presented that automatically detected
and identified three apple diseases: apple bitter rot, blister spot, and scab from an Android
mobile device application. Using OpenCV and Java, a computer vision software library
and programming language, I developed a real-time algorithm that identifies the proper
apple disease using the OpenCV template matching function. The algorithm executed a
pixel-by-pixel transformation using a gray scale filter to improve disease matching
between the templates and the image. A systematic verification process was performed
that took the resulting highest pixel match and performed identification against all disease
templates. The Android application that packages this functionality allowed the user to
take a picture of the diseased area, executed the algorithm, and then displayed the best
match identified. Results suggested that some diseases were identified on either the
wrong disease image or a non-diseased fruit image, while others were accurately
identified. The successful identification of a disease was proven to be 71% accurate,
while the others had a success rate as low as 33%. Therefore alternative or supplemental
methods will need to be explored to improve accuracy across various disease matches.
Anita Garcia
August, 2015
2. Table of Contents
I. Introduction
II. Methodology
III. Experiments
IV. Experiment Results
V. Apps Created
VI. Discussion
VII. Future Work
References
3. I. Introduction
Fruit diseases are hazardous in more ways than only their effect on the human
body. The issue of fruit diseases stretches into the grower’s economical well
being and production. According to plant pathologist, Alfredo Martinez, apple
diseases cause a production loss of 0.1 - 5.0 percent and .5 - 153.6 thousands of
dollars are being spent on damage and control [1]. Existing solutions that are
being performed by trained individuals include monitoring and various
management procedures. During the monitoring process, several fruit factors are
observed, like leaf wetness and temperature. These observations are made on
each apple tree and then recorded during the pre bloom, pre harvest and harvest
times. Some management procedures include resistant cultivars, sanitation, and
chemical control. All of this man power and additional disease resistant resources
are costly. In 2008, apple disease cost of control was 267.5 thousands of
dollars[2]. What if the grower could bypass the experts, timely procedures, and
money due to lost of production and cost of control? Automating these
procedures while using template matching, an image processing technique, on
an android phone will eliminate loss in production and economical devastation.
II. Methodology
The primary method used in addressing this agricultural problem is OpenCV’s image
processing method, template matching. In this approach, two images are matched up
against one an other to best identify the most accurate match. A generic, pre-selected
disease template is cross examined against a query image in a pixel by pixel fashion and
results in a float value from -1 to 1, indicating the accuracy of the best match found.
.9993243217468262
[TEMPLATE IMAGE] -> [QUERY IMAGE] -> [DISEASE FOUND]
*In the figure above, the resulting matches found indicate the level of accuracy of the template
being matched against the query image.
Much image variability may be present between the two images being cross examined,
such as lighting, color, and positioning. To best execute template matching, additional
4. image processing steps are needed to neutralize both images. To best neutralize pixel
variability, I applied an image processing filter that converts both the template and query
image into grayscale.
The second method that I explored was Cascade Classification.There are two main stages
in this classification, one is training and the other is detection[3]. Through an automated
training process, a set of resulting images are generated to be identified with any given
disease. This training process involved collecting positive and negative images in order to
produce a resulting template. A terminal command can be used to begin the training via
openCV’s opencv_traincascade. This work will then be saved in an .xml file,
which is ready to be tested.
III. Experiments
Binary
Much of the image variability questions were taken into account by various experiments.
Any image may give too much pixel information, whether it be color, shine, brightness,
etc. A binary image conversion and comparison was explored, which allowed for each
pixel in the image to have only two possible values, thus eliminating pixel variability. In
my case, I used the black and white colors with the use of a threshold. Both the template
and query image were taken and converted into Binary. These comparisons were done
using template matching and the resulting values closely analyzed. I found that when
using binary images, the resulting accuracy was less than when using the same two
images (template and query) in color. The normalization attempt, in theory, would have
given more accurate results because of the reduction of pixel variety. The opposite was
resulted to be true.
.8070833683013916
[TEMPLATE IMAGE] -> [QUERY IMAGE] -> [DISEASE FOUND]
*In the figure above, the resulting matches found indicate the level of accuracy of the template
being matched against the query image.
Gray Scale
For the same reasons of reducing image variability, the experimentation of the grey scale
filter was used. In this experiment, both the query image and the template were
converted into a grey scaled image with a built in OpenCV method before the OpenCV
5. template matching function was performed. The normalization that grey scale conversion
brought to both, the template and query image, was beneficial to all matching
experiments. Matching results from the template using this filter yielded a higher
matching accuracy rate. With a higher accuracy rate, this experiment was selected to be
used in the final algorithm as a pre-processing step before template matching was to be
executed.
IV. Experiment Results
The template matching results vary on the amount of templates examined against each
image subject; whether each image subject is tested against a single disease template, or
all eight templates. Single template matches: 33 - 100 % Matching template matches: 5 -
71 % Each of the three has two corresponding templates to improve the accuracy rate.
The smaller the template feature is, the more easily identifiable the disease is across
multiple image subjects, making the accuracy rate drop.
V.Apps Created
Several Applications were developed prior to the completion of the final application.
Four applications were created in order to test key features, image pre-processing
experiments and OpenCV function. The applications created included: Opening Camera,
Image Pre-processing, Template Matching, Test Algorithm, Final Application: Phyto
Sense It.
Camera Access
The purpose of this application was solely to gain Android camera access. The specificity
of this application allows for a camera view to open up.
6. Image Pre-processing
The purpose of the application is to convert an image to binary, and gray scale. This
application was capable of using the a Camera View instead of the native Android
Camera. This app allowed for a photo to be taken, image filtration to be applied, and the
converted image was displayed.
Template Matching
The purpose of this application is to test the OpenCv template matching function. This
application had multiple stages: At it’s beginning stage, it allowed the user to press a
button that would match the template to an query image taken from a drawable. Later,
the application progressed to match the template against a query image that was captured
from the camera. The resulting template match shows a rectangle around the best
detected match. The last purpose of this application was to test which pre-processing
filter had the best accuracy rates.
7. Test Algorithm
The purpose of this application is collect the name of the disease, state of fruit, disease
detected, and maximum accuracy rate of each sample photo. In order to attain this
comprehensive data set, each sample picture is matched against each template.
1) Store all images in drawables as diseasename_#
2) Run all templates against each photo individually, by each batch
3) Store maximum values in array
4) After Image batch is iterated through, look for highest max
5) The index of where the maxvalue is found will correspond to the disease
* 0-1: healthy, 2-3: bitterrot, 3-4: blisterspot, 5-6: scab
6) If index of max value is 0 or 1, then fruit is healthy, otherwise fruit is diseased
Name State Disease Detected Max. Accuracy Rate
8. Final Application
This is the final product, which is a combination of all previous applications put together.
This serves the purpose of disease inspection using the camera and allowing user to snap
a picture after a home screen of photography tips for best chances of disease detection,
run inspection algorithm on the image taken, then display resulting disease detected, if
any, along with a short description of disease, picture of disease, link for more
information and option to try again.
VI. Discussion
Using template matching as my primary method for disease inspection proved to be less
accurate than hypothesized. The similarity of each disease template used made the results
appear on false image subjects. For example, apple blister spot was often detected in
apple bitter rot and apple scab because of it’s subset similarity.
VII. Future Work
Future work will include further exploring cascade classifier or any other methods to
improve accuracy. The initial verification of whether the object being captured is an apple
or not before proceeding into image detection. Conducting a thorough accuracy
experimentation and analysis to pin point the best method compatible with android
platforms. Once this is attained, a larger disease database will need to be implemented.
Any future implications of a functioning, accurate and robust algorithm that detects and
identifies diseases can be utilized as a cost effective tool for large crop growers.
9. References
[1] Jayamala K. Patil, Raj Kumar, “Advances in Image Processing For Detection of Plant
Diseases,” Journal of Advanced Bioinformatics Applications and Research, vol. 2, Issue,
2, pp. 135-141, June, 2011.
[2] David B. Langston, Jr. (2008). 2008 Georgia Plant Disease Loss Estimates (AP
102-1) [online]. Available: http://extension.uga.edu/publications/detail.cfm?
number=AP102-1#Apple
[3] OpenCV 2.4.11.0 documentation. Cascade Classifier Training [online]. Available:
http://docs.opencv.org/doc/user_guide/ug_traincascade.html