Sie sind auf Seite 1von 120

NATIONAL UNIVERSITY OF COMPUTER & EMERGING SCIENCES

LAHORE, PAKISTAN
DEPARTMENT OF COMPUTER SCIENCE

Weed Detection in Wheat Fields Using


Computer Vision

By: Novaira Noor


L12-5003
Master of Computer Science
Thesis

Supervisor:
Dr. Yasir Niaz Khan
Co-Supervisor
Dr. Asif Gilani

1
SUBMITTED TO THE DEPARTMENT OF COMPUTER SCIENCE IN PARTIAL
FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF MASTER OF
SCIENCES IN COMPUTER SCIENCE AT FAST NATIONAL UNIVERSITY OF
COMPUTER AND EMERGING SCIENCES

May 2014.

© 2014 NOVAIRA NOOR. ALL RIGHTS RESERVED.

Signature of Author: ___________________________________________________

Department: _________________________________________________________

Dated: ______________________________________________________________

Certified by: _________________________________________________________

Supervisor

_________________________
Dr. Yasir Niaz Khan
Assistant Professor of Computer Science
FAST (NUCES)

2
Certificate of Originality

This is to certify that I am responsible for the work done in this thesis. The original work is my
own. Neither the thesis nor the original work contained therein has been submitted to this or any
other institution for a higher degree. Information taken from other sources is cited in the
references section. Resemblance to someone else’s work is unintentional and purely
coincidental.

Signature: ____________________________

Date: ________________________________

3
Acknowledgement

I am thankful to GOD Who unraveled intellect on to my heart and choose me among His
enlightened and gave me strength and courage to meet all of the challenges and obstacles faced
throughout my life, especially to achieve this objective successfully.

My gratitude goes to my beloved parents, sisters and friends for their love, guidance and
motivation. I am grateful to them. I hope that I can return to them as much support and
encouragement as they have given to me.

I am indebted to my supervisor Dr. Yasir Niaz Khan for his eloquent guidance and support
during my research. He has always produced great learning scenarios for me and his suggestions
enabled me to complete the thesis in best possible manner. I am also grateful to Dr. Asif Gilani
and Dr. Kh. M. Umar Suleman for their help and suggestions during my thesis.

Novaira Noor

4
Abstract

Agriculture plays a significant role in the economic growth of countries. Hence reducing cost
and improving quality as well as quantity of crops is highly needed. Precision farming
technologies have been developed during last two decades to refine the agricultural management
practices. The purpose of precision farming is to customize treatments of fields based on local
conditions with the aim to reduce cost and increase yield. Weeds are most dangerous competitors
of wheat crops. They are unwanted plants that compete with crops for nutrients, food and water
and in some cases light. They not only affect productivity but also deteriorate crop quality and
makes them toxic. Weed distribution level vary from low to high densities. This distribution
pattern makes site specific weed management more feasible. Motivate farmers to use herbicide
economically, targeting only high weed density areas. In traditional/manual weed management
methods a uniform amount of herbicide is applied throughout the field. These methods are labor
intensive, costly and time consuming. Therefore automatic weed detection by means of computer
vision is focused in this thesis. I have proposed two algorithms for weed detection in scattered
wheat fields where weed and wheat leaves may overlap each other and have same color. First
algorithm is based on image processing techniques. In it, color information is used to
differentiate vegetation from soil while shape and texture analysis techniques are applied to
distinguish between weeds and crop. The performance of algorithm is evaluated using ground
truth images with an acceptable success rate of 74%. In the second algorithm multi-class linear
kernel SVM has been used to classify wheat field images based on weed density. In experiments
different feature sets like local binary pattern (LTP), Surf and Sift sparse codes were used to train
SVM against three classes; 1) no weed 2) less weed 3) more weeds. For comparison purposes
Back-propagation Neural Network and Non-linear RBF kernel SVM was used. Results showed
that multi-class linear kernel SVM beats neural network and non-linear SVM, in terms of
classification accuracy and execution time. Moreover multi-class linear SVM trained on LTP
with five other texture features classified field images with 82% accuracy.

5
Table of Contents
Abstract ......................................................................................................................................................... 5

I. Introduction ..................................................................................................................................... 14

A. Wheat crop production: .................................................................................................................. 14


B. Weeds: ............................................................................................................................................. 15
C. Weed Management and Control: .................................................................................................... 17
D. Problem Statement: ........................................................................................................................ 17
E. Traditional methods: ....................................................................................................................... 17
F. Precision Agriculture (PA):............................................................................................................... 18
G. Uncontrolled lightening condition: ................................................................................................. 18
II. Related Work ................................................................................................................................... 19

A. Weeds in Wheat crops in Pakistan .................................................................................................. 20


B. Weed Detection Approaches........................................................................................................... 21
C. Manual Weed Scouting ................................................................................................................... 22
D. Automated Weed Detection ........................................................................................................... 22
E. Remote Sensing ............................................................................................................................... 22
1. Satellite Systems ......................................................................................................................... 23

F. Ground Based Systems .................................................................................................................... 24


1. Photodetectors ........................................................................................................................... 24

2. Hyperspectral Imaging ................................................................................................................ 24

G. Computer Vision ............................................................................................................................. 25


1. Shape Analysis Techniques ......................................................................................................... 26

2. Textural Analysis ......................................................................................................................... 28

3. Crop Row Elimination.................................................................................................................. 30

H. Weed Type Classification: ............................................................................................................... 32


I. Summary:......................................................................................................................................... 34

6
III. Weed Detection Using Image Processing ........................................................................................ 36

A. Soil and vegetation (weed and wheat) segmentation: ................................................................... 36


B. Weed and wheat discrimination ..................................................................................................... 37
1. Shape based detection:............................................................................................................... 38

2. Texture Based Detection:............................................................................................................ 39

C. Shape and Frequency Based Weed Detection Algorithm: .............................................................. 41


IV. Experiments and Results ................................................................................................................. 42

A. Datasets ........................................................................................................................................... 42
B. Experimental Setup ......................................................................................................................... 42
C. Stage 1: Soil and Vegetation Segmentation .................................................................................... 42
1. Results: ........................................................................................................................................ 51

D. Stage 2: Weed and Wheat discrimination: ..................................................................................... 51


1. Shape Based Analysis .................................................................................................................. 51

2. Texture based analysis: ............................................................................................................... 54

3. Apply logical OR .......................................................................................................................... 58

4. Weed Detection Results:............................................................................................................. 58

5. Execution Time Results: .............................................................................................................. 59

6. Texture Based Analysis Results ................................................................................................... 60

7. Shape Based Analysis Results ..................................................................................................... 61

V. Weed Detection using Circular Hough Transform:.......................................................................... 63

A. Hough Transform:............................................................................................................................ 64
B. Weed Detection Using CHT: ............................................................................................................ 65
1. Preprocessing: ............................................................................................................................. 66

2. Color Processing:......................................................................................................................... 66

3. Circular Hough Transform: .......................................................................................................... 66

C. Experiment and Results: .................................................................................................................. 68


VI. Texture Analysis:.............................................................................................................................. 71
7
A. Statistical Approach: ........................................................................................................................ 72
1. Local Mean: ................................................................................................................................ 72

2. Local Standard Deviation: .......................................................................................................... 73

3. Energy: ........................................................................................................................................ 73

4. Contrast: ...................................................................................................................................... 74

5. Correlation: ................................................................................................................................. 74

6. Entropy:....................................................................................................................................... 76

7. Local Range: ............................................................................................................................... 76

B. Experiment and Results: .................................................................................................................. 76


VII. Weed Detection Using Support Vector Machine ............................................................................ 79

A. Weed Detection Using Multiclass Linear SVM ................................................................................ 81


1. SVM: ............................................................................................................................................ 81

2. Multiclass Linear SVM ................................................................................................................. 83

3. Local Ternary Pattern .................................................................................................................. 84

4. Texture features.......................................................................................................................... 85

5. Speeded Up Robust Features (SURF) .......................................................................................... 85

6. Scale-Invariant Feature Transform (SIFT) ................................................................................... 86

7. Sparse Coding of SIFT .................................................................................................................. 87

B. Comparative Analysis ...................................................................................................................... 88


C. Experiment and Results: .................................................................................................................. 88
1. Experimental Setup: .................................................................................................................... 88

2. Dataset ........................................................................................................................................ 89

3. Back-Propagation Neural Network ............................................................................................. 91

4. Non-Linear SVM .......................................................................................................................... 92

5. Performance Evaluation.............................................................................................................. 92

6. Classification Results using SURF ................................................................................................ 92


8
7. Classification Results using SIFT sparse codes ............................................................................ 96

8. Classification Results using LTP ................................................................................................. 100

9. Classification Results using Texture Features ........................................................................... 104

10. Classification Results using LTP and Texture Features...................................................... 108

D. Discussion...................................................................................................................................... 112
VIII. Conclusion ..................................................................................................................................... 114

IX. Future Work: ................................................................................................................................. 115

X. References ..................................................................................................................................... 116

9
List of Figures:

Figure 1: Leaf Shape of Broadleaf Weeds in Wheat ............................................................................... 16


Figure 2: Grass like Weeds in Wheat ...................................................................................................... 16
Figure 3: Edge Detection Method on Rows ............................................................................................ 27
Figure 4: Flow Chart of Weed Detection using Fast Fourier Transform ................................................. 28
Figure 5: Flow Chart of Bayes Classifier Method for Weed Detection ................................................... 29
Figure 6: Flow Chart of Weed Detection Using Morphological Operations ........................................... 30
Figure 7: Weeds between Two Rows ...................................................................................................... 31
Figure 8: Flow chart of Inter Row Weed Detection using Hough Transform.......................................... 32
Figure 9: Weed Classification based on Discriminate Analysis ............................................................... 33
Figure 10: Flow Chart of Weed Detection Using Edge Link Detection.................................................... 34
Figure 11: Flow Chart of Shape and Texture based Weed Detection ..................................................... 41
Figure 12: Monochromatic Image of Test Image1 .................................................................................. 43
Figure 13: Monochromatic Image of Test Image2 .................................................................................. 43
Figure 14: Thresholding on Test image1, Threshold=227 ....................................................................... 44
Figure 15: Thresholding on Test image2, Threshold=227 ....................................................................... 45
Figure 16: Thresholding on Test Image1, Threshold=195....................................................................... 45
Figure 17: Thresholding on Test Image2 with Threshold=195 ............................................................... 46
Figure 18: Monochromatic Image of Test Image1 with r=-0.7,b=0.136,g=0.388 ................................... 47
Figure 19: Monochromatic Image of Test Image2 with r=-0.7,b=0.136,g=0.388 ................................... 47
Figure 20: Thresholding on Test Image1 with Threshold=90 ................................................................. 48
Figure 21: Thresholding on Test Image2 with Threshold=90 ................................................................. 48
Figure 22: Monochromatic Images with Different RGB Values a) r=-1,g=2,b=-1, b) g=-0.388, r=-0.7,
b=0.136 ................................................................................................................................................... 49
Figure 23: Binary Test Image1 with Different Threshold a) threshold= 227, b) threshold = 90 ............. 50
Figure 24: Binary Test Image2 with Different Threshold a) threshold= 195, b) threshold = 90 ............. 50
Figure 25: Morphological Opening of Test Imsge2 with 35 radius ......................................................... 52
Figure 26: Morphological Opening of Test Imsge1 with 35 radius ......................................................... 52
Figure 27: Morphological opening of Test Imsge2 with Radius=45 ........................................................ 53
10
Figure 28: Morphological opening of Test Imsge1 with Radius=45 ........................................................ 53
Figure 29: Diagonal Sub-band of Test Image1 ........................................................................................ 54
Figure 30: Diagonal Sub-band of Test Image2 ........................................................................................ 55
Figure 31: Dilated diagonal Sub-band of Test Image1 ............................................................................ 56
Figure 32: Dilated Diagonal Sub-band of Test Image2............................................................................ 56
Figure 33: Weed Detected after Textural Analysis on Test Image1........................................................ 57
Figure 34: Weed Detected after Textural Analysis on Test Image2........................................................ 57
Figure 35: Final result of Shape and Texture based weed detection (a) Original image with weeds
marked by red circle (b) logical OR of shape and texture based analysis results ................................... 58
Figure 36: Leaves of Weed and Wheat crop ........................................................................................... 63
Figure 37: Each point in geometric space (left) generates a circle in parameter space (right). The circles
in 65
Figure 38: Flow Chart of Weed Detection using CHT.............................................................................. 67
Figure 39: Test Image1 after preprocessing ........................................................................................... 68
Figure 40: Color Processing Result after Histogram Equalization ........................................................... 68
Figure 41: Result of CHT on test image1 ................................................................................................. 69
Figure 42: Result of CHT on test image2 ................................................................................................. 69
Figure 43: Separating Hyperplane between Positive and Negative Training Sample............................. 81
Figure 44: LTP operator........................................................................................................................... 85
Figure 45: Flow Chart of Weed Density Classification Using Multi-class Linear SVM with SIFT Sparse
Codes....................................................................................................................................................... 89
Figure 46: Sample Images of (a) Non-Weed (b) Less-Weeds (c) More-Weeds....................................... 90
Figure 47 : Mean Accuracy of Three Classifiers Trained on SURF Descriptors ....................................... 96
Figure 48: Mean Accuracy of Three Classifiers Trained on SIFT Sparse Codes ..................................... 100
Figure 49: Mean Accuracy of Three Classifiers Trained on SIFT Sparse Codes ..................................... 104
Figure 50: Mean Accuracy of Three Classifiers Trained on Textures Features ..................................... 108
Figure 51: Classification Performance of Three Classifiers Trained on LTP and Texture Features ....... 112

11
List of Equations

Eq 1: Relative Weed Density Calculation (%) .............................................................................................. 22

Eq 2: Normalized Difference Vegetation Index (NDVI red ) Calculation .................................................... 25

Eq 3: Excessive Green (EXG) Calculation ..................................................................................................... 27

Eq 4: Excessive Red (EXR) Calculation ......................................................................................................... 28

Eq 5: Pixel Color Distance Calculation......................................................................................................... 29

Eq 6: Otsu’s Excessive Green Calculation ................................................................................................... 35

Eq 7: Woebbecke Excessive Green Calculation.......................................................................................... 39

Eq 8: Normalized RGB Calcultion ................................................................................................................ 40

Eq 9: RGB to Monochromatic Image Conversion ....................................................................................... 40

Eq 10: Circule Calulation in CHT ................................................................................................................. 64

Eq 11: Parameteric Equation for Circule ..................................................................................................... 64

Eq 12: Parameteric Equation for Circule .................................................................................................... 63

Eq 13: Local Mean Calcultion ...................................................................................................................... 72

Eq 14: Local Standard Deviation Calculation .............................................................................................. 73

Eq 15: Energy Calculation ........................................................................................................................... 74

Eq 16: Contrast Calculation ......................................................................................................................... 74

Eq 17: Correlation Calculation .................................................................................................................... 75

Eq 18: Mean Calculation For GLCM Element i ............................................................................................ 75

Eq 19: Mean Calculation For GLCM Element j ............................................................................................ 75

Eq 20: Gray Level Variance Calculation ...................................................................................................... 75

Eq 21: Gray Level Variance Calculation....................................................................................................... 75

Eq 22: Entrop Calculation............................................................................................................................ 76

12
Eq 23: Prediction Function of Multi-Class Linear SVM................................................................................ 83

Eq 24: Unconstrained Optimixation Problem Defination ........................................................................... 83

Eq 25: Differentiable Quadratic Formula .................................................................................................... 83

Eq 26: Threshold Equation For Local Ternary Pattern ................................................................................ 84

