Detection of plant leaf diseases using image segmentation and soft computing techniques
CHAPTER 1
INTRODUCTION
1.1 DESCRIPTION
The agricultural land mass is more than just being a feeding sourcing in today’s world.
Indian economy is highly dependent of agricultural productivity. Therefore in field of
agriculture, detection of disease in plants plays an important role. Images form important data
and information in biological sciences. Digital image processing and image analysis
technology based on the advances in microelectronics and computers has many applications
in biology and it circumvents the problems that are associated with traditional photography.
Plants exist everywhere we live, as well as places without us. Many of them carry
significant information for the development of human society. As diseases of the plants are
inevitable, detecting disease plays a major role in the field of Agriculture. Plant disease is one
of the crucial causes that reduces quantity and degrades quality of the agricultural products.
Disease management is a challenging task. Mostly diseases are seen on the leaves or stems of
the plant. Precise quantification of these visually observed diseases, pests, traits has not
studied yet because of the complexity of visual patterns. Hence there has been increasing
demand for more specific and sophisticated image pattern understanding
Plant diseases cause periodic outbreak of diseases which leads to large scale death and
famine. The naked eye observation of experts is the main approach adopted in practice for
detection and identification of plant diseases. But, this requires continuous monitoring of
experts which might be prohibitively expensive in large farms. Further, in some developing
countries, farmers may have to go long distances to contact experts, this makes consulting
experts too expensive and time consuming and moreover farmers are unaware of non-native
diseases.
Automatic detection of plant diseases is an important research topic as it may prove
benefits in monitoring large fields of crops, and thus automatically detect the diseases from
the symptoms that appear on the plant leaves. This enables machine vision that is to provide
image based automatic inspection, process control and robot guidance. Comparatively, visual
identification is labor intensive, less accurate and can be done only in small areas.
Dept. of CS&E, BIET, DVG Page 1
Detection of plant leaf diseases using image segmentation and soft computing techniques
1.2 PROBLEM STATEMENT
There is lack of advanced automatic technique for detection of leaf diseases and
identification of diseases in initial stage through naked eyes is a most difficult task. This
causes huge economic loss for farmers.
1.3 OBJECTIVES
In Crops leaf plays an significant job as it gives data about the amount and nature of
yield ahead of time contingent on the state of leaf. We propose the framework which should
accomplish the following objectives:
To process the data of the leaf picture from plant dataset.
To extract the feature from pre-processed data.
To accurately classify the leaf disease.
To evaluate performance analysis.
1.4 EXISTING SYSTEM
The existing method for plant disease detection is simply naked eye
observation by experts through which identification and detection of plant diseases is
done.
1.4.1 DISADVANTAGES
2. We need large team of experts to detect diseases.
3. Continuous monitoring of plants is required.
4. Cost of existing system is high when we implemented for large farms.
5. Farmers do not have proper facilities or even idea that they can contact to experts.
Due to which consulting experts even cost high as well as time consuming too.
1.5 PROPOSED SYSTEM
We propose an approach for image segmentation technique which uses
different image processing algorithm along with genetic technique is used for
automatic detection and classification of plant leaf diseases. Digital camera or similar
Dept. of CS&E, BIET, DVG Page 2
Detection of plant leaf diseases using image segmentation and soft computing techniques
devices are used to take images of leafs of different types, and then those are used to
identify the affected area in leafs. Then different types of image processing techniques
are applied on them, to process those images, to get different and useful features
needed for the purpose of analyzing later.
Figure 1.1: Block Diagram of Proposed System
1.5.1 ADVANTAGES
1. At very early stage itself it detects the symptoms of diseases i.e. when they
appear on plant leaves.
2. It reduces a large work of monitoring in big farms of crops.
3. Automatic detection of the diseases by just seeing the symptoms on the plant
leaves makes it easier as well as cheaper.
4. Also supports machine vision to provide image based automatic process
control, inspection, and robot guidance.
Dept. of CS&E, BIET, DVG Page 3
Detection of plant leaf diseases using image segmentation and soft computing techniques
CHAPTER 2
LITERATURE REVIEW
2.1 RELATED BACKGROUND STUDY
In 2007, Woods Keri provides the feasibility of using genetic algorithms to segment
general colour images and discuss the issues involved in designing such algorithms. Colour
images can increase the quality of segmentation, but increase the complexity of the problem.
Genetic algorithms are well suited to optimising complex problems such as image
segmentation.
In 2011, Al-Bashish D, Braik M, Bani-Ahmad S design, implement and evaluate an
image-processing-based software solution for automatic detection and classification of plant
leaf diseases. They show that relying on pure naked-eye observation of experts to detect and
classify such diseases can be prohibitively expensive, especially in developing countries.
Providing fast, automatic, cheap and accurate image-processing-based solutions for that task
can be of great realistic significance. Their proposed detection models based neural networks
are very effective in recognizing leaf diseases, whilst K-means clustering technique provides
efficient results in segmentation RGB images.
In 2012, Kulkarni Anand H, Ashwin Patil R K proposes a methodology for
detecting plant diseases early and accurately, using diverse image processing techniques and
artificial neural network (ANN). The work begins with capturing the images. Filtered and
segmented using Gabor filter. Then, texture and color features are extracted from the result of
segmentation and Artificial neural network (ANN ) is then trained by choosing the feature
values that could distinguish the healthy and diseased samples appropriately. Experimental
results showed that classification performance by ANN taking feature set is better with an
accuracy of 91%.
In 2013, Naikwadi Smita, Amoda Niket propose and experimentally evaluate a
software solution for automatic detection and classification of plant leaf diseases. Studies of
plant trait/disease refer to the studies of visually observable patterns of a particular plant. The
experimental results demonstrate that the proposed technique is a robust technique for the
detection of plant leaves diseases. The developed algorithm’s efficiency can successfully
detect and classify the examined diseases with a precision between 83% and 94%.
Dept. of CS&E, BIET, DVG Page 4
Detection of plant leaf diseases using image segmentation and soft computing techniques
In 2013, Chaudhary Piyush propose an algorithm for disease spot segmentation
using image processing techniques in plant leaf is implemented. This is the first and
important phase for automatic detection and classification of plant diseases. A comparison of
the effect of CIELAB, HSI and YCbCr color space in the process of disease spot detection is
done. Median filter is used for image smoothing. Finally threshold can be calculated by
applying Otsu method on color component to detect the disease spot.
In 2013, Rathod Arti N, Tanawal Bhavesh, Shah Vatsal provides various methods
used to study of leaf disease detection using image processing. The methods studies are for
increasing throughput and reduction subjectiveness arising from human experts in detecting
the leaf disease[1].digital image processing is a technique used for enhancement of the image.
To improve agricultural products automatic detection of symptoms is beneficial.
In 2013, Dhaygude Sanjay B, Kumbhar Nitin P explains application of texture
statistics for detecting the plant leaf disease. Firstly by colour transformation structure RGB
is converted into HSV space because HSV is a good colour descriptor. Masking and
removing of green pixels with pre-computed threshold level. Then in the next step
segmentation is performed using 32X32 patch size and obtained useful segments. These
segments are used for texture analysis by color co-occurrence matrix. Finally if texture
parameters are compared to texture parameters of normal leaf.
In 2013, Arivazhagan S, Newlin Shebiah R, Ananthi S, Vishnu Varthini S
proposed system which is a software solution for automatic detection and classification of
plant leaf diseases. They developed processing scheme consists of four main steps, first a
color transformation structure for the input RGB image is created, then the green pixels are
masked and removed using specific threshold value followed by segmentation process, the
texture statistics are computed for the useful segments, finally the extracted features are
passed through the classifier. Their proposed algorithm’s efficiency can successfully detect
and classify the examined diseases with an accuracy of 94%.
In 2014, Ghaiwat Savita N, Arora Parul present survey on different classification
techniques that can be used for plant leaf disease classification. A classification technique
deals with classifying each pattern in one of the distinct classes. A classification is a
technique where leaf is classified based on its different morphological features. There are so
many classification techniques such as k-Nearest Neighbor Classifier, Probabilistic Neural
Network, Genetic Algorithm, Support Vector Machine, and Principal Component Analysis,
Dept. of CS&E, BIET, DVG Page 5
Detection of plant leaf diseases using image segmentation and soft computing techniques
Artificial neural network, Fuzzy logic. Selecting a classification method is always a difficult
task because the quality of result can vary for different input data. Plant leaf disease
classifications have wide applications in various fields such as in biological research, in
Agriculture etc. They provide an overview of different classification techniques used for
plant leaf disease classification.
Dept. of CS&E, BIET, DVG Page 6
Detection of plant leaf diseases using image segmentation and soft computing techniques
CHAPTER 3
REQUIREMENTS SPECIFICATION
3.1 FUNCTIONAL REQUIREMENTS
Functional requirements are the software capabilities which are to be present in order
for the user to get the service from the system.
Our proposed system is having the applications in the field of farming for detecting
diseases in the leaves. The following are the functional requirements of proposed system:
1. Image Acquisition: The proposed system is fed with the images of different leaf with
disease affected.
2. Database Operations: Various types of leaf images are maintained in the database.
3. Color Co-occurrence Method: It is the methodology in which both the texture and
color of an image are considered, to come to the unique features, which shows that
image.
3.2 NON-FUNCTIONAL REQUIREMENTS
Non-Functional Requirements provides criteria that are used to decide the operations of
the system. The following are the non-functional requirement:
1. Scalability: The proposed system can extended to any number of farms.
2. Reliability: Our proposed system is reliable. There will be no false data and lesser
loss of information as it ensures increased data utility.
3. Flexibility: The proposed system is more flexible to the user as it uses simple
techniques and also less complexity so that everyone can understand easily.
4. Performance: Our proposed system accurately classifies the diseases than the legacy
system.
5. Cost: Lesser cost compare to existing technique.
Dept. of CS&E, BIET, DVG Page 7
Detection of plant leaf diseases using image segmentation and soft computing techniques
3.3 HARDWARE AND SOFTWARE REQUIREMENTS
Minimal Hardware Requirements
Processor : Corei3 or higher
Hard disk : Minimum 20GB
RAM : Minimum 4GB
Minimal Software Requirements
Operating System: Ubuntu 18 or higher
Tools used : Python 3.7 and above
Database : MySQL/My SQLite
Dept. of CS&E, BIET, DVG Page 8
Detection of plant leaf diseases using image segmentation and soft computing techniques
CHAPTER246
SYSTEM DESIGN
System design thought as the application of theory of the systems for the development
of the project. System design defines the architecture, data flow, use case, class, sequence and
activity diagrams of the project development.
4.1 SYSTEM5ARCHITECTURE9
This architecture diagram illustrates how the system is built and is the basic
construction of the software7method. Creations of such structures and documentation of these
structures is the main responsible of software architecture.
Figure 4.1: Architecture of proposed system
Dept. of CS&E, BIET, DVG Page 9
Detection of plant leaf diseases using image segmentation and soft computing techniques
Since, disease detection in plants plays an important role in the agriculture field, as
having a disease in plants are quite natural. If proper care is not taken in this area then it can
cause serious effects on plants and due to which respective product quality, quantity or
productivity is also affected.
Plant diseases cause a periodic outbreak of diseases which leads to large-scale death. These
problems need to be solved at the initial stage, to save life and money of people.
Automatic detection of plant diseases is an important research topic as it may prove benefits
in monitoring large fields of crops, and at a very early stage itself it detects the symptoms of
diseases means when they appear on plant leaves. Farm landowners and plant caretakers (say,
in a nursery) could be benefited a lot with an early disease detection, in order to prevent the
worse to come to their plants and let the human know what has to be done beforehand for the
same to work accordingly, in order to prevent the worse to come to him too.
This enables machine vision that is to provide image-based automatic inspection,
process control. Comparatively, visual identification is labor intensive less accurate and can
be done only in small areas.
The project involves the use of self-designed image processing algorithms and techniques
designed using python to segment the disease from the leaf while using the concepts of
machine learning to categorise the plant leaves as healthy or infected.
By this method, the plant diseases can be identified at the initial stage itself and the pest and
infection control tools can be used to solve pest problems while minimizing risks to people
and the environment.
4.2 SEQUENCE DIAGRAM
A sequence diagram it is a type of communicative diagram which demonstrates how
the techniques or processes work with each other and also gives the information about in
which order they are working. Sequence diagram, its develop communication arrangement
graph. These figures some time named occurrence figures, occasion situations, What's more
scheduling figures.
Dept. of CS&E, BIET, DVG Page 10
Detection of plant leaf diseases using image segmentation and soft computing techniques
Fig.4.3: Sequence Diagram.
Description: Initially we take the leaf image as input and perform some pre-processing on it.
After that we extract some features based on which training and testing sequence will occurs
respectively. Here farmer is the one who needs to test the images. Admin is the proposed
system.
4.3 DATA FLOW DIAGRAM
It also referred as bubble graph. This diagram is useful for representing the system for
all degree of constructions. The figure is differentiated into parts which show maximizing
data path & practical aspect.
Dept. of CS&E, BIET, DVG Page 11
Detection of plant leaf diseases using image segmentation and soft computing techniques
Figure 4.7: Dataflow diagram
8Fig.4.6: Flow chart Diagram
Dept. of CS&E, BIET, DVG Page 12
Detection of plant leaf diseases using image segmentation and soft computing techniques
CHAPTER65
IMPLEMENTATION
5.1 PROPOSED METHODOLOGY
Digital camera or similar devices are used to take images of leafs of different types,
and then those are used to identify the affected area in leafs. Then different types of image
processing techniques are applied on them, to process those images, to get different and
useful features needed for the purpose of analyzing later.
Algorithm written above illustrated the step by step approach for the proposed image
recognition and segmentation processes:
(1) Image acquisition: is the very first step that requires capturing an image with the
help of a digital camera.
(2) Preprocessing: of input image to improve the quality of image and to remove the
undesired distortion from the image. Clipping of the leaf image is performed to get the
interested image region and then image smoothing is done using the smoothing filter. To
increase the contrast Image enhancement is also done.
(3) Mostly green colored pixels, in this step, are masked. In this, we computed a
threshold value that is used for these pixels. Then in the following way mostly green pixels
are masked: if pixel intensity of the green component is less than the pre-computed threshold
value, then zero value is assigned to the red, green and blue components of the this pixel.
(4) Removing: Infected clusters, inside the boundaries, remove the masked cells.
(5) Clustering: Obtain the useful segments to classify the leaf diseases. Segment the
components using genetic algorithm.
(6) Computing the features using color co-occurrence methodology: For feature
extraction the method used is color co-occurrence method. It is the methodology in which
both the texture and color of an image are considered, to come to the unique features, which
shows that image. Over the traditional gray-scale representation, in the visible light spectrum,
the use of color image features provides an additional feature for image characteristic. There
are three major mathematical processes in the color co-occurrence method. First, conversion
of the RGB images of leaves is done into HIS color space representation. After completion of
this process, to generate a color co-occurrence matrix, each pixel map is used, which results
into three color co-occurrence matrices, one for each of H, S, I.
Dept. of CS&E, BIET, DVG Page 13
Detection of plant leaf diseases using image segmentation and soft computing techniques
(7) Classification of disease: In this phase of classification, extraction and comparison of the
co-occurrence features for the leaves with the corresponding feature values are stored in the
feature dataset. First, the Minimum Distance Criterion and then classifier are used to done the
classification. The measurement of success of classification is done by using the
classification gain and following equation is used for calculation:
Gain (%) = number of correct classification / Total no of test images * 100
5.2 IMPLEMENTATION
In the initial step, the RGB images of all the leaf samples were picked up.
The step-by-step procedure of the proposed system:
+ RGB image acquisition;
+ Convert the input image from RGB to HSI format;
+ Masking the green-pixels;
+ Removal of masked green pixels;
+ Segment the components;
+ Obtain useful segments;
+ Evaluating feature parameters for classification;
+ Configuring CLASSIFIER for disease detection.
Calculating number of pixels with shade of white(p) to check if exclusion of these pixels is
required or not (if more than a fixed %) in order to differentiate the white background or
white patches in image caused by flash, if present.
p=0
for i in range([Link][0]):
for j in range([Link][1]):
B = img[i][j][0]
G = img[i][j][1]
R = img[i][j][2]
if (B > 110 and G > 110 and R > 110):
p += 1
Finding the % of pixels in shade of white
totalpixels = [Link][0]*[Link][1]
Dept. of CS&E, BIET, DVG Page 14
Detection of plant leaf diseases using image segmentation and soft computing techniques
per_white = 100 * p/totalpixels
'''
print 'percantage of white: ' + str(per_white) + '\n'
print 'total: ' + str(totalpixels) + '\n'
print 'white: ' + str(p) + '\n'
'''
Excluding all the pixels with colour close to white if they are more than 10% in the image
if per_white > 10:
img[i][j] = [200,200,200]
[Link]('color change', img)
Mean-shift algorithm
Mean shift clustering aims to discover “blobs” in a smooth density of samples. It is a
centroid-based algorithm, which works by updating candidates for centroids to be the mean
of the points within a given region. These candidates are then filtered in a post-processing
stage to eliminate near-duplicates to form the final set of centroids
newimg = [Link](([Link][0], [Link][1],3),np.uint8)
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER , 10 ,
1.0)
img = [Link](blur1, 20, 30, newimg, 0, criteria)
[Link]('means shift image',img)
Computes the bounding box for the contour, and draws it on the frame:
for contour, hier in zip(contours, hierarchy):
(x,y,w,h) = [Link](contours[maxid])
min_x, max_x = min(x, min_x), max(x+w, max_x)
min_y, max_y = min(y, min_y), max(y+h, max_y)
if w > 80 and h > 80:
Colour Transformation:
Dept. of CS&E, BIET, DVG Page 15
Detection of plant leaf diseases using image segmentation and soft computing techniques
HSI (hue, saturation, intensity) color model is a popular color model because it is based on
human perception. After transformation, only the H (hue) component of HSI colour space is
taken into account since it provides us with the required information.
#Changing colour-space
#imghsv = [Link](img, cv2.COLOR_BGR2HSV)
imghls = [Link](roi, cv2.COLOR_BGR2HLS)
[Link]('HLS', imghls)
imghls[[Link]((imghls==[30,200,2]).all(axis=2))] = [0,200,0]
[Link]('new HLS', imghls)
Masking Green Pixels:
This is performed as green colour pixel represent the healthy region of a leaf. Green pixels
are masked based on the specified threshold values.
mask = cv2.bitwise_and(originalroi,originalroi,mask = thresh)
[Link]('masked out img',mask)
Segmentation:
The infected portion of the leaf is extracted by segmenting the diseased part with other
similar coloured parts (say, a brown coloured branch of a leaf that may look like the disease)
which have been considered in the masked out image, are filtered here. All further image
processing is done over a region of interest (ROI) defined at this stage.
#Creating rectangular roi around contour
height, width, _ = [Link]
min_x, min_y = width, height
max_x = max_y = 0
frame = [Link]()
# computes the bounding box for the contour, and draws it on the frame,
for contour, hier in zip(contours, hierarchy):
(x,y,w,h) = [Link](contours[maxid])
min_x, max_x = min(x, min_x), max(x+w, max_x)
min_y, max_y = min(y, min_y), max(y+h, max_y)
if w > 80 and h > 80:
Dept. of CS&E, BIET, DVG Page 16
Detection of plant leaf diseases using image segmentation and soft computing techniques
Classification:
From the previous results we analyze and evaluate the features like the area of the
leaf, percentage(%) of the leaf infected, the perimeter of the leaf, etc., for all the leaf images,
and pass it to the classifier. We used GaussianNB classifier by invoking from Sklearn
module.
from sklearn.naive_bayes import GaussianNB
Libraries:
We imported Numpy, pandas, matplotlib and CV2 libraries in our coding to build
proposed system.
# importing required libraries
import numpy as np
import pandas as pd
import [Link] as plt
import cv2
Dataset creation
In `leaf sampler` directory run:
```shell python3 [Link] -i ```
or
```shell python3 [Link] -i ```
`[Link]` for running on one same category of images (say, all images
are infected) and `[Link]` for creating dataset for both category
(infected/healthy) of leaf images, in the working directory.
Dept. of CS&E, BIET, DVG Page 17
Detection of plant leaf diseases using image segmentation and soft computing techniques
CHAPTER0600
RESULTS AND DESCRIPTIONS
6.1 OUTPUT SCREENSHOTS
The main window contains the overview of the project and steps of proposed system
along with browse button for image acquisition.
Figure 6.1: Main window (GUI front end)
After clicking browse button on main window we can select the image need to tested
in our image test dataset.
Dept. of CS&E, BIET, DVG Page 18
Detection of plant leaf diseases using image segmentation and soft computing techniques
Figure 6.2: list of images of leaf to test
Once we select the image need to be tested we get the different sub-windows each
showing result of the respective steps in the proposed system.
Figure 6.3: Different sub-windows along with proposed steps respectively
Dept. of CS&E, BIET, DVG Page 19
Detection of plant leaf diseases using image segmentation and soft computing techniques
The following figures are the output of different steps of proposed system respectively.
Figure 6.4: Original Image
Figure 6.4: color changed
Dept. of CS&E, BIET, DVG Page 20
Detection of plant leaf diseases using image segmentation and soft computing techniques
Figure 6.5: Means Shift Image step
Figure 6.6: contour step
Dept. of CS&E, BIET, DVG Page 21
Detection of plant leaf diseases using image segmentation and soft computing techniques
Figure 6.7: ROI step
Figure 6.8: Rectangle ROI
Figure 6.9: HLS
Dept. of CS&E, BIET, DVG Page 22
Detection of plant leaf diseases using image segmentation and soft computing techniques
Figure 6.10: Image hue hls
Figure 6.11: Image hue with mask
Figure 6.12: Masked out image
Dept. of CS&E, BIET, DVG Page 23
Detection of plant leaf diseases using image segmentation and soft computing techniques
Figure 6.13: Image with threshold of disease infected
Figure 6.14: Contour Masked
Figure 6.15: Validation of disease affected area within image acquired
Dept. of CS&E, BIET, DVG Page 24
Detection of plant leaf diseases using image segmentation and soft computing techniques
Figure 6.16: final prediction with test dataset and trained dataset
Dept. of CS&E, BIET, DVG Page 25
Detection of plant leaf diseases using image segmentation and soft computing techniques
CHAPTER 7
CONCLUSION AND FUTURE WORK
CONCLUSION
This project presents the survey on different diseases classification techniques used
for plant leaf disease detection and an algorithm for image segmentation technique that can
be used for automatic detection as well as classification of plant leaf diseases later. Grape,
corn, tomato, pepper, apple, and blueberry are some of those species on which proposed
algorithm is trained and tested. Therefore, related diseases for these plants were taken for
identification. With very less computational efforts the optimum results were obtained, which
also shows the efficiency of proposed algorithm in recognition and classification of the leaf
diseases. Another advantage of using this method is that the plant diseases can be identified at
early stage or the initial stage.
FUTURE WORK
To improve recognition rate in classification process Artificial Neural Network, SVM
classifier, Fuzzy Logic and hybrid algorithms can also be used.
Dept. of CS&E, BIET, DVG Page 26