Eq 27: Optimization Equation for Sparce Coding........................................................................................ 87

Eq 28: Quadratic Constraints Optimization Equation ................................................................................. 87

13
I. Introduction

Agriculture plays an important role directly and indirectly in economic growth of Pakistan. Pakistan is
blessed with natural resources favorable for cultivation. Major cultivating crops are wheat, rice, maize,
sugarcane and cotton.

A. Wheat crop production:

Pakistan is the 8th largest wheat producer contributing about 3.17% of the world wheat production
(FAOSTAT)I. Wheat contributes 13.1 percent to the value added in agriculture and 2.8 percent to GDP
(Economic Survey of Pakistan 2008-09). In Pakistan wheat is cultivated in all provinces especially in
Punjab. Hence 57% of the total cultivated and 69% of the total cropped area of Pakistan is covered by
Punjab providence. It contributes a major share in the agricultural economy of the country by providing
about 80% of wheat national food production (Agricultural Statistics of Pakistan 2008-09). Unfortunately
population of Pakistan is increasing year by year (2.5% per Annam) but the production of wheat is not
accordingly.

I
Food and Agriculture Organization Corporate Statistical Database

14
Wheat (1000 Metric Tons)II

B. Weeds:

Now a day’s cultivation is not as easier as in past. Now different types of weeds and insects have been
grown on crops and affect their productivity. Weeds are unwanted plants that compete with crops for
nutrients, food and water and in some cases light. Weeds not only affect productivity, they also
deteriorate crop quality, making them harmful for human and reduce fish production. Weeds present in
wheat fields are commonly divided into three types of weed (a) narrow weed, (b) broadleaf weed and
(c) grass like weed [1]. Broadleaf weeds may have oval, heart shape, linear and eclipse etc. Grass weeds
have long and narrow leaf as compared to broadleaf weeds and have veins parallel to each other.

II
Economic Research Service, USDA, 2012-2013, http://www.whichcountry.co/top-10-largest-producers-of-wheat

15
Figure 1: Leaf Shape of Broadleaf Weeds in Wheat

Figure 2: Grass like Weeds in Wheat

16
C. Weed Management and Control:

Weed management is very critical in crop production because removing unwanted weeds increase the
production cost of crops. Proper weed detection is the key point of weed management. Weed
identification must happen early in the growing season so that weed competition can be reduced by
appropriate control measures. Weeds reduce wheat productivity and their late detection increase
wheat production cost. In Pakistan bout 44% farmers reported 20-30% yield losses in wheat, 30% of the
farmers reported 31-40% and 17% farmers reported 41-50% wheat yield losses [2].

Traditional weed management and control methods need a lot of human labor and effort to inspect
fields at proper time and spray herbicides. Beside this we are living in an era of technology where
technology is available in every field. A lot of work has been done to automate weed detection. Many
robotic systems have been developed to detect weeds using computer vision and classification
algorithms. These technologies help farmers to know about the plant heath, presence of weeds, its
location and density on crops so that they can schedule water supply and spray of herbicides.

D. Problem Statement:

There is a demand for a rapid increase in the production of wheat in worldwide either by increasing the
area under cultivation or by increasing productivity. We can’t increase area for cultivation so all studies
focus on increasing wheat productivity. Among rural households wheat is the largest single consumption
item, while among urban households it is the second largest consumption item following housing [3].

E. Traditional methods:

There are many problems with traditional methods of cultivation. First, often farmers take
measurements of soil properties, weed density and plant nutrient from one place. Considering highest
concentration of weeds, farmers apply a uniform dosage on whole fields while weed density might vary
locally in the field. Some parts may have high concentration of weeds and others may have less or no
weeds. Unnecessary dosage of herbicide is harmful for crop and herbicides are expensive too. For
economical and beneficial usage of herbicides, farmers do need techniques which can evaluate whole

17
field so it can be possible to treat each part of the field according to its need. Second traditional field-
scouting methods are labor intensive and time consuming.

F. Precision Agriculture (PA):

The goal of precision farming is to maximize profitability and minimize environmental damage by
managing each part of an agricultural field at just the right time, using just the right amount of fertilizer
and/or pesticide [4]. By adapting the local density of weed in fields we can increase the productivity
investing less cost and with less impact on the environment

G. Uncontrolled lightening condition:

With the advancement in agriculture precision technology, researchers have started working on using
machine vision technology in agricultural field. Imaging techniques and computer processing speed has
encouraged researchers to develop robotics systems with camera based vision system for local weed
detection and removal in fields. These tasks must be carried out with the highest accuracy and
robustness possible under adverse and highly variable outdoor illumination conditions, which are the
natural lightening conditions in fields. Different weather condition such as cloudy and sunny affects
weed detection. Placement and working of physical vision device is important use for image acquisition
in fields.

Apart from uncontrolled illumination, computer vision systems also face another challenge of un-even
lightening condition due to shadow of adjacent crops. In such images, some objects become darker that
makes it difficult to distinguish them from soil. Human eye can see non-uniformly illuminated objects
clearly except in extremely bright or dark conditions. Human eye applies a local threshold to each
individual area of its focal length.

18
II. Related Work

Pakistan is an agricultural country and wheat is the principle food of the country. In Pakistan, wheat
being the staple diet is the most important crop and is cultivated on the largest acreages in almost every
part of the country. It occupies 70 percent of the Rabi crop and 37 percent of the total cropped area in
the country (Agriculture Statistics Pakistan 2001-02). Weed infestation is a serious problem in wheat
crop. It is estimated that in wheat yield losses range from 20% to 40% due to weeds [5]. Losses in wheat
yield due to weeds amount to more than Rs. 28 billion at national level and Rs. 2 billion at provincial
level in KPK [6]. Weeds are known to be very competitive in obtaining moisture, sunlight and nutrients.
This competitive nature will unfortunately affect the crop yield [7]. Weeds deteriorate the quality of
farm produce and consequently reduce the market value [8]. With a large variation in weed occurrence,
detection of unwanted weeds on wheat crops is still challenging. In this section a detailed description of
the research work and its results that has been done so far for weed detection is discussed. Furthermore
weed evolution surveys and studies are also covered in this section.

Production of Major Crops (1000 tons) III

III
Pakistan Bureau of Statistics 2012-2013 , http://www.aamirilyas.com/economic-survey-of-pakistan-2012-13-pdf/
19
A. Weeds in Wheat crops in Pakistan

Many studies and surveys have been done in this domain to evaluate weeds in wheat crops in different
regions of Pakistan. To develop a generalized accurate algorithm for weed detection, it’s important to
assess all types of harmful weeds found in different wheat cultivation areas of Pakistan. Recently a study
is conducted to investigate the major weeds of wheat in Khyber Pakhtunkhwa province. Data is collected
from D.I. Khan, Lakki Marwat, Kohat and Peshawar during the peak season of weed growth. Four
parameters (relative density, relative frequency, relative canopy coverage and Importance Value Index)
are used in this study. After applying ecological formulas they have found that Avena fatua as a most
problematic weed which is broadleaf weed. While, Rumex dentatus at D.I. Khan, Phalaris minor at Lakki
Marwat and Peshawar, and Rumex crispus at Kohat are the second major weeds [9].

Another study is conducted in Dera Ismail Khan District during 2008-2013. Relative weed density (%) or
species wise weed density is calculated using given formula. Weed flora of the study area is comprised
of 32 weed species. Among them they found seven most dominating weeds including Avena fatua,
Phalarus minor, Rumax dentatus, and Chenopodium album [10].

Relative Weed Density (%) = Eq 1

To find ecological characteristics of weed in wheat fields, a study is conducted in Lahore, District Swabi.
Study area comprise of four localities in irrigated area and one in barani area. The density and frequency
of weed spices are converted to relative values and summed up to obtain importance values (IV).
According to the study the losses caused to agricultural crops by Avena, Cyperus rotundus and
Chenpodium album are significant [11].

Invasive weeds are one of the prominent threats to the local biodiversity as invasive weeds cause huge
health, environmental and economic losses throughout the world [12]. A study is conducted to identify
invasive weeds in the southern part of Khyber Pakhtunkhwa. Invasive species affects indigenous species
adversely on a global level. Environmental factors like Climate, pollution and habitat degradation are
promoting factor for invasive weeds. For this study they purposely introduced Prosopis juliflora through

20
linear plantation along roadsides from where it spreads to cultivation area and cause 50 other species to
become aggressive. This study reported 12 weeds as highly invasive that include Avena fatua, Carthamus
oxyacantha and Conyza bonariensis etc [12].

B. Weed Detection Approaches

There are different approaches for weed detection. They can be categorized as follows

Weed Detection
Approaches

Automatic
Manual Weed
Weed
Datection
Detection

Remote Computer
sensoning Vision

Satellite Ground Based Shape Analysis Texture Analysis Geomatrical


System System Method Method Methods

Photo Hyperspectral
Detectors Methods

Figure 3: Weed Detection Approaches

21
C. Manual Weed Scouting

The earliest and the simplest of all technologies is manual weed detection. In manual weed detection
farmers and specialists check plants with naked eye and use their expertise to evaluate plant health and
presence of weeds. Manual weed detection using human eyes, provides very effective results, but
requires substantial human effort and energy. Manual weed sampling is time- and cost-intensive
therefore cannot be economic in a wider practice [13]. Another important issue in manual scouting is
sampling. Less sampling increases the risk of useful information loss in due to spatial variability.
However more sampling requires more effort and labor cost but gives correct information. Thus to
automate farming, manual method using Human expertise is now changing with artificial trained model,
image processing and reflection methods etc to provide reliable and robust results.

D. Automated Weed Detection

The automatic weed detection is mainly classified into two categories: remote sensing and computer
vision method which are future divided. Satellite and ground based system are sub divisions of remote
sensing. Photo detector comes in ground based systems which is used to discriminate soil from
vegetation. Spectral and all methods of computer vision including geometry and shape/texture analysis
are used for weed crop segmentation.

E. Remote Sensing

Remote sensing can be defined as a technique use to get information of objects from a distance,
without being in contact with objects. Remote sensing is based on the reflection of electromagnetic
radiation. When electromagnetic energy strikes crop/plant coming from sun, three things absorb,
transmit and reflect can occur with energy. Remote sensing used this information that how much energy
is reflected, absorbed or transmitted to determine leaf color, texture and shape etc. The relationship
between reflected, absorbed and transmitted energy to determine spectral signatures of individual
plants [14] which are then use to identify different plant species.

22
1. Satellite Systems

QuickBird satellite images are taken and used to detect weed in the fields of sugar beets. Experimental
results are compared with data gained after applying weedscanner technique [15] on same area. After
obtaining multispectral satellite images’ following equation is applied on a subset of images. NDVI is
calculated from the red and near infrared wavelength that are reflacted.

Eq 2

Finally a supervised classification of whole sugar beets field is done by calculating NDVI of a weed patch
in tracking area .Results showed that satellite spectral imagery is very useful for site specific herbicide
application but non broadleaf weeds are not detectable with QuickBird imagery [16]

In another work digital multispectral camera is used to detect weeds in soybean fields. Whole field area
is divided into 1400 sample of one squre meter each. Weed then calculated by hand counting for each
sample. Discriminate analysis techniques is used to detect weeds in satellite images. Results showed
that major weeds are detected with 75% accuracy which even more where weed density is greater.
There are misclassifications in no weed areas due to variable soil conditions [17].

In one research color images with less than one centimeter resolution is taken from remote control
aircraft. Gabor filter is used to discriminate weeds from crop rows. This technique gave good results in
corn, onion and sugar beets fields. But is unable to detect weed within crop rows [18]

Satellite remote sensing is limited because of insufficient resolution and limited viewing windows.
However, aerial imagery techniques have been used for many years for monitoring the spread of disease
across specific crops [19].

23
F. Ground Based Systems

In ground based methods, high spatial resolution sensors are used that are mounted on tractors or
other field equipment. There are two major categories of ground-based methods, photodetectors and
hyperspectral imaging.

1. Photodetectors

Early on, photodetectors are used to distinguish vegetation area from soil. Spatial resolution is the field
of view of photodetectors. Photodetectors can estimate average greenness in its field of view by
measuring the amount of NIR and visible light reflected. So we can find vegetation coverage in the area
from sensor readings.

A photoelectric sensor based on a tungsten–halogen light source is developed to find the presence of
seedlings by scanning the ground and application of herbicide. Light reflected from ground is split into
visible and NIR. Vegetation area then is detected by measuring the ratio of visible to NIR. The ration is
less for leaves as compared to soil. For herbicide application a handlheld spray is used which triggered
when vegetation area is found out. Results showed that both sunlight and soil reflectance properties
effect performance of the sensor [20]

In another research photoelectric sensor is used for post emergence herbicide application within each
row. For weed detection NIR source and photoreceptor is used. In this work spray system is mounted on
a vehicle and a logical control circuit is designed to operate spray nozzle. Experiments are conducted in
soybean fields and results showed a 15% reduction in herbicide usage without adverse affect on weed
control [21].

2. Hyperspectral Imaging

Hyperspectral imaging, like other spectral imaging, collects and processes information from across the
electromagnetic spectrum; it divides the spectrum into many more bands. This technique of dividing

24
images into bands can be extended beyond the visible. Engineers build sensors and processing systems
to provide such capability for application in agriculture [22]. Spectral differences between plant species
may lead to the ability to separate wheat from weeds. In spectral approaches biggest challenge is to
determine the spectral changes that are robust against variable lighting conditions.

The study used ground-level image spectroscopy data, with high spectral and spatial resolutions, for
detecting annual grasses and broadleaf weeds in wheat. Ground level images are taken from spectral
camera. Fractional coverage assessment id done on each image to distinguish it in four classes: wheat,
soil, grass weed and broadleaf weed. Then images are transformed into raletive reflectance values
followed by spectral resampling. Image pixels are used as cross-validation. This approach gives 85% of
total accuracy and showed that high spectral and spatial resolutions can provide separation between
wheat and weeds based on their spectral data [23].

A research has been done to detect grass and broadleaf weeds in wheat and chickpea fields. Spectral
relative reflectance of leaf and canopy scale values for four classes’ wheat, chickpea, grass weeds are
calculated using field spectroscopy. The General Discriminate Analysis method is then used to classify.
The red-edge region is the slope connecting the low red and high NIR repentance values in the spectrum
of vegetation and is an important indicator for spectral separation of different plant species [24].

A research has been done to detect dicotyledonous weeds in wheat using hyperspectral imaging.
Spectral standardization algorithm is used as a spectral preprocessing step to overcome the lightening
conditions. Partial Least Square Linear Discrimination Analysis (PLS-LDA) discrimination model is used to
discriminate wheat varieties and weed. In this research 8% prediction error is recorded on test set [25].

G. Computer Vision

Reducing herbicide usage in fields is an important aspect in precision agriculture. So only weed density
area should be sprayed. Apart from remote sensing, some research work has been done on weed
management and control using computer vision. The purpose is to develop an intelligent computer
vision system that can be mounted on agricultural mobile robots. Some work has been done focusing
on imaging processing and morphological operation to distinguish weed shape from. Many supervised
25
and unsupervised classifiers such as ANN, k-nearest neighbor, bayes classifiers and discrimination
analysis have been used to detect weeds. For classification shape and textural features has been
extracted using Gabor and wavelet transforms. Fuzzy logic and Genetic algorithm have also used in
agricultural field for weed detection. Some techniques have proposed considering row crops and detect
weed in between rows but first eliminating row crops. Many of these techniques are discussed below.

1. Shape Analysis Techniques

In these techniques individual plant is assessed weather it is crop or weed. There are two major trends
to discriminate weed from crop based on shape features, first is using image processing techniques and
second uses classifiers.

In paper two methods to differentiate carrot plant from ryegrass and Fat Hen (Chenopodium album)
weeds has been proposed. The first approach directly uses the leaf shape as the only discriminate and
gives correct classification rates between 52% and 74%. The second method consists in a self-organizing
neural network that discriminates plant types with accuracy above 75% without prior knowledge [26].

A back propagation neural network is used to discriminate weed in corn fields. Soil background is
removed using image processing. Excessive green (EXG) and excessive red (EXR) intensities are
calculated from following eq(3)(4). Gray level image is obtained by subtracting EXG – EXR. In gray level
images soil is represented as black background. Wavelet transform is used to extract features. These
features and fractional dimensions of weed/corn images are used as parameters to BPNN.
Monocotyledon and dicotyledon are separated out with 100% accuracy while weed and corn are
classified with 77.14% accuracy [27].

EXG = 2 Eq 3

EXR = Eq 4

26
In another paper weeds are detected in cabbage and carrot fields by developing Fuzzy logic. Images are
acquired from a camera that gives provides controlled lightening conditions. Eight morphological and
three color features are selected to form feature space. Color space transformation and binerisation is
done as pre-processing. Morphological operator ‘Erosion’ is used for segmentation. After feature
extraction, weighted and non weighted parameter are selected for membership function using training
dataset. Results showed that color features increase accuracy. 51 to 90% plants are correctly classified
[28].

Considering specific shapes of corn leaves and leaf vein structure, a method has been proposed in which
frequency filter as well as edge density filter is used. Euclidean distance is used in preprocessing step to
eliminate soil using following Eq(5).

Pixel color distance = Eq 5

Images are converted into gray scale before applying modified edge detection. Edge detection is
performed using according to the following algorithm. The algorithm can be extended to columns as
well.

Figure 3: Edge Detection Method on Rows

For frequency filter images are divided into cells and FFT2 is applied on each cell. Similarly density filter
is applied on each cell. Density filter counts the number of white pixel in each cell and categorize each

27
cell as background, weed or crop based on threshold. Cell size is very important for correct results.
Fisher linear classifier (FLD), a linear classifier is used to calculate cell size for both frequency filter and
density filter. Results showed that weeds have more frequency and density then crop. Weed plants are
detected with 92% accuracy [29].

Figure 4: Flow Chart of Weed Detection using Fast Fourier Transform

2. Textural Analysis

Shape analysis techniques have limitation because they need to analysis of individual leaf. Some other
techniques are based on Textural analysis. Texture features mostly includes intensity and energy.

In a research texture based weed detection technique has been introduced. Low level Gabor wavelet is
used to extract features while high level neural network is used for classification. Both spatial and
spectral frequency textural features are used to distinguish broadleaf and grass like weeds. On a set of
sample images different experiments are performed to find appropriate frequency level and filter

28
dimension for feature extraction. A three layered feedfarward neural network with eight hidden nodes
is used to classify broadleaf and grass weeds. 100% classification accuracy is reported [30].

Figure 5: Flow Chart of Bayes Classifier Method for Weed Detection

In a research paper, two methods have been proposed two detect weed in lawn based on textural
features. In first method color images are converted into gray images and Sobel edge detector is
applied. Images are then process window wise (17*17) and find local mean and variance for each
window. Mean and variance are used as input of bayes filter. In post-processing dilation and erosion is
applied on bayes filter results. Second method also use texture features of edge images to detect weeds
but only morphological operators are used. 82.60% weeds are correctly detected in first method while
with 91.11% accuracy in second method [31].

29
Figure 6: Flow Chart of Weed Detection Using Morphological Operations

3. Crop Row Elimination

Another approach to detect weeds exploits the pattern where crops are in row and weeds are usually in
between rows as in fig. In such methods vertical lines are find out assuming these are crops and then
weeds are detect by measuring edges of row crop.

A method consisting of two processes has been introduced. First process is image segmentation that
divides digital images into cells delimited by crop row centres and fixed horizontal space. Area based
attributes of each cell measures the relation between crop and weed. Second process is decision making
based on Support vector machine. Content of each cell is then provided to a trained support vector
machine classifier to identify whether it should be sprayed with herbicide or not. They correctly identify

30
85% of the cells to be sprayed [32]

Crop
Weed

Figure 7: Weeds between Two Rows

In this paper weed detection is divided into three steps. For each steps different interchangeable
methods has been discussed. Images are taken in sunny as well cloudy day. Images are processed
through soil segmentation methods S1 and S2, crop row elimination E1, E2 and E3 methods and weed
extraction F1 and F2 methods. In segmentation soil is segmented from vegetation area. The purpose of
crop row elimination is to detect those part of vegetation area that are part of crop leaving weeds
untouched. It is the most difficult part of the weed detection. Last step is used to detect weeds. At the
end genetic algorithm is used to find out best combination of the methods for each step given images.
Combination of S1–E3–F1 and S1–E3–F2 both give accuracy up to 90% on both dataset sunny and cloudy
[33]

Another attempt is made by developing vision based robot for automatic weed detection. Multiple
image processing techniques are used to find out space between rows and Hough transform is used to
calculate current orientation and position. K-means clustering is used for color segmentation in pre-
processing to classify soil and vegetation. After segmentation automatic ROI selection is performed and
image is converted into gray. Crop rows are detected using parameterized Hough transform which
process 100 pixels at a time for optimization. Orientation and position of the crop are used as
parameters. Experiments are performed on both real and synthetic images [34]

31
Figure 8: Flow chart of Inter Row Weed Detection using Hough Transform

H. Weed Type Classification:

Weeds can be differentiating on the basis of weed leaf. As mentioned earlier weeds are mostly grass
like, narrow and broad. Many researchers worked on weed classification using image processing.

A research has been done to classify weeds [35]. This Algorithm used image processing to extract shape
and textural features and then clustering and classification is performed. 11 shape and 5 textural
features is used. Shape features include aspect ratio, rectangularity, perimeter ratio, circularity, and
compactness etc. Texture features include energy, entropy, contrast, inverse difference moment and
correlation. In preprocessing excessive green is calculated according to Eq(6) followed by binerization
based on Otsu’s threshold. Otsu’s threshold is used to minimizing the intra class variance considering

32
that image consist of two types of pixels background and weed. Erosion and dilation is performed to
extract shape features. Discriminate Analysis is used to classify. Results showed 82% accuracy.

Excessive Green= 2 Eq 6

Figure 9: Weed Classification based on Discriminate Analysis

A real time machine vision system has been developed to locate weed density. Proposed solution is
capable to classify broad and narrow weeds for selective herbicide application. Colored input image is
converted into gray level image. A 3*3 mask is applied to reduce unnecessary information. Finally
proposed edge junction linking is performed to classify weed shape and type. The results showed 93%
accuracy on 240 sample images [35].

33
Figure 10: Flow Chart of Weed Detection Using Edge Link Detection

I. Summary:

Literature review of the previous research suggested that

 Local weed detection and removal required for precision agriculture is possible and may results
a noticeable reduction in herbicide usage.
 Automatic weed detection is highly desirable needed by the farmers.
 Satellite based remote sensing is limited by special, spectral and temporal resolution of sensors
used in satellite imaging

34
 Ground based remote sensing weed detection and plant discrimination techniques are more
successful then satellite because of high spatial resolution.
 A few researches have been done using hyperspectral imaging mainly because of sensor
availability and it is costly.
 Segmentation techniques for soil elimination using thresholding and excessive green methods
have been extensively used in almost all researches.
 Shape and texture based techniques use image processing for feature extraction and then
classifier for weed detection
 Crop row elimination methods can be successfully used to find weed density in crops that are
plant in rows.
 Most of the weed detection has been done in corn field.
 In vision based system weed detection in weed is done by learning and classification.
 Research in the field of weed detection and discrimination from crop using both computer vision
and remote sensing is extensible.

35
III. Weed Detection Using Image Processing

From the prior literature review, it can be seen that no work has been on weed detection in scattered
wheat crop using image processing. Shape and texture based weed detection methods mostly use
learning and classification other assume certain constraint on shape and color. For example corn leaves
are smooth then its weeds [29] or weed are darker and broad then grass [31]. The proposed algorithm is
aimed to detect weed in scattered wheat fields where weed are any where overlapped with wheat
leaves and have same color as wheat. Proposed algorithm use both shape and textural features together
to discriminate weeds. It consists of two stages. These two steps are as follows.

1. Soil and vegetation segmentation.


2. Weed and wheat discrimination.

A. Soil and vegetation (weed and wheat) segmentation:

The first step in weed detection methods is mostly vegetation (weed and wheat) segmentation from soil
background. This step can be considered as pre-processing. This step not only reduces the data to be
processed in further stages but it also makes the weed detection easier by preserving vegetation area
only. Due to the fact that vegetation pixels have more green color then soil, color based vegetation
indices (red, blue and green pixel value) are mostly consider for this step. Most famous methods which
is used in many research paper is normalized excessive green method proposed by Woebbecke et al. in
1992 [37]

Eq 7

Where g, r and b are calculated as follows

Eq 8

36
Euclidian distance is also used for color segmentation to remove soil [29]. The object of this stage is
convert input colored (RGB) image into black and white image where white depicts the vegetation area
and soil is converted into black background.

In proposed method soil segmentation is consist of 2 steps inspired from [32].

 The first is to convert the colored input image into one dimensional gray level image according
to the following eq(9).

Gray (i,j)= r +
Eq 9

Here and are the non-normalized red,


green and blue values at each pixel (i,j). r, g and b are coefficients.

 Then a thresholding technique is used to convert the gray level image into binary image to
represent vegetation area as white and rest as black.

Binary (i,j) =

B. Weed and wheat discrimination

Next stage is to eliminate a part of white area that is actually wheat crop. The output of this stage will be
the images contain only broadleaf or narrow weeds. This is the toughest and crucial stage because weed
and wheat has same color and crop is scattered. In proposed method this stage is also further divided
into two steps as follows:

37
1. Shape based detection
2. Texture based detection

Both of these step use image processing techniques to detect weeds. At the end the results of above
mentioned stages are OR to get final better result.

1. Shape based detection:

This step is based on the leaf shape to detect weed using image processing. Leaves of mostly weeds are
broad, small and somewhat circular shaped as compared to wheat leaves. Wheat leaves are long,
narrow and blade shape. Considering leaves characteristics of weed and wheat, this step detect weeds
based on area and radius. Morphological operator ‘open’ is used to find that white parts in the image
whose connected area and radius is greater than threshold.

Morphological Operator ‘OPEN’

Morphology:

Morphology is a broad set of image processing operations that process images based on shapes.
Morphological operations apply a structuring element to an input image, creating an output image of
the same size. In a morphological operation, the value of each pixel in the output image is based on a
comparison of the corresponding pixel in the input image with its neighbors [38]. Size and shape of the
neighborhood is chose to define the structuring element.

Morphological opening:

It is actually erosion followed by dilation using same structure element for both operation. The
structuring element should be single structuring element object instead of array [39]. In morphological
operation erosion and dilation, the state of any given pixel in the output image is determined by
applying a rule (defines operation as erosion or dilation) to the corresponding pixel and its neighbors in

38
the input image. In dilation, the value of the output pixel is the maximum value of all the pixels in the
input pixel's neighborhood. In a binary image, if any of the pixels is set to the value 1, the output pixel is
set to 1. In erosion, the value of the output pixel is the minimum value of all the pixels in the input
pixel's neighborhood. In a binary image, if any of the pixels is set to 0, the output pixel is set to 0 [40].
Neighborhood of the interested pixel is defined by structuring element.

Structuring Element:

In morphological operators structuring elements are important parts use to probe the input image.
Structuring elements are usually two dimensional or flat matrixes of 0’s and 1’s. The centre pixel of the
structuring element is known as origin and it is the pixel of interest. In three dimensional or nonflat
structuring element 0’s and 1’s determine the extent in x and y axis with additional parameter height for
third dimension.

In proposed method morphological operation ‘open’ is used that is sensitive to specific shapes in the
input image. To specify the shape, disk shaped flat structuring element is used for morphological
opening.

2. Texture Based Detection:

Wheat leaves are long and narrow with rough edges. Amount of activity in terms of energy is higher in
wheat part as compared to weeds. So wavelet transform is used to exploit this characteristic for weed
detection. Fourier transform can also be used to detect higher activity areas but we need location of
each frequency also which Fourier transform does not give.

Wavelet Transform:

Wavelet transform has become a powerful tool in signal processing and image processing. Wavelets are
a set of localized basis function with powerful capabilities such as orthonormality, locality in frequency
and time domains, fast implementation and maybe compact support [41]. For image processing two

39
dimensional wavelet transform is used. The theories of multiresolution analysis and wavelets can be
generalized to higher dimensions. In practice the usual choice for a two-dimensional scaling function or
wavelet is a product of two one-dimensional functions. For example,

In proposed method two -dimensional discrete wavelet transform is applied on binary image which is
produced in stage 1. After that diagonal sub-band coefficients are extract out which have higher
intensities on wheat part. Threshold is applied on sub-band coefficient to remove wheat area. At the
end morphological operator ‘dialation’ is used to detect weed area.

At the end a logical operator ‘OR’ is applied on the results of shape and frequency based detection steps
to get the final results.

40
C. Shape and Frequency Based Weed Detection Algorithm:

Input Coloured Image (RGB)

Excessive Green
Monochromatic Image

Binary Image after


Thresholding

Morphological opening Wavelet transform

Thresholding on digonal
sub-coefficient

Dilation

Logical OR

Resulted image

Figure 11: Flow Chart of Shape and Texture based Weed Detection

41
IV. Experiments and Results

A. Datasets

Colored images were obtained in April 2014 from wheat farm in Lahore. Camera used to capture images
has resolution: 1920x1080 (HD Video at 30fps). Video is taken at height of 1-1.3 m in sunny day with
clear weather around 2:00PM-4:00PM. Dataset contains images of all six stages of wheat.

B. Experimental Setup

The image processing and weed detection has been carried out on a laptop with a Intel Core i3
microprocessor, 2.00 GB of RAM and the Windows 7 operating system. Proposed algorithm has been
implemented using image processing toolkit of Matlab 2013a. 35 images have been used in
experiments.
In this section, Experimental results have been shown on two test images due to space constraint.
Experimental results of each stage with different parameters have been given below.

C. Stage 1: Soil and Vegetation Segmentation

First convert the colored image into monochromatic image according to the equation Eq(9). R, g and b
coefficients are assigned as follows.
g=2
b = -1
r = -1
So Eq (9) becomes

Gray (i,j)= (-1 + )

42
Figure 12: Monochromatic Image of Test Image1

Above figure shows monochrome image after applying excessive green equation on the input
RGB image. Left part of figure 12 shows original test image 1. On right side is the monochrome
image. Vegetation area is become bright in monochrome image.

Figure 13: Monochromatic Image of Test Image2

Resultant monochrome test image 2 excessive green conversion is shown in the above figure 13.
Soil area is dark with respect to vegetation area.
43
Next convert the gray level image into binary using thresholding technique as in Eq(10).

Put
Threshold = 227

So Eq (10) becomes

Binary (i,j) =

Figure 14: Thresholding on Test image1, Threshold=227

A thresholding technique is applied on monochrome image to get binary image. Threshold value is set to
227. Resulted binary image is shown above. In binary image soil is represented as black and vegetation is
represented as white area.

44
Figure 15: Thresholding on Test image2, Threshold=227

Above figure shows the thresolding result on second test image with threshold value equal to 227.
Thresholding technique is used to eliminate unnecessary information which I soil in my case. After
thresholding images contain only vegetation.

Change threshold value:

Figure 16: Thresholding on Test Image1, Threshold=195

45
In these experiments different combination of coefficient values (r,g,b) and threshold have been tested.
In previous results threshold value is set to 227. Above figure 16 shows the result binary image with
threshold value set to 195.

Figure 17: Thresholding on Test Image2 with Threshold=195

Soil segmentation result on test image 2 is shown above. This image is obtained by first converting RGB
image into monochrome image and then thresholding is applied with threshold value is equal to 195.

Change r, g and b coefficient values.

In experiments monochrome convertion is done using different coefficient combinations. Another


combination of coefficient is as follows

g = 0.588
b = 0.136
r = -0.7

46
Figure 18: Monochromatic Image of Test Image1 with r=-0.7,b=0.136,g=0.388

For monochrome conversion, different combination of parametric values (r,g,b) has been tested. The
above monochrome image is obtained by setting multiplying parametric values as r=-
0.7,b=0.136,g=0.388. Figure 19 shows the monochrome conversion result on test image 2.

Figure 19: Monochromatic Image of Test Image2 with r=-0.7,b=0.136,g=0.388

47
Convert gray level image into binary image:

Image conversion from gray-level to binary image with the threshold value set to 90 is shown below.

Figure 20: Thresholding on Test Image1 with Threshold=90

Above figure shows the resultant binary test image 1 with threshold value is set to 90. It can be seen
that a lot of vegetation area is get removed along with soil. Binary test image 2 with the same threshold
is shown below.

Figure 21: Thresholding on Test Image2 with Threshold=90

48
Comparison of monochromatic images with different coefficient r, g and b combinations.

Comparison of monochrome images with different coefficients r, g ,b is depicted in the following figure.
Left of figure 22 is the monochrome image with the coefficients set to r=-1, g=2, b=-1. On the right side
is the monochrome image with coefficients values g=-0.388, r=-0.7, b=0.136. it is evident that left side
image is better monochrome image so I concluded that r=-1, g=2, b=-1 is the best coefficient
combination for monochrome conversion.

Figure 22: Monochromatic Images with Different RGB Values a) r=-1,g=2,b=-1, b) g=-0.388, r=-0.7, b=0.136

Comparison of binary images with different threshold value.

In experiments different threshold values are used to convert monochrome image into binary image
which is the output of soil segmentation phase. Binary images with different threshold values are
compared to check best threshold value for soil segmentation. Figure 23 shows the comparison of
binary images with different thresholds. Left side image is obtained with threshold value is equal to 227
and right side image is obtained by setting threshold value as 90. Left side image with threshold 227 is
better than threshold equal to 90

49
Figure 23: Binary Test Image1 with Different Threshold a) threshold= 227, b) threshold = 90

In below figure binary image with threshold value 195 is compare with binary image obtained with the
threshold value equal to 90.

Figure 24: Binary Test Image2 with Different Threshold a) threshold= 195, b) threshold = 90

50
1. Results:

Experiments are performed on 35 images and results for soil segmentation are mentioned in table1. It
can be seen from experiments that coefficient values and threshold value play important role. Results
have shown that coefficient values r=-1, g=2 and b=-1 with threshold =195 correctly detect vegetation
area with 99% and soil area with 100% accuracy.

Correctly r=2,g=-1,r=-1 and g=0.588,b=0.136, r=- r=2,g=-1,r=-1 and


Detected Area threshold = 227 0.7and threshold= 90 threshold = 195

Vegetation (%) 98.5% 92% 99%

Soil (%) 100% 100% 100%

Table 1: Results of Soil Segmentation

D. Stage 2: Weed and Wheat discrimination:

1. Shape Based Analysis

Morphological operations of image processing toolkit of Matlab have been used. Disk shape is used for
structural element. Parameter of structuring element ‘strel’ has been used as follows

Parameters:

Shape = disk
R (radius) = 35
N = 4 (n is used for approximation).

51
Figure 25: Morphological Opening of Test Imsge2 with 35 radius

Shape analysis result on test image 2 is shown above. Right side of figure 25 is obtained by applying
morphological operation on binary images with radius is set to 35. Radius is very important to detect
weeds properly because some weeds are large and some are smalls.

Figure 26: Morphological Opening of Test Imsge1 with 35 radius

Shape analysis result with same radius on test image 1 is shown in above figure.

52
Parameters:
Shape = disk
R (radius) = 45
N = 0 (n is used for approximation).

Figure 27: Morphological opening of Test Imsge2 with Radius=45

Morphological opening result on test image 2 with redius is equal to 45 is shown in above figure. Large
broad leaf weeds are well detected with this radius but many small weeds are not detected.

Figure 28: Morphological opening of Test Imsge1 with Radius=45

53
2. Texture based analysis:

The first step is to apply discrete wavelet transform on binary image and extract diagonal sub band
coefficients. This shows high activity at wheat edges. Texture based analysis is performed in parallel with
shape based analysis on binary images obtained after soil segmentation. In texture based analysis
structural or transform approach is used. Two dimensional discrete wavelength transform is applied
first. An appropriate sub-band that is information rich is extracted out. In our case we mostly extracted
out diagonal sub-band coefficients which have higher intensities on wheat part.

Figure 29: Diagonal Sub-band of Test Image1

Above diagram is obtained by first applying two dimensional wavelength transform on binary image
then diagonal sub-band is extracted out. It can be seen that there is more activity in terms of white
pixels in wheat crop and soil area while weed area is mostly black.

54
Figure 30: Diagonal Sub-band of Test Image2

Above figure shows the sub-band coefficients extracted from test image 2 after applying 2-d discrete
wavelet transform.

Dilate Extracted Diagonal Sub-band

After two dimensional wavelet transformation a morphological operator ‘dialation’ followed by


thresholding is used to detect weed area. Dilation is performed on extracted sub-band coefficients.
Dilation is used to connect small white pixel that are close to each other and can form one object. In this
way weeds get prominent as black holes. Dialated extracted sub-band coefficients of test image 1 is
shown in below diagram. Balck holes depicts the presences of weed leaves. Whilte blobs shows the
presence of crop and soil.

55
Figure 31: Dilated diagonal Sub-band of Test Image1

Figure 32 is obtained by first applying two dimentional descrete wavelet transform on binray image and
performing dilation on information rich sub-band coefficients. Right side of figure 32 shows weeds as
black holes.

Figure 32: Dilated Diagonal Sub-band of Test Image2

56
Apply threshold on dilated image:

Figure 33: Weed Detected after Textural Analysis on Test Image1

Thresholding followed by inverse is performed after on dilated image. After inversion weed area is
represented as white. Final result of texture based analysis on test image 1 and test image 2 is shown in
figure 33 and 34. Right side of figures shows weeds as white areas with some noise.

Figure 34: Weed Detected after Textural Analysis on Test Image2


57
3. Apply logical OR

Final result is obtained by applying logical OR on the resultant images of shape based analysis and
texture based analysis. Resulted image contained small white areas that are noise rather than weeds. So
a closing operator followed by is used as a post-processing step. A flat square shaped structuring
element is used in dilation and erosion. Then detected areas greater than threshold are removed. Figure
35 shows the final result of shape and texture based weed detection after noise removal. Green circled
areas are the weeds which were detected by texture analysis and not in shape analysis. Similarly blue
circled areas are the weeds which were detected by shape analysis and not in texture analysis.

(a) (b)

Figure 35: Final result of Shape and Texture based weed detection (a) Original image with weeds marked by red circle (b)
logical OR of shape and texture based analysis results

4. Weed Detection Results:

To evaluate the accuracy of weeds and wheat discrimination step, ground truths images have been
made by manually mark the weed areas in each image of dataset. White pixel count is then used to

58
compare the resulted weed detected image with corresponding ground truth. Table 2 is obtained by
evaluating 30 weed detected out image and then take average.

Combined Shape
Detection Rate Shape Analysis Frequency Analysis and Textural
Analysis

Correct Weeds 72% 69% 74%

False Positive 15% 12% 15%

Table 2: Weed Detection results of Shape and Texture Based Weed Detection

5. Execution Time Results:

Following results are obtained by running above mentioned algorithm on 100 images in MATLAB. This
time is calculated in seconds.

Stages Average (sec) St.dev (sec)

0.38793 0.007912
Soil Segmentation

Shape Based Analysis 1.100188 0.043881

Frequency Based Analysis 0.426933 0.008498

Complete Algorithm 1.978167 0.054903

Table 3: Average and St.dev of Execution Time on 100 images

59
Weed detection rate on all 30 images is shown below. Table 4 shows the weed detection result using
shape based analysis on each one of 30 images and table 5 shows detection rate and false positive using
texture based analysis 0f 30 images.

6. Texture Based Analysis Results

Image No Detection Rate False Image No Detection Rate False


(%) Positive (%) (%) Positive
(%)

1 68 10 11 69.5 12

2 69 14 12 72 15

3 67 13 13 68 16

4 69 16 14 69 15

5 70 15 15 69 13

6 68 17 16 68.5 15

7 69 13 17 65 17

8 69 14 18 69 11

9 68.5 15 19 69.5 14

10 67 14 20 68 12

21 69 13 26 68 16

22 71 15 27 71 14

23 66 14 28 69 13

60
24 68 15 29 69 14

25 70 15 30 70 15

Table 4: Detection Rate and False Positive of Shape based analysis on 30 images

7. Shape Based Analysis Results


Average Average

68.72414 14.63793
Image No Detection Rate False Image No Detection Rate False
(%) Positive (%) (%) Positive
(%)

1 73 10 11 69.5 12

2 69 9 12 72 10

3 70 12 13 75 14

4 74 15 14 70 11

5 70 10 15 69 15

6 74 11 16 72 12

7 72 13 17 73 10

8 70 10 18 69 11

9 74 11 19 74 12

10 72 11 20 72 12

21 69 13 26 72 10

22 71 10 27 75 13

61
23 72 11 28 73 10

24 71 12 29 74 12

25 70 12 30 70 13

Table 5: Detection Rate and False Positive of Texture based Analysis on 30 images

Average Average

71.68333 11.56667

Shape analysis correctly detect weeds more than frequency analysis but in textural analysis the rate of
wrong weed detection (vegetation area is detected as weed) is higher than shape analysis. Results have
shown that alone shape or textural analysis techniques are not sufficient so we have to combine their
result to increase accuracy.

62
V. Weed Detection using Circular Hough Transform:

The main difference between weed and wheat crop is the shape of their leaves. As discussed in shape
and texture based weed detection method that leaves of wheat crop are narrow, long and blade shape
depicted in figure 36 while weed leaves are broad and somewhat circular shaped as shown in figure 37.
To detect weed in scattered wheat crop based on the shape feature, I tired another image processing
technique known as Circular Hough Transform (CHT).

(a) (b)

Figure 36: Weed Leaves Samples

(a) (b)

Figure 37: Wheat Crop Samples


63
Images in figures 36 and 37 are illustrative examples of weed and wheat leaves. Figure 36(a) shows
multiple small weed leaves. Figure 36(b) shows large weed leaves. Figure 37(a) and (a) shows wheat
leaves that are different from weed leaves.

A. Hough Transform:

Object detection in complex images in still challenging in image processing. Because target object may
get obscured due to presence of other objects like in my case weed leaves are mostly covered with crop
leaves. Another problem is that target object may contain noise itself. Due to these factors targeted
objects are not clearly visible for their detection. Hough transforms (HT) are used to detect object based
on shape. The underlying technique of Hough transform is similar to template matching. The HT can be
depicted as a change of a point in a 2 dimensional region to a parameter space, reliant on the state of
the items to be recognized. The advantage of HT over other techniques is its resistance towards noise in
the image. The HT is basically used to detect straight lines but now it is extended to detect circles,
eclipses and other parameterized geometric shapes.

Circular Hough Transform (CHT) is used to detect circular objects. In contrast to standard HT, CHT uses
following equation to compute circles.

Eq 10

In the above equation a and b represent the coordinates for the center, and r is the radius of the circle.
For a circle with radius r and center (a, b) can be described with the following parametric equations [42]:

Eq 11

64
Eq 12

When the angle sweeps through the full 360 degree range the points (x, y) trace the perimeter of a
circle. If an image contains many points, some of which fall on perimeters of circles, then the job of the
search program is to find parameter triplets (a, b, r) to describe each circle [42].

If the circles in an image are of known radius r, then the search can be reduced to 2D. The objective is to
find the (a, b) coordinates of the centers. The locus of (a, b) points in the parameter space fall on a circle
of radius r centered at (x, y). For each edge point, a circle is drawn with that point as origin and radius r
[42]. CHT with 3D can also be used in which first 2D array represents circle coordinates while third
dimension represents radius of the circle.

Figure 38: Each point in geometric space (left) generates a circle in parameter space (right). The circles in parameter space
intersect at the (a, b) that is the center in geometric space.

B. Weed Detection Using CHT:

After the successful experiments of Shape and Texture based Weed Detection algorithm, we devised
another shape based image processing algorithm using Circular Hough Transform. This method exploits
shape differences of weed and wheat leaves and consists of following three steps.

65
1. Preprocessing
2. Color processing
3. Circular Hough Transform

1. Preprocessing:

Firstly input RGB image is sent to preprocessing stage where contrast of input image is enhanced. In this
algorithm histogram equalization is used to increase the contrast. Contrast enhancement not only
improves feature extraction (shape) but it also helps in background removal in next step.

2. Color Processing:

In this stage unnecessary colors and objects are removed to make weed detection in next stage easy and
faster. In my dataset soil information is unnecessary and need to be removed. In this stage color
information is used to eliminate soil background from vegetation (weed and wheat crop) using
thresholding operation. The output of this step is a binary image in which soil is represented as black
and vegetation area is represented as white.

3. Circular Hough Transform:

After color processing image contains weed and wheat crop. Both weed and wheat crop have same
colors so color processing cannot use to discriminate weed from wheat crop. Here shape feature is used.
CHT tries to find circular pattern of given radius with in an image of given by collecting maximum votes.
CHT can be implemented in many ways but all implementation have following three common step:

66
1. Accumulator Array Computation:

Foreground pixels with high gradient are the best candidate for accumulator array. These candidate
pixels are allowed to vote for a pattern around them that makes circle of given radius.

2. Center Estimation:

The votes of candidate pixels belonging to an image circle tend to accumulate at the accumulator array
bin corresponding to the circle's center. Therefore, the circle centers are estimated by detecting the
peaks in the accumulator array.

3. Radius Estimation

Radii are explicitly estimated utilizing the estimated circle centers along with image information. The
technique is based on computing radial histograms.

We have used Matlab function “imfindcircle” in this step to calculate circles. This function takes
radius range as input to find circular objects for given input parameter (radius). This function is efficient
in the presence of noise and occlusion. Instead of 3D this function uses only 2D accumulator array with
an extra step for radius estimation but computational cost remain low. Flow chart of this algorithm is
shown in Figure 39.

Histrogram
Input RGB Color Processing
equalization to
Image using threshold
enhance the contrast

Circular Hough
Output Image
Transform

Figure 39: Flow Chart of Weed Detection using Circular Hough Transform

67
C. Experiments and Results:

Matlab tool is used for these experiments and same dataset of field images is used which were used in
Shape and Texture based Weed detection algorithm. Result of different steps of Weed Detection using
CHT is shown below.

(a) (b)

Figure 40: Test Image1 after preprocessing

Figure 40 shows the result of preprocessing step. Input RGB image is first resized then converted to gray
scale image. Lastly histogram equalization is applied on test image and shown in figure 40(b).

(a) (b)

Figure 41: Color Processing Result after Histogram Equalization

68
The result of color processing on histogram equalized image in shown in figure 41. Figure 41(a) shows
contrast enhanced image and Fig 41(b) shows binary image which is obtained by applying thresholding
technique on the output image of preprocessing step. In binary image white portion shows vegetation
area.

(a) (b)

Figure 42: Result of CHT on test image1

Third step of CHT is very important which is used to detect weed from wheat crop based on leaf shape.
The result of CHT is depicted in figure 42. Figure 42(a) shows input RGB image and Figure 42(b) shows
resulted circles on binary image after applying CHT. Coordinates of circles and radii computed by CHT
are used to draw red circles.

(a) (b)

Figure 43: Result of CHT on test image2


69
The result of CHT on another test image is shown in figure 43. As we can notice that many red circles
are present on wrong places either on soil or wheat which do not represent weed. This method is well
suitable to detect small round weeds but it gives more false positive. It means that CHT detect more
wrong circular objects or weed. The detection rate of weed detection algorithm using CHT is given in
table 6.

Number of Images Correct Weeds False positive

30 59-65% 38-42%

Table 6: Detection Rate and False Positive of Weed Detection Using CHT

Weed detection rate for this algorithm varies from 59% to 65%. Range for false positives varies from
38% to 42%

Number of Images Average (sec) St.dev (sec)

30 10.22 0.12

Table 7: Execution Time of Weed Detection Using CHT

Efficiency of this algorithm in terms of execution time is depicted in table 7. This time is calculated by
running the algorithm in Matlab on 35 images. It takes very long time to compute coordinates and radii
of all circles. CHT is a kind of brute force method and its computation is very complex. CHT has two
major drawbacks. It requires large memory space and it is very slow. Its speed depends on number of
parameters as well. For large number of parameters it becomes slow because for each additional
parameter time complexity increases at the rate O( ), where I is size of the image and n is the
number of parameters. This algorithm on average takes 10 sec which is much more than average time of
Shape and Texture based Weed Detection which is 1.9 sec.

So overall this algorithm of Weed Detection using CHT is not efficient both in terms of accuracy and
processing time.

70
VI. Texture Analysis:

Object detection and recognition is an important field of image processing. We can detect objects based
on three features that are 1) color 2) shape 3) texture. In our case color information is used for soil and
vegetation segmentation. Due to the fact that weed and wheat crop have same colors, we cannot
differentiate them using color processing. In preceding chapters we have described two algorithms for
weed detection based on shape feature. Weed detection algorithm described in chapter 3 is based on
both shape and texture feature. There are two ways to analyze image texture that are structural and
statistical approach. Statistical approach analyzes spatial distribution of gray level intensities while
structural approach defines texture as textural primitives occurring in regular or repeated pattern. In
Shape and Texture based Weed Detection method, structural approach is used to analyze texture using
two dimensional wavelet transform. Texture attributes are a useful tool to segment the image into
regions of interest. Due to its importance a detailed statistical texture analysis of weed and wheat leaves
has been conducted and described in this chapter.

Real life images usually don’t display locales of uniform intensities. These variations of intensities form
repeated patterns known as visual texture. It is difficult to define texture. In image processing texture
can be characterized as a substance comprising of commonly related pixels and grouping of pixels. This
grouping of pixels is called as texture primitives or texture elements (texels) [43]. Many researchers gave
different definitions of texture. Some are given below:

“We may regard texture as what constitutes a macroscopic region. Its structure is simply attributed to
the repetitive patterns in which elements or primitives are arranged according to a placement rule.” [44]

“A region in an image has a constant texture if a set of local statistics or other local properties of the
picture function are constant, slowly varying, or approximately periodic.” [45]

71
A. Statistical Approach:

In statistical approach we analyze the spatial distribution of gray level intensities by computing local
feature, i.e. neighborhood characteristics at each pixel in the image. Depending on the number of pixels
defining the local feature, statistical methods can be further classified into first-order (one pixel),
second-order (two pixels) and higher-order (three or more pixels) statistics [46]. I first-order estimates
we only consider individual pixel value and ignore neighborhood characteristics whereas in second-
order estimates we consider two pixels present at specific location relative to each other.

First-order statistical approach perform some mathematical calculations to find statistics like mean and
variance from original image pixels and ignores the relationship between targeted pixel and
neighborhood pixels. Instead of global mean and variance I have considered local mean and local
slandered deviation to analyze weed and wheat texture. I have calculated mean and st dev for each pixel
with respect to predefined neighborhood. The purpose of computing mean and st dev for each pixel is
to find a range of these attributes for weed and wheat leaves

1. Local Mean:

The mean takes average of gray level intensities of the image being examined. Local mean is a
straightforward technique in which gray level intensity for each pixel x is obtained by averaging the gray
level values of pixel contained in predefined neighborhood. In my case for neighborhood I defined a
window of size 3 3. Local mean for a pixel x can be calculated using following formula.

Eq 13

72
T is the total number of pixels in the neighborhood. m,n,s,..p are the indices of the pixels in the
neighborhood and S is the set of coordinates of pixels in the neighborhood. are the intensities
of f at position m,n,s,..p [47].

2. Local Standard Deviation:

Local standard deviation computes the square root of variation of intensities around the mean in
predefined neighborhood. it can be calculated as follows.

– Eq 14

First-order statistics provide information about distribution of gray level values within an image but does
not provide their relative position. We cannot devise that all low gray level values are grouped together
or they are mixed with high gray level values. Here comes gray level co-occurrence matrix (GLCM) that
stores position information for pixels having same gray level values. It is a 2-dimentinal array P of size
n n where n is the number of gray level vales, in which each entry is calculated by first defining a
displacement factor d and counting all pairs of pixels separated by displacement d having gray levels i
and j [43]. From this co-occurrence matrix we can compute different second-order statistics like
entropy, energy and correlation etc. I have analyzed following second-order statics of weed and wheat
leaves.

3. Energy:

It is also known as second angular moment or uniformity. It measures textural uniformity that means
repetition of pixel pair. It is use to detect textural disorders. It returns sum of squared elements in
GLSM. Its range is [0 1] and for constant image energy value is 1. Energy for an image spectrum can be
calculated as follows:
73
Eq 15

In above equation

p (i,j) = element i,j of normalized symmetrical GLCM ( number of gray level co-
occurrence matrices in GLCM).

N = number of gray levels in the image.

4. Contrast:

It calculates the minimum and maximum gray level vales in the image and defines the image in such a
way that it sets the minimum gray level value to black and maximum gray level value to white. It returns
a measure of intensity contrast between targeted pixel and predefined neighborhood over entire image.
It can be defined using given formula.

Eq 16

In above equation p(I,j) and N are same as in energy. Its range is [0 ]. its value is 0
for constant image.

5. Correlation:

It measures the linear dependency of gray level values in neighboring pixels. It is used to detect noise. It
computes that how much a pixel is correlated with its neighbor over entire image. Its range is [1 -1]. Its

74
value is 1 for perfectly positively correlated image and -1 for perfectly negatively correlated image. And
for constant image its value is NaN. Its formula is given below:

Eq 17

In above formula

P(i,j) and N are same as above

= the GLCM mean, can be calculated as follows

Eq 18

Eq 19

= variance of gray level values of all reference pixels in the relationship that
contribute to the GLCM. And can be calculated as follows

Eq 20

Eq 21

If the image is completely uniform then its GLCM variance will be 0. In this case denominator of
correlation formula becomes 0 that makes correlation undefined.

75
6. Entropy:

It measures the randomness of gray level values. It is the amount of disorder in the image. Entropy has
low values for simple n structured images like crystal. When the image is not texturally uniform then
many GLCM entries have small values that make entropy values large. Conceptually it is inverse of
energy. But the benefit of energy over entropy is that the range of energy is normalized. It can be
defined as

Eq 22

7. Local Range:

Besides all these statistical features I have also analyzed the local range of weed and wheat leaf images
It computes the gray level range (maximum and minimum value) of neighboring pixels around each
pixel.

B. Experiment and Results:

For experiment purpose I took weed and wheat leave sample from dataset. I took 6 samples of weed
and wheat crop leaves in different conditions like (with sun light, overlapped and dark). And find the
range (min and max value) of mean, stdev, entropy, rangefilt , contrast, correlation and energy for
sample leaves. For statistical textural analysis again Matlab tool has been use. Local mean is calculated
using convolution operation with window size of 3 3. For local standard deviation I use a Matlab
function “stdfilt”. It returns an array in which each output pixel contain standard deviation of 3 3
neighboring pixels around corresponding pixel. The size of output array is same as of input image. For
border pixels it uses symmetric padding. But the range of mean and standard deviation foe wheat leaves
covers the range for weed leaves for example local mean range for wheat leaves is 5.4-242.7 which
includes the range of weed leaves that is 15.1-237.2. To calculate local range of sample images I used
Matlab function “rangefilt”. It returns an array in which each output pixel contain local range (minimum
76
– maximum gray level value) of 3 3 neighboring pixels around corresponding pixel. The size of output
array is same as of input image. This texture feature has same problem as of above two. Local ranges of
weed and wheat leaves are overlapping.

For other textural features I used gray level co-occurrence matrix of Matlab. “graycomatrix” function
creates a GLCM. Each element (i,j) in glcm specifies the number of times that the pixel with value i
occurred horizontally adjacent to a pixel with value j. “graycoprops” is another function which is used
after “graycomatrix”. This function takes two inputs. One is GLCM, created by “graycomatrix” function
and second parameter defines the statistics which we want to compute. In my case I have calculate
correlation, entropy, contrast and energy. “graycoprops” function uses normalized GLCM to compute
statistics. It returns a structure with the field of desired statistics. Each field contains a 1 x p array, where
p is the number of gray-level co-occurrence matrices in GLCM. The ranges of all these texture features
for weed and wheat leaves are given below:

Texture Weed Weed Weed Crop Crop Crop


Range
Feature Leaf1 Leaf2 Leaf3 Leaf1 Leaf2 Leaf3
min 15.11 53.55 50.11 5.44 14.55 18.11
Mean
max 197.88 248.00 237.22 255.00 254.66 242.77

min 0 0 0 0 0 0
St.dev
max 57.40 38.49 30.31 122.27 86.07 94.08

min 0.19 0.87 0 0 1.43 1.92


Entropy
max 5.87 5.83 5.84 6.17 6.11 6.11

min 0 0 0 0 0 0
RangFilt
max 167 107 117 252 231 239

min 0.28 0.50 0.34 2.93 1.93 2.05


Contrast
max 0.37 0.67 0.35 4.79 2.71 2.21

min 0.40 0.49 0.73 0.43 0.33 0.37


Correlation
max 0.5571 0.60 0.72 0.65 0.53 0.43

77
min 0.31 0.22 0.24 0.03 0.08 0.06
Energy
max 0.33 0.26 0.26 0.04 0.12 0.07
Table 8: Min and Max Values of Different Texture Attributes of Sample Leaves

Above table shows Min and Max values of different texture attributes against weed and crop sample
leaves. Contrast value for weed leaves ranges from 0.28 to 0.67 while contrast value for wheat crop
varies from 1.93 to 4.79. It shows that contrast maximum value for weed leave is less then minimum
value of contrast for crop leaves which is 1.93. Similarly energy range for wheat crop is 0.03-0.12 which
is less than energy range for weed leaves that is 0.22-0.33. From above mentioned result we can
conclude that contrast and energy can b used as a good feature to classify weed and wheat because
their ranges are not overlapping.

78
VII. Weed Detection Using Support Vector Machine

The use of machine learning algorithm for object recognition has become popular in recent years. It is
generally accepted that machine learning algorithms are more accurate and robust. In the beginning,
Swain and Ballard [48] proposed color histograms as a view- based approach for object recognition. In
this method pixel values are recorded in different color bins but this method depends on lighting
condition. Hence an object can have different color in different lightening conditions. Most of the
objects cannot be described by their shapes only so Schiele and Crowley [49] extended the idea of color
histogram by including some local image features like gradient magnitude and orientation. They tried to
make multidimensional histogram. These methods are accurate and robust against rotation and
deformation but they are not capable to detect objects in complex cluttered images.

Global histograms don’t work well for complex images having many objects. Schneiderman and Kanade
[50] introduced the concept of object categorization in natural scene. They computed histograms of
wavelet transform coefficients. Considering histogram approach Scale-Invariant Feature Transform
(SIFT) was proposed in which position dependent histograms were calculated. Later Speeded Up Robust
Features (SURF) was introduced which is a variant of SIFT and much faster than SIFT.

Machine learning is a field that investigates the development of algorithms that can learn from input
data. Such algorithms work by building a model focused around inputs and utilizing that to settle on
forecasts or decisions. Based on learning style we can broadly categorize the machine learning
algorithms into two categories: Supervised and unsupervised learning algorithms. Supervised learning
algorithm takes an input data along with known labels and builds a predictor model. On unknown data
predictor model generates reasonable predictions. We use supervised learning for classification as well
regression problem. Examples of supervised learning include Artificial Neural Network, Naïve Bayes
classifier, Nearest neighbor and Support Vector Machine etc. In unsupervised learning input data is not
label. A predictor model is constructed by reasoning structures exhibit in the input data. Association rule
learning and clustering are its typical example problems. Unsupervised learning algorithms include K-
means, Apriori algorithm and Ector quantization etc.

79
There are many advantages of using machine learning algorithms some are as follows:

 More accurate than human crafted rules


 Don’t need human interaction or programmer
 Automatic learning
 It is flexible and can apply to any learning task
 Can handle large datasets

Main drawbacks of machine learning method include:

 Required a lot of label data


 Hard to get perfect accuracy

Earlier researches on weed detection also involved many statistical methods and classifiers. To
discriminate weed species Burks et al [51] investigated 33 unique texture features for six classes on
three neural networks (backpropagation, counterpropagation, and radial basis function). It was found
that backpropagation neural-network classifier gave best classification accuracy upto 97% with less
computational requirement. Marchant and Onyango [52] did a comparison of Bayesian classifier and
multilayer feed-forward neural network in a task of discriminating plants, weeds, and soil in colour
images. They concluded that if we have less number of feature that require small amount of storage
then Bayesian classifier is preferred over a feed-forward neural network. Goel et al [53] investigated
that there is potential of using decision trees in the classification of hyperspectral data for crop
treatment based on the weed condition. Yang et al [54] reported details regarding improvement of a
image aquacision and processing system for weed detection and a fuzzy logic decision-making system
for selective herbicide spray. This examination showed that a fuzzy logic system has the capacity that
comprehend and encourages the representation and processing of human information in machine and
the inputs, outputs, and tenets of FL are not difficult to change.

80
A. Weed Detection Using Multiclass Linear SVM

In this section I have proposed an algorithm that determines the presence of weed in wheat crop based
on weed density. This method uses a multiclass linear SVM that classifies field images into 3 categories
1) no weed 2) less weed 3) more weeds. I have trained this multiclass linear kernel SVM on different
feature set like local ternary pattern, SURF, SIFT and texture features to find best feature set for weed
detection. For comparison purpose Back-propagating neural network and non-Linear Gaussian Radial
Basis Function kernel (RBF) SVM have been used. Detail of these feature sets, SVMs and neural network
is given below.

1. SVM:

Support Vector Machines are a group of supervised learning techniques popular for classification and
regression. They can be used to train classifiers for polynomial, neural network, or radial basis functions.
It was developed e 1990s based upon the theory of statistical learning. It is an extension of nonlinear
models developed by Vladimir Vapnik. Basically, SVM is a binary classifier, which scans for the ideal
differentiating hyperplane that expands the margin between two (alternately more) classes and
minimizes the generalization error. Margins define the width of area parallel to hyperplane that has no
interior data points. For binary classification we can depict SVM as follows.

Figure 44: Separating Hyperplane between Positive and Negative Training Sample

81
Above figure shows a decision boundary between positive and negative training samples. Data points
that are closest to the separating hyperplane and on the boundary of the rectangle area defined by
margin are known as support vectors. The SVM is famous for its robust execution even in the presence
of scattered and noisy data but at the same time it is not user friendly. Therefore SVM has been
seriously investigated for last few years and connected to an extensive variety of issues like text
classification, speaker identification, face detection, tissue classification, object recognition and corn
root classification. In a large portion of these studies, SVM either significantly beat or possibly matched
the practically identical solutions. In spite of the fact that SVM is getting famous because of its
satisfactory results and accuracy. Its potential in agriculture has not been completely investigated.

Wu and Wen [55] investigated SVM to detect four weed species in corn at early growth stage. They used
Gray Level Co-occurrence Matrix (GLCM) and histogram distribution to extract ten texture features of
weed and corn from gray level field images. Principle component analysis was used to select best
feature combination. The results showed that the SVM classifiers with different feature selections can
detect weed and corn with accuracy ranging between 92.31 to 100%. In this study SVM was compared
with back-propagation neural-network classifier on same dataset and it was found that SVM performs
better with 100% accuracy than neural network which gave 80% accuracy.

Karimi et al [56] evaluated SVM to classify hyper spectral images of corn fields to detect weed and
nitrogen stress. They used 72-waveband Compact Airborne for image acquisition during early growth
season. Performance of SVM was evaluated against three cases: combinations of nitrogen application
rates and weed infestation levels, nitrogen application rates alone, and weed controls alone. They
compared SVM accuracy with artificial neural network (ANN) on same dataset and found SVM performs
better than ANN in all three cases. SVM gave 69% accuracy for combined weed and nitrogen application
while gave 86% and 81% accuracy in rest of two cases in which weeds and nitrogen treatment were
investigated separately.

SVM is an example of artificial intelligence technique which gives better classification accuracy than
traditional methods for corn and weed classification. But Weed detection in other fields specialy in
scattered crop fields is still challenging. In previous researches classifiers were evaluated on data taken
at one or few random dates but I have taken field images after every two weeks during whole growing
season of wheat crop because leaf shape and plant height changes with different growth stages.
82
2. Multiclass Linear SVM

To classify weed and wheat crop I have used multiclass linear SVM presented by Yang, Jianchao, et al
[57]. When a training data is given, linear classifier tires to learn linear functions so when test data is
presented it can predict test data labels. Mathematically we can define it as follow.

If we represent training data as a set . Then linear SVM learns linear


functions such that it can predict labels of test data z using given equation

Eq 23

Considering one against all strategy all L binary SVMs are trained by solving unconstraint convex
optimization problem defined as follows:

Eq 24

In above equation = 1 if = c otherwise it will be = -1. is a hinge loss function which


is calculated using differentiable quadratic formula.

Eq 25

In this multiclass class linear SVM training is done using Limited-memory Broyden–Fletcher–Goldfarb–
Shanno (LBFGS) which is an optimization algorithm. This multiscale linear SVM has linear complexity
because it linearly scans over the training data. Major computation cost is caused by computing J(w) and
its gradient.
83
I used this multiclass linear SVM for the selection of best feature combination that can detect weed with
more accuracy among following features.

3. Local Ternary Pattern

Texture analysis and classification plays important role in visual object recognition. Local binary pattern
(LBP) is an example of texture feature that was first introduced by Ojala et al for rotation invariant
texture classification. There are two main steps in LBP. First is thresholding in which all neighboring pixel
values are converted into binary numbers after comparing them with the central pixel. We move
clockwise or anti clock wise in 8*8 aur 16*16 window and write 1 if central pixel value is less then
neighbor’s value otherwise write 0. In encoding step we convert binary values of pixels into decimal
numbers by computing histograms. Local ternary pattern (LTP) is an extension of LBP. The main
drawback of LBP is that its performance is affected in the presence of noise. LTP overcomes this
weakness and robust against noise. Unlike LBP it uses three values (1,0,-1) for threshodling. It compute
neighboring pixel values using following equation

Eq 26

In the above equation k is thresholding constant. C is central pixel value and p represent neighboring
pixel value. LTP is computed by calculating two LBT (upper and lower pattern) because histogram of
these LTP results in a large range. LTP operator is generated by concatenating encoded lower and upper
pattern. Thresholding and concatenation steps for LTP operator are depicted in figure 45.

84
Figure 45: LTP operator

Above figure shows coded lower and upper pattern constructed after thresholding.

4. Texture features

Texture contains important information and it is widely used for object classification. Based on texture
analysis done in chapter 4 I have computed a texture feature set consists of 5 texture features that are
contrast, co-relation, energy, entropy and homogeneity. Images are first converted into gray level and
then e Gray Level Co-occurrence Matrix (GLCM) was computed to extract above mentioned texture
features.

5. Speeded Up Robust Features (SURF)

Surf is a scheme for image feature extraction. It is based on Gaussian second derivative mask and
feature descriptors that relies on local Haar wavelet responses. SURF basically consists of two steps. In
first step interest points are detected in images and in second step descriptors are created for each
interest point. It is best suited for blob like structure in the images. It has a tendency to discriminated
85
bright blob present on dark background and dark blob present on bright background. It can detect
object in complex, cluttered and partially hidden object because it is invariant of scale, rotation,
distortion and changes in lightening conditions. Surf introduces the concept of scale Octaves that is
each octave linearly samples a small portion of the scale space. The size of this portion or region is
critical and proportional to the scale magnitudes used.

6. Scale-Invariant Feature Transform (SIFT)

It was proposed by D.Lowe in 2004. It extracts keypoint and computes its descriptors. It is invariant to
translation, scaling and rotation. It converts the image in to a large set of local feature vectors. SIFT
algorithm consists of following four steps:

1) Scale – space Extreme Detection:

In images with different size corners, it can’t be possible to use same window for keypoint detection
with different scale because to detect large corners we need larger window. So SIFT uses scale space
filtering. For this, SIFT uses Difference of Gaussians Dog. Once Dog are calculated, images are scanned to
find local extrema over scale and space.

2) Keypoint Localization:

After computing keypoints locations SIFT uses Taylor series expansion of scale space to get more
accurate location of extrema. SIFT discard those extrema whose intensity is less than some threshold.
Dog have higher response for edges so to remove edges SIFT uses 2x2 Hessian matrix and calculate
pricipal curvature. In short SIFT removes low contrast keypoints and edges. It keeps strong keypoints
only.

3) Orientation Assignment:

To make it rotation invariant, orientation is then assigned to each keypoint. Gradient magnitude and
direction is calculated around region of keypoint location. Orientation Histogram is created in which
highest peak and peak above 80% are considered as orienataion. In this way keypoint are created in the
same location and scale but in different direction.

86
4) Keypoint Descriptor:

A 16x16 neighborhood is created around kepoint which is further divided into 16 blocks of 4 x4 each. 8
bin orientation histogram of each sub block is represented as vector to form keypoint descriptor.

I have done sparse coding followed by spatial pyramid pooling of SIFT features to improve classification
accuracy.

7. Sparse Coding of SIFT

SVMs using spatial pyramid matching (SPM) kerne have been used extensively for image classification.
These nonlinear SVMs have computational complexity of in training and O(n) in testing phase
where n is the size of training dataset. It has memory requirement. It is not suitable for large
training data. Due to its scalability limitation I have used multi-scale spatial max pooling based on sparse
code of SIFT features instead of vector quantization. Traditional SPM uses K-means vector quantization
and compute histogram for spatial pooling.

Sparse coding has two phases training phase and coding phase. First we extract a set of SIFT descriptor
X. In training phase we first train a codebook V. To train codebook V I have extracted a defined number
of SIFT descriptor from random patches and iteratively run following two equations.

Eq 27

Eq 28

In the above equation represent SIFT descriptor and is cardinality constrain and all element of
are non-negative. In coding phase sparse codes for each image represented as descriptor is obtained by
optimizing above equation.

87
B. Comparative Analysis

To compare the performance and accuracy of multiclass linear SVM, I have used Neural Network and
non-linear SVM. Neural network are very useful in artificial intelligence and its application ranges from
medical imaging to computer leaning algorithms. It takes images as input and output class label after
classification. We usually divide dataset into three sets. Major portion of 70% is used to train the neural
network, 15% is used for validation and rest of 15% is used for testing. In experiments back-propagation
neural network is used with 10 hidden neurons. In experiments non-Linear Gaussian Radial Basis
Function kernel (RBF) SVM is also tested using all above mentioned feature sets.

After experiments it was found that multiclass linear SVM performs better than neural network and
non-linear SVM in terms of mean accuracy and execution time. It was also noticed that multi class linear
SVM trained on SIFT sparse code gives better mean accuracy of about 0.85 among all feature sets but
execution time is more while LTP along with five texture features gives mean accuracy of about 0.82
with less execution time. There is a tradeoff between execution time and mean accuracy. If we
compromise on time and use SIFT sparse codes then steps mentioned in figure 46 will be perform for
weed density classification.

A. Experiment and Results:

1. Experimental Setup:
.

Experiments are performed using MATLAB 14 software on Intel Core i3 microprocessor, 2.00 GB of RAM
and the Windows 7 operating system.

88
Images dataset

Extract SIFT descriptors

Sprace coding of SIFT

Spatial Max pooling

Train Multi-class linear


SVM

Test Multi-class linear


SVM

Figure 46: Flow Chart of Weed Density Classification Using Multi-class Linear SVM with SIFT Sparse Codes

2. Dataset

In order to make reliable results field images were taken after every two weeks during growing season
of wheat crop because leaf shape and plant height varies during whole growing season. I made three
classes based on weed density and each class contains 33 images. 20% of images in each class are used
for training and 80% images are used for testing. Sample images for each class are shown below.

89
(a) (b)

(c)

Figure 47: Sample Images of (a) Non-Weed (b) Less-Weeds (c) More-Weeds

In above figure one sample image of each class is shown. Figure 47 (a) shows the case when there is only
soil and wheat crop and no weed leaves. Figure 47 (b) shows the case with less number of weeds. In this
case weed leaves are small and have almost round shape. Figure 47 (c) shows more number of weeds
having long leaves.

90
3. Back-Propagation Neural Network

Back-propagation neural network has been implemented using Matlab Neural Network Toolbox. Matlab
Toolbox provides different back propagation training algorithms like Levenberg-Marquardt, Bayesian
Regularization, BFGS Quasi-Newton and Resilient Backpropagation etc. I used Resilient Backpropagation
in all experiments with its default setting shown in given table. This training algorithm is defined by
Matlab function “trainrp”. I used it because it has less memory requirement and it is fast then standard
gradient descent algorithms. 20 hidden neurons are used. I have calculated its accuracy by divided the
number of testing images which are correctly classified divided by total number of testing images. Error
and performance (mean squre error) is calculated for each class in each round. Final result and
performance is computed by taking average. 50 % images of each class is used for training and rest are
used for testing.

Parameter Value

Maximum number of epochs to train 1000

Maximum time to train in seconds Inf

Learning rate 0.01

Decrement to weight change 0.5

Increment to weight change 1.2

Initial weight change 0.07

Maximum weight change 50.0

Maximum validation failures 6


Table 9: Parameter Settings of Back-propagation Neural Network

91
4. Non-Linear SVM

For comparative analysis another classifier (non-linear SVM) is used. SVM basically use for binary data
and perform one to one classification. To implement multi class SVM two binary Gaussian Radial Basis
Kernal SVM has been used. SVM classifier classifies test data using one to all relation.

5. Performance Evaluation

Classification accuracy of three classifiers using different feature set has been evaluated using well
known cross validation technique. Classification process is repeated 5 times. In each iteration training
and testing data is selected randomly to keep results reliable and average accuracy per class is recorded.
At the end mean accuracy and standard deviation is recorded. Classifiers performance in terms of
execution time in seconds is also calculated. Execution time of feature extraction, training phase and
testing phase is calculated against all three classifiers.

6. Classification Results using SURF

To extract SURF descriptors of dataset, resized images were converted into gray scale images. SURF
points are then extracted using Matlab build-in function “detectSURFFeatures” with MetricThreshold
parameter set to 600. MetricThreshold defines the strongest features. It outputs those pair who has
MetricThreshold and non negative scalar value. Feature vectors were calculated using Matlab build-in
function “extractFeatures” function with images and their corresponding SURF point as input.
“extractFeatures” function extract variable number of feature from each image so to keep constant size
feature vectors I used to selec some defined number feature from each feature vector. Feature set is
constructed by concatenating feature vector of each image vertically. Weed classification results using
SURF descriptors are given in following table.

Round NonWeed Less Weed More Weed Mean

92
1 0.61 0.95 0.83 0.79

2 0.74 0.84 0.56 0.72

3 0.65 0.79 0.52 0.65

4 0.09 1 1 0.70

5 0.52 1 0.74 0.75

Table 10: Classification Rate of Multi-Class Linear SVM using SURF

Classification accuracy of SVM using SURF descriptors is shown in table 10. SURF descriptors are good
for blob detection which is also depicted in our results. SURF detected less weed images with more
accuracy then non weed or more weed images because less weed images have small rounded weeds
where as non weed and more weeds have long weed or crop leaves. Multiclass Linear SVM classifies
field images into three classes using SURF with 0.72 mean accuracy and 0.054 standard deviation
Mean accuracy: 0.72

Standard deviation: 0.053

Stages No of images Execution time (Sec)

Feature extraction 99 47.67

Training 10/per class 7.19

Testing 23/per class 0.04

Table 11: Execution Time of Multi-class Linear SVM using SURF

Table 11 shows the execution time to extract SURF descriptor, training and testing of SVM using SURF.
Training phase on SURF descriptor took more time then training multiclass Linear SVM on LTP because
of large feature set.

Round Non Weed Less Weed More Weed Mean

93
1 0 0.32 1 0.44

2 0.04 0.16 1 0.40

3 0 0.21 1 0.40

4 0 0.37 1 0.46

5 0.04 0.26 1 0.44


Table 12: Classification Rate of Non-Linear RBF Kernal SVM using SURF

Classification rate of non-linear SVM is shown in table 12. It couldn’t classify non weed and less weed
images well. Images with more weeds are correctly detected. Mean accuracy and standard deviation
over 5 iterations are given below.
Mean accuracy: 0.43

Standard deviation: 0.024

Stages No of images Execution time (Sec)

Training/per class 10 0.91

Testing/per class 23 10.11


Table 13: Execution Time of Non-Linear RBF Kernal SVM

Execution time of training and testing phase of non linear SVM is shown is table 13. Non linear SVM
takes more time in testing because it checks one to all relations. Table 14 shows classification results of
neural network.

Round Non Weed Less Weed More Weed Mean

1 0 1 0 0.33

2 0 1 0 0.33

3 0 0.54 0 0.18

94
4 0.06 0.31 0.53 0.30

5 0 1 0 0.33
Table 14: Classification Rate of Back-propagation Neural Network using SURF

Back-propagation neural network detects less weed images with more accuracy. Neural network is
trained on 50% images of each class. It took 21 iterations during training. Accuracy of neural network is
calculated in the same way as SVMs accuracy is calculated. Neural network is trained on 16 images of
each class so total of 48 images. To test 51 images, 17 images from each class are randomly selected in
each iteration. Mean squared error is also calculated along with mean accuracy and standard deviation.
Mean accuracy: 0.30

Standard deviation: 0.066

Mean Squared Error: 6.45

Epoch: 21 iterations

Stages No of images/per class Execution time (Sec)

Training 16 5.21

Testing 17 0.15
Table 15: Execution Time of Back-propagation Neural Network

Execution time of neural network is show in the table 15. Its testing time is greater than multiclass linear
SVM. It takes more space then SVM in training. Multi-class linear SVM takes less testing as compare to
non-linear SVM and neural network and it accuracy is greater than rest of two classifiers.

Graph in figure 48 shows the performance of three classifiers. Mean accuracy is shown along y-axis and
number of iterations are shown on x-axis. It can be notices that performance of multiclass linear SVM
trained on SURF descriptors is better than performance of non-linear RBF kernel SVM and back-
propagation neural network.

95
Figure 48 : Mean Accuracy of Three Classifiers Trained on SURF Descriptors

7. Classification Results using SIFT sparse codes

SIFT descriptors are extracted out from gray-scale images. I stored SIFT descriptor for each image
separately in Matlab data(.mat) file. Some descriptors selected from random patches are used to train
codebook. I have used fixed sixe 16*16 patches to extract SIFT descriptors’. Sparse codes for each image
are generated using codebook. Codebook size is also important. SVM performs better classification if
codebook size increases up to 1024. I my experiments I trained codebook of size 1024. The parameter
lambda in sparse coding enforces the sparsity in each feature vector and set to 0.1 in experiments.
Feature set is obtained by performing spatial pyramid max pooling on sparse codes of SIFT. Finally SVM
is trained and tested on these SIFT sparse code for classification. Results are given in the table 16.

96
Round Non Weed Less Weed More Weed Mean

1 0.78 0.95 0.70 0.81

2 0.91 1 0.61 0.84

3 0.91 1 0.65 0.86

4 1 1 0.96 0.99

5 0.91 1 0.43 0.78

Table 16: Classification Rate of Multi-class Linear SVM using SIFT Sparse Codes

Table 16 shows the classification results of multiclass Liner SVM based on weed density using SIFT sparse
code. It was found that SIFT sparse code can detect weed with more than 84% accuracy and it is better
than rest of other feature sets. But sparse coding of SIFT descriptors take long time. Execution time is
given below
Mean accuracy: 0.85

Standard deviation: 0.078

Stages No of images Execution time

Feature extraction 99 90.00

Sparse codes generation 99 342.72

Training/per class 10 1.44

Testing/per class 23 0.02


Table 17: Execution Time of Multi-class Linear SVM on SIFT Sparse Code

97
Table 17 shows execution time of multi-class linear SVM. Classification results proved that SIFT sparse
code are good features for weed density classification. But SIFT descriptors calculation takes long time
followed by sparse code generation which takes even more time of about 343 seconds.

Round Non Weed Less Weed More Weed Mean

1 0 0.26 1 0.42

2 0 0.21 1 0.40

3 0 0.21 1 0.40

4 0.04 0.21 1 0.42

5 0.04 0.16 1 0.40


Table 18: Classification Rate of Non-Linear RBF Kernal SVM on SIFT Sparse Codes

Non-linear SVM using SIFT Sparse code detects more weed images correctly in all 5 iterations. Non weed
images are poorly classified. Classification rate of non-linear RBF kernel using SIFT sparse codes are
shown in table 18.

Stages No of images/per class Execution time (Sec)

Training 10 0.49

Testing 23 9.19
Table 19: Execution time of Non-Linear RBF Kernal SVM

Non-linear SVM takes 0.493 seconds in training 30 images represents as SIFT sparse code. Execution
time of testing phase is greater than training phase. Execution results for training and testing is
mentioned in table 19.

Round Non Weed Less Weed More Weed Mean

1 0 1 0 0.33
98
2 0 1 0 0.33

3 0.59 0.38 0.06 0.34

4 0 1 0 0.33

5 0 1 0 0.33
Table 20: Classification Rate of Back-Propagation Neural Network on SIFT Sparse Codes

Table 20 shows classification rate of Back-propagation neural network. Neural network trained on SIFT
sparse codes classifies less weed images correctly and other two classes are not well detected. Average
accuracy, standard deviation and Mean squared error are also calculated and given below.
Mean accuracy: 0.34

Standard deviation: 0.004

Mean Squared Error: 1.81

Epoch: 16 iterations

Stages No of images/per class Execution time (Sec)

Training 16 1.49

Testing 17 0.07
Table 21: Execution time of Back-Propagation Neural Network

Table 21 shows execution time of Back-Propagation Neural Network for its training and testing phase.
Number of images per class is mention as there are 3 classes in dataset. In experiments neural network
took 1.49 seconds to train 48 images and much less time to test 53 images. In testing it took 0.069
seconds. Classification performance of three classifiers is shown in the following graph.

99
Figure 49: Mean Accuracy of Three Classifiers Trained on SIFT Sparse Codes

Mean accuracies of all three classifiers in each of 5 iterations is depicted in figure 49. It is evident that
mean accuracy of multi-class SVM trained on SIFT sparse codes in each iteration is better than other two
classifiers.

8. Classification Results using LTP

To represent training and testing images in the form of local ternary pattern first I have resized the
images of size 640*480 and convert RGB images into gray-scale images. Then I converted 2-d image
matrix into an array. LTP are calculated using LBP. My routine outputs histograms for uniform pattern
and one additional bin for all non uniform patterns. Feature set is constructed by concatenating
histograms of LTP. Result of multiclass linear SVM using LTP is given below:

100
Round Non Weed Less Weed More Weed Mean

1 0.91 0.74 0.74 0.80

2 0.91 0.74 0.43 0.69

3 0.91 0.89 0.43 0.75

4 0.78 0.89 0.91 0.86

5 0.83 0.68 0.87 0.79


Table 22: Classification Rate of Multi-class Linear SVM using LTP

Table 22 shows that classification rate of Multi-class Linear SVM using LTP. Classification process is
carried out for 5 round and in each round accuracy rate for each class is recorded. Mean accuracy for
each round is shown in last column. Results showed that it can detect non weed images and less weed
images with more accuracy then more weed images. Multiclass Linear SVM classifies field images into
three classes with 0.78 mean accuracy and 0.062 standard deviation.
Mean accuracy: 0.78

Standard deviation: 0.06

Stages No of images Execution time (Sec)

Feature extraction 99 19.30

Training 10/per class 0.91

Testing 23/per class 0.04


Table 23: Execution Time of Multi-class Linear SVM Classification using LTP

101
Table 23 shows execution time in seconds for different stages of classification. Table shows that feature
set preparation takes major time and testing take very less time as compared to training time.
Classification result of non-linear kernel is given below

Round Non Weed Less Weed More Weed Mean

1 0.04 0.26 1 0.44

2 0.04 0.37 1 0.47

3 0 0.26 1 0.42

4 0.04 0.21 1 0.42

5 0 0.26 1 0.42
Table 24: Classification Rate of Non-Linear RBF Kernal SVM using LTP

Results in table 24 shows that non-linear RBF kernel SVM trained on LTP gives better classification then
SIFT spares code and SURF. Mean accuracy for each class in each iteration is calculated and shown in
last column. Overall mean accuracy and standard deviation is given below.
Mean accuracy: 0.43

Standard deviation: 0.021

Stages No of images/per class Execution time (Sec)

Training 10 0.37

Testing 23 6.97
Table 25: Execution Time of Non-Linear RBF Kernal SVM

Execution time of non-linear RBF kernel SVM is shown in table 25. Testing and training time is calculated
in seconds. Total 99 images belonging to all three categories are used. For training purpose 30 images

102
are used and 69 images are used in testing. Test data include equal number of images for each class.
Classification results of neural network is shown table 26.

Round Non Weed Less Weed More Weed Mean

1 0.65 0.46 0 0.37

2 0.06 0.54 0.47 0.36

3 0 0.62 0.82 0.48

4 0.12 0.38 0.06 0.19

5 0 0.69 0.35 0.35


Table 26: Classification Rate of Back-Propagation Neural Network

Classification accuracy of back-propagation neural network for each class in each of 5 iterations is shown
above. Average mean along with mean squared error and standard deviation is mentioned below.
Mean accuracy: 0.35

Standard deviation: 0.10

Mean Squared Error: 4.81

Epoch: 18

Stages No of images/per class Execution time (Sec)

Training 16 0.38

Testing 17 0.02
Table 27: Execution Time of Back-Propagation Neural Network

103
Execution time of neural network is depicted in above table. It took 18 iterations and 0.38 seconds to
train 48 images. Results showed that neural network takes very less time as compare to non- linear SVM
specially in testing phase. A graph showing mean accuracy of each classifier is shown figure 50.

Figure 50: Mean Accuracy of Three Classifiers Trained on SIFT Sparse Codes

Above graph shows performance comparison of multi-class linear SVM with non-liner RBF kernel SVM
and back-propagation neural network. Linear SVM perform much better using SIFT sparse codes.

9. Classification Results using Texture Features

Multiclass linear SVM is trained on another feature set consist of five texture features. First RGB images
are converted into gray-scale images followed by image type conversion into “double”. Entropy is
calculated using Matlab build-in function “entropy”. Gray co-occurrence matrix (GLCM) is calculated for

104
each image. Rest of four texture features (correlation, energy, contrast and homogeneity) is calculated
from GLCM using “graycoprops” function. Classification rate of multi-class linear SVM is given below

Round Non Weed Less Weed More Weed Mean

1 0.87 1 0.74 0.87

2 0.74 0.84 0.65 0.74

3 0.74 0.89 0.74 0.79

4 0.61 0.84 0.96 0.80

5 0.87 0.89 0.61 0.79

Table 28: Classification Rate of Multi-class Linear SVM using Texture Features

Results in table 28 shows that texture features helps multi-class linear SVM to classify all three classes
equally. In previous experiments classifiers classify one or two classes with more accurately but not all.
Linear SVM trained on texture features classifies all three classes properly.
Mean accuracy: 0.80

Standard deviation: 0.04

Stages No of images Execution time (Sec)

Feature extraction 99 34.68

Training 10/per class 0.99

Testing 23/per class 0.04

Table 29: Execution Time of Multi-class Linear SVM

105
Table 29 shows the time needed to extract texture features. Table 26 also shows the time taken by
multi-class SVM for training on five texture features. 0.04 seconds were consumed in testing phase.
Below table shows classification results of non-linear SVM.

Round Non Weed Less Weed More Weed Mean

1 0.78 0.89 0.70 0.79

2 0.78 1 0.65 0.81

3 0.65 0.84 0.74 0.74

4 0.78 0.79 0.91 0.83

5 0.74 1 0.70 0.81


Table 30: Classification Rate of Non-linear RBF Kernal SVM using Texture Features

Table 30 shows astonishing results about non-linear RBF Kernal SVM. Non-linear SVM trained on texture
features gives best accuracy among all feature sets. Best mean accuracy of Non-linear SVM trained on
other feature sets like (SURF, LTP, SIFT sparse codes) was 0.44 where as mean accuracy of non-linear
SVM trained on texture feature is 0.80 which is equal to mean accuracy of multi-class linear SVM.
Mean accuracy: 0.80
Standard deviation: 0.032

Stages No of images Execution time (Sec)

Training 10/per class 0.02

Testing 23/per class 2.06

Table 31: Execution Time of Non-linear RBF Kernal SVM

Execution time of non-linear SVM is shown in table 31. This testing time is less then testing time taken
by non-linear SVM trained on other feature set. Mean accuracy of linear and non-linear SVM using

106
texture features is almost same but non-linear SVM takes more time in testing then multi-class linear
SVM.

Round Non Weed Less Weed More Weed Mean

1 0.26 0.79 0.65 0.57

2 0.65 0.95 0.48 0.69

3 0.09 0.68 0.78 0.52

4 0.83 0.74 0.48 0.68

5 0.48 0.74 0.43 0.55

Table 32: Classification Rate of Back-Propagation Neural Network

Table 32 shows classification results of back-propagation neural network trained on five texture
features. Like non-linear SVM texture features improves mean accuracy of neural network up to 0.60
but it is less than mean accuracy of SVMs.
Mean accuracy: 0.60

Standard deviation: 0.07

Mean Squared Error: 2.07

Epoch: 10

Stages No of images Execution time (Sec)

Training 16/per class 0.12

Testing 17/per class 0.01

Table 33: Execution Time of Back-Propagation Neural Network

107
Execution time of back-propagation neural network to train 48 images is 0.117 seconds and testing time
is 0.0133 seconds. Its testing time is even less than linear SVM.

Figure 51: Mean Accuracy of Three Classifiers Trained on Textures Features

Graph in figure 51 shows classification accuracy of three classifiers trained on five texture features
(entropy, energy, correlation, contrast and homogeneity). In these experiments it is found that texture
features increased that mean accuracy of all three classifiers. It is noticed that non- linear SVM trained
on Texture feature have same average accuracy as of multiclass linear SVM. In fact in some iterations
(2,4,5) mean accuracy of non-linear RBF kernel SVM is greater than linear SVM. But testing time of linear
SVM is less than non-linear SVM.

10. Classification Results using LTP and Texture Features

Another feature set is also used in experiments which is combination of five texture features (energy,
entropy, homogeneity, correlation and contrast) and local ternary patterns. All three classifiers were
trained on this feature set. Their classification results and execution time is given below.
108
Round Non Weed Less Weed More Weed Mean

1 0.91 0.89 0.61 0.81

2 0.91 0.74 0.52 0.72

3 0.83 0.89 0.96 0.89

4 0.70 1 0.83 0.84

5 0.70 0.94 0.87 0.84

Table 34: Classification Rate of Multi-class Linear SVM using LTP and Texture Features

Table 34 shows the classification results of multi-class linear SVM. In most of the iterations mean
accuracy is above 0.83. It shows that after SIFT sparse codes, this combined feature set gives best
accuracy.
Mean accuracy: 0.82

Standard deviation: 0.062

Stages No of images Execution time (Sec)

Feature extraction 99 76.63

Training 10/per class 1.77

Testing 23/per class 0.05

Table 35: Execution Time of Multi-class Linear SVM

Table 35 shows the time needed to calculate combined feature set. It also shows the testing and training
time of multi-class linear SVM trained on combined feature set.

109
Round Non Weed Less Weed More Weed Mean

1 0.04 0.26 1 0.44

2 0.04 0.37 1 0.47

3 0 0.26 1 0.42

4 0.04 0.21 1 0.42

5 0 0.26 1 0.42

Table 36: Classification Rate on Non-linear RBF Kernal SVM using LTP and Texture Features

Table 36 shows classification results of nonlinear SVM. It classifies more weed images with more
accuracy then non weed or less weed images. Mean accuracy with standard deviation over five
iterations is given below.
Mean accuracy: 0.43

Standard deviation: 0.02

Stages No of images Execution time (Sec)

Training 10/per class 0.35

Testing 23/per class 6.60

Table 37: Execution Time of Non-linear RBF Kernal SVM using LTP and Texture Features

Execution time of non linear SVM in testing and training is shown in table 37. Its testing time is
greater than testing time of linear SVM. Classification accuracy of neural network is given
below.

Round Non Weed Less Weed More Weed Mean

110
1 0 1 0 0.33

2 1 0 0 0.33

3 0 0.38 0.24 0.21

4 0.12 0.23 0.41 0.25

5 0 1 0 0.33

Table 38: Classification Rate of Back-Propagation Neural Network using LTP and Texture Features

Table 38 shows the classification accuracy of back-propagation neural network. It is evident that neural
network trained on combined feature set didn’t perform well. Its overall mean accuracy for all classes is
very low. Standard deviation and mean squared error are mentioned below.
Mean accuracy: 0.29

Standard deviation: 0.06

Mean Squared Error: 4.43

Epoch: 20

Stages No of images Execution time (Sec)

Training 16/per class 8.57

Testing 17/per class 0.22

Table 39: Execution Time of Back-Propagation Neural Network

Execution time of neural network trained on combined feature set is shown above. It took much time in
training and gave more classification accuracy. Performance graph of all three classifier is given below.

111
Figure 52: Classification Performance of Three Classifiers Trained on LTP and Texture Features

In figure 32 mean accuracy in each iteration for three classifiers is shown. Mean accuracy of each
iteration is calculated by calculating the accuracy of each class than takes its average. From graph it is
clear that mean accuracy of multi–class linear SVM is better than other two classifiers.

B. Discussion

After performing above mentioned experiments I have concluded following four facts regarding weed
density classification.

 Multi-class linear SVM classifies weed density with more accuracy than non-linear RBF kernel
SVM and back-propagation neural network. It takes less time in testing phase then non-linear
SVM

112
 Multi-class linear SVM trained on SIFT sparse codes classifies weed density with best mean
accuracy of 0.85 but its takes 4.37 seconds to extract SIFT sparse codes from single image.
 Non-linear RBF kernel SVM and back-propagation neural network gave best mean accuracy
when trained on five Texture features (entropy, energy, contrast, correlation and homogeneity).
Non-Linear SVM and Linear SVM trained on texture features gave almost same mean accuracy
of 0.79 but non-linear SVM takes more time in testing than linear SVM.
 Combined feature set of LTP and texture feature is the second best feature set after SIFT sparse
codes. Multi-class Linear SVM gave mean accuracy of about 0.82. It takes 0.77 seconds to
extract features from single image which is less than the time needed to extract SIFT sparse
codes.

113
VIII. Conclusion

In the context of precision agriculture, selective herbicides application and local weed detection is highly
needed. For economical and beneficial usage of herbicides, farmers do need techniques which can
evaluate whole field so it can be possible to treat each part of the field according to its need. In this
paper, precision farming technology inspired algorithm is presented for site specific weed management.
Weed distribution level vary from no, low to high densities, this distribution pattern makes site specific
weed management more feasible and help farmers to save large amount of herbicide by only applying
herbicides on high weed density areas. For this, knowledge of location and density of weed species in
wheat crops is important. Two algorithms have been proposed for weed detection in scattered wheat
crops where weed and crop leaves may overlap each other. The Shape and Texture based Weed
Detection algorithm performs efficiently despite of similarity between weed and crop leaves and highly
variable lighting conditions. Given 30 input images, shape based analysis detected 72% weeds correctly
and 69% weeds are detected by frequency based analysis. Overall weed detection rate of the proposed
algorithm is 74% and 15% vegetation area is recorded as false positive (wrongly detected as weed).
Average execution time is recorded as 2.04 sec. It should be mentioned that wrong and miss detection
was because of multiple reasons including crop shadow, overlapping weed and wheat leaves and over
exposure of light. Experimental results showed that weed detection using Circular Hough Transform
technique gives poor accuracy with more false positive. In later part another weed detection algorithm
using multi-class linear SVM has been proposed. After feature set selection experiments it was found
that multi-class linear SVM trained on LTP and five other texture feature can classify field images based
on weed density with mean accuracy of 0.82. It takes 0.7 seconds to extract features and 0.002 seconds
to test a single image. Comparative analysis found that multi-class linear SVM gives better performs in
terms of mean accuracy and execution time than non-linear RBF kernel SVM and back-propagation
neural network. After all experiments it is concluded that multi-class linear SVM detects weed with more
accuracy in less time as compared to image processing based weed detection algorithm. This algorithm
is beneficial in precision agriculture and can be used in any flying robots used for selective herbicide
spray.

114
IX. Future Work:

In future, this work will be extended to detect other two types of weeds (narrow leaf and grassy weeds)
in wheat crop. The potential of using remote sensing tools in precision farming has been explored during
the past decade. Hyperspectral images contain more information than conventional RGB images. Hence
hyperspectral camera may be used as a powerful technology for weed sensing.

115
X. References

1. Alvi, Shah Muhammad, Ch Sanaullah, and Muhammad Anjum Ali. "Evaluation of some
herbicides for the control of weeds in wheat crop." Pak. J. Life Soc. Sci 2.1 (2004): 24-27.
2. Marwat, K. B., et al. "Survey on weed problems in wheat crop in district Mardan." Pakistan
Journal of Weed Science Research 12.4 (2006): 353-358.
3. Sher, Falak, and Eatzaz Ahmad. "Forecasting Wheat Production in Pakistan."Lahore Journal of
Economics 13.1 (2008).
4. Polder, Gerrit, et al. "Weed detection using textural image analysis." 6th Biennial Conference of
the European Federation of IT in Agriculture (EFITA), Glasgow, UK. Available online at
http://edepot. wur. nl/28203. Accessed October. Vol. 12. 2007.

5. R. Ahmad and A. S. Shaikh, “Common Weeds of Wheat and Their Control,” Pakistan Journal of
Water Resources,Vol. 7, No. 1, 2003, pp. 73-76.
6. G. Hassan, B. Faiz, K. B. Marwat and M. Khan, “Effects of Planting Methods and Tank Mixed
Herbicides on Controlling Grassy and Broad Leaf Weeds and Their Effects on Wheat cv Fakhr-e-
Sarhad,” Pakistan Journal of Weed Science Research, Vol. 9, No. 1-2, 2003, pp. 1-11.
7. Slaughter, D., Giles, D., & Downey, D. 2008. Autonomous robotic weed control systems: A
review. Computers and Electronics in Agriculture 61(1): 63-78.
8. Pervaiz, K. and M.H.Quazi. 1992. Status of food production in Pakistan. Progr. Farming, 12:5.
9. Khan, Muhammad Azim, and Fazli Wahid. "To investigate the major weeds of wheat in different
agro-ecological zones of Khyber Pakhtunkhwa Pakistan."Pakistan Journal of Weed Science
Research 19.1 (2013).
10. Marwat, Sarfaraz Khan, et al. "Weeds of Wheat Crop and Their Control Strategies in Dera Ismail
Khan District, Khyber Pakhtun Khwa, Pakistan."American Journal of Plant Sciences 4.1 (2013).
11. Sher, Z. A. M. A. N., et al. "Floristic composition, communities and ecological characteristics of
weeds of wheat fields of Lahor, District Swabi, Pakistan."Pak. J. Bot 43.6 (2011): 2817-2820.

116
12. Khan, Ikramullah, et al. "Invasive weeds of southern districts of Khyber Pakhtunkhwa-
Pakistan." Pakistan Journal of Weed Science Research 17.2 (2011).
13. Weis, Martin, and Roland Gerhards. "Detection of weeds using image processing and
clustering." Bornimer Agrartechnische Berichte 69 (2009): 138-144.
14. De Jong, Steven M., Freek D. Van Der Meer, and Jan GPW Clevers. Basics of remote sensing.
Springer Netherlands, 2004.
15. Menges, R. M., P. R. Nixon, and A. J. Richardson. "Light reflectance and remote sensing of
weeds in agronomic and horticultural crops." Weed Science(1985): 569-581.
16. Backes, Matthias, and Jan Jacobi. "Classification of weed patches in Quickbird images:
verification by ground truth data." EARSeL eProceedings 5.2 (2006): 173-179.
17. Medlin, C. R., Shaw, D. R., Gerard, P. D. and LaMastus, F. E. 2000. Using remote sensing to
detect weed infestations in Glycine max. Weed Science 48, 393–398.
18. Vioix, J-B., Douzals, J-P., Assemat, L., LeCorre, V., Dessaint, F. and Guillemin, J-P. 2001.
Development of a combined spatial and spectral method for weed detection and localisation. In:
Proceedings of the 3rd European Conference on Precision Agriculture, edited by G. Grenier and
S. Blackmore (agro Montpellier, Montpellier, France) Vol. 2, pp. 605–610.

19. Perez, A. J., et al. "Colour and shape analysis techniques for weed detection in cereal fields."
Computers and electronics in agriculture 25.3 (2000): 197-212.
20. Hooper, A. W., Harries, G. O. and Ambler, B. 1976. A photoelectric sensor for distinguishing
between plant material and soil. Journal of Agricultural Engineering Research 21, 145–155.
21. Shearer, S. A. and Jones, P. T. 1991. Selective application of post-emergence herbicides using
photoelectrics. Transactions of the ASAE 34(4), 1661–1666.
22. Wikipedia contributors. "Hyperspectral imaging." Wikipedia, The Free Encyclopedia. Wikipedia,
The Free Encyclopedia, 30 Jul. 2014. Web. 6 Aug. 2014.
23. Herrmann, I., et al. "Ground-level hyperspectral imagery for detecting weeds in wheat fields."
Precision Agriculture 14.6 (2013): 637-659.
24. Shapira, Uri, et al. "Field spectroscopy for weed detection in wheat and chickpea
fields." International Journal of Remote Sensing 34.17 (2013): 6094-6108.
25. Hadoux, Xavier, Nathalie Gorretta, and Gilles Rabatel. "Weeds-wheat discrimination using
hyperspectral imagery." CIGR-Ageng 2012, International Conference on Agricultural
Engineering. 2012.

117
26. De Rainville, François-Michel, et al. "Bayesian classification and unsupervised learning for
isolating weeds in row crops." Pattern Analysis and Applications: 1-14.
27. Wu, Lanlan, et al. "Identification of weed/corn using BP network based on wavelet features and
fractal dimension." Scientific research and essay 4.11 (2009): 1194-1200.
28. Hemming J, Rath T (2001) Precision Agriculture Computer-Vision-based Weed Identification
under Field Conditions using Controlled Lighting. Journal of Agricultural Engineering Research
78(3):233–243.
29. Nejati, Hossein, Zohreh Azimifar, and Mohsen Zamani. "Using fast fourier transform for weed
detection in corn fields." Systems, Man and Cybernetics, 2008. SMC 2008. IEEE International
Conference on. IEEE, 2008.
30. Tang, L., et al. "Texture-based weed classification using gabor wavelets and neural network for
real-time selective herbicide applications." Urbana 51 (2003): 61801.
31. Watchareeruetai, Ukrit, et al. "Computer vision based methods for detecting weeds in
lawns." Machine Vision and Applications 17.5 (2006): 287-296.
32. Tellaeche A, Pajares G, Burgos-Artizzu XP, Ribeiro A (2011) A computer vision approach for
weeds identification through Support Vector Machines. Applied Soft Computing 11(1):908–915

33. Xavier P. Burgos- Artizzu, Angela Ribeiro, Gonzalo Pajares, 2010,“Analysis of natural images
processing for extraction of agriculture elements” Elsevier- image and vision computing 28, pp
138-149..
34. Asif, Muhammad, et al. "A vision system for autonomous weed detection robot." International
Journal of Computer and Electrical Engineering 2.3 (2010): 486-491.
35. Siddiqi, Muhammad Hameed, Irshad Ahmad, and Suziah Bt Sulaiman. "Edge link detector based
weed classifier." Digital Image Processing, 2009 International Conference on. IEEE, 2009.
36. Agrawal, Kamal N., et al. "Weed Recognition Using Image-Processing Technique Based on Leaf
Parameters." Journal of Agricultural Science and Technology B 2 (2012): 1939-1250.
37. Woebbecke, D.M., Meyer, G.E., Von Bargen, K., Mortensen, D., 1992. Plant species
identification, size, and enumeration using machine vision techniques on near-binary images.
SPIE Optics Agric. Forestry 1836, 208–219.
38. MathWorks, (2014). Image Processing Toolbox: User's Guide (R2014a). Retrieved May 14, 2014
from http://www.mathworks.de/de/help/images/morphology-fundamentals-dilation-and-
erosion.html

118
39. MathWorks, (2014). Image Processing Toolbox: User's Guide (R2014a). Retrieved May 15, 2014
from http://www.mathworks.com/help/images/ref/imopen.html
40. MathWorks, (2014). Image Processing Toolbox: User's Guide (R2014a). Retrieved May 14, 2014
from http://www-rohan.sdsu.edu/doc/matlab/toolbox/images/morph4.html#24720
41. Kargar, B., H. Amir, and Ali M. Shirzadifar. "Automatic weed detection system and smart
herbicide sprayer robot for corn fields." Robotics and Mechatronics (ICRoM), 2013 First
RSI/ISM International Conference on. IEEE, 2013.
42. S. Bindu, S. Prudhvi , G. Hemalatha, Mr. N. Raja Sekhar and Mr V. Nanchariah “object detection
from complex background image using circular hough transform.” Int. Journal of Engineering
Research and Applications, 4.4 (2004): 23-28.
43. Selvarajah, S., and S. R. Kodituwakku. "Analysis and comparison of texture features for content
based image retrieval." International Journal of Latest Trends in Computing 2.1 (2011).
44. Tamura, H., S. Mori, and Y. Yamawaki, “Textural Features Corresponding to Visual Perception,”
IEEE Transactions on Systems, Man, and Cybernetics, SMC-8, pp. 460-473, 1978.
45. Sklansky, J., “Image Segmentation and Feature Extraction,” IEEE Transactions on Systems, Man,
and Cybernetics, SMC-8, pp. 237-247, 1978.
46. Srinivasan, G. N., and G. Shobha. "Statistical texture analysis." Proceedings of world academy of
science, engineering and technology. Vol. 36. 2008.
47. Sun, Changming. "Fast Algorithm for Local Statistics Calculation for< i> N</i>-Dimensional
Images." Real-Time Imaging 7.6 (2001): 519-527.
48. Swain, M., and Ballard, D. Color indexing. International Journal of Computer Vision (Jan 1991).
49. Schiele, B., and Crowley, J. L. Recognition without correspondence using multidimensional
receptive field histograms. International Journal of Computer Vision 36 (2000), 31–50.
50. Schneiderman, H., and Kanade, T. A statistical method for 3d object detection applied to faces
and cars. IEEE Computer Society Conference on Computer Vision and Pattern Recognition 1
(2000), 1746.
51. Burks, T. F., S. A. Shearer, J. R. Heath, and K. D. Donohue. 2005. Evaluation of neural-network
classifiers for weed species discrimination. Biosystems Engineering 91(3): 293-304.
52. Marchant, J. A. and C. M. Onyango. 2003. Comparison of a Bayesian classifier with a multilayer
feed-forward neural network using the example of plant/weed/soil discrimination. Computers and
Electronics in Agriculture 39(1): 3-22.

119
53. Goel, P. K., S. O. Prasher., R. M., Patel, J. A. Landry, R. B. Bonnell, and A. A Viau. 2003.
Classification of hyperspectral data by decision trees and artificial neural networks to identify
weed stress and nitrogen status of corn. Computers and Electronics in Agriculture 39(2): 67-93.
54. Yang, C. C., S. O. Prasher, and P. K. Goel. 2004. Differentiation of crop and weed by decision-
tree analysis of multi-spectral data. Transactions of the ASAE 47(3): 873-879
55. Wu, L. and Y. Wen. 2009. Weed/corn seedling recognition by support vector machine using
texture features. African Journal of Agricultural Research 4(9): 840-846.
56. Karimi, Y., S. O. Prasher, R. M. Patel, and S. H. Kim. 2005. Application of support vector
machine technology for weed and nitrogen stress detection in corn. Computers and Electronics in
Agriculture 51(1): 99-109.
57. Yang, Jianchao, et al. "Linear spatial pyramid matching using sparse coding for image
classification." Computer Vision and Pattern Recognition, 2009. CVPR 2009. IEEE Conference
on. IEEE, 2009.

120

Das könnte Ihnen auch gefallen