Classification of crops and weeds from digital images

Published:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

In conventional agricultural system, one of the major concerns is to reduce the abundance of unwanted pests known as weeds. In most of the cases, removal of the weed population in agricultural fields involves the application of chemical herbicides, which has been successful in increasing crop productivity and quality. However, concerns regarding the environmental and economic impacts of herbicide applications have promoted interests in seeking alternative weed control approaches. An automated machine vision system which can distinguish crops and weeds from digital images can be a cost-effective alternative to reduce the excessive use of herbicides. That is, instead of uniform application of herbicides in the field, a real-time system can be deployed to reduce the amount of herbicide use by identifying and spraying only the weeds. This paper proposes the use of a machine learning algorithm called support vector machine (SVM) for the classification of crops and weeds from digital images. Our objective is to ascertain if good classification accuracy can be achieved by SVM when it is used as the classification model in an automated weeding system. For our experiments, a total of fourteen features which characterize crops and weeds in images were investigated to find the best combination of features that provides the highest classification accuracy. Analysis of the classification results shows that SVM achieves above 97% accuracy over a set of 224 sample images.

Keywords: weed control; herbicides; machine vision system; support vector machine; RBF kernel; stepwise feature selection.

I. Introduction

Increasing productivity and upgrading plantation systems are the major concerns for accelerating agricultural development. Weeds are unwanted plants that can survive and reproduce in agricultural fields. They hamper agricultural development by disturbing production and quality through competing with crops for water, light, soil nutrients, and space. Uncontrolled weeds commonly reduce crop yields from 10 to 95 percent (Young et al., 1978). As a result, weed control strategies are critical to sustain crop productivity. Up to now, several strategies exist for weed control such as removing weeds manually by human labourers, mechanical cultivation, or applying agricultural chemicals known as herbicides. Applying herbicides is the most common method which has adverse impacts on both environment and human health. It also raises a number of economic concerns. In the United States, the total cost of applying herbicides was estimated to be $16 billion in 2005 (Naeem et al., 2007). One of the main cost ineffective and strategic problems in using herbicides system is that herbicides are applied uniformly within a crop field in most cases. But weed species are aggregated (Rew et al., 1995) and usually grow in clumps or patches (Tian et al., 1999) within the cultivable field. There could be many parts of a field that have none or insignificant volume of weeds, but herbicides are still applied to them. On the other hand, human involvement in applying herbicides is very time consuming and costly. If the same types of herbicides are applied in a field again and again for the removal of the weed population, there is a possibility of re-emergence of weeds that have become tolerant to those types of herbicides. From related literature, over 290 biotypes of herbicide tolerant weeds have been found in different places worldwide (www.weedscience.com, accessed August 2010). Again, pre-emergence herbicides like atrazine and alachlor are likely to contaminate ground and surface water supplies as they are soil-applied (Tian et al., 1999), which is a major issue for the safety of drinking water.

The performance of agricultural sector has an overwhelming impact on food security, poverty alleviation and economic development of a country. To reduce the population pressure on agricultural sector, crop production and quality must be increased with minimal cost for weed control. Spraying herbicides with a knapsack sprayer is the most commonly used technique in agricultural fields. This technique is considered to be inefficient and time consuming where recommended safety measures are rarely maintained. Here, a machine vision system that has the ability to classify crops and weeds so that herbicides can be applied where there are weeds can be a novel approach that will enhance the profitability and lessen environmental degradation. In such an approach, images would be taken from a crop field so that weeds can be identified and treated accordingly by an automated real-time system. Two general approaches are commonly used for automated weed detection in agricultural fields (Thompson et al., 1990). The first is to classify crops and weeds based on geometric differences such as leaf shape or plant structure and the second is to use spectral reflectance characteristics (Pérez et al., 2000).

Many researchers have investigated different methodologies for the automation of the weed control process. Shearer and Jones (1991) developed a photo sensor based plant detection system which had the ability of detecting and spraying only the green plants. Shape feature analyses were performed by Woebbecke et al. (1995) on binary images to differentiate between monocots and dicots. Colour, shape and texture analyses approaches have been investigated by Zhang and Chaisattapagon (1995) for classification between weeds and wheat crop. Søgaard (2005) investigated a method of weed classification using image processing based on active shape models and succeeded to identify young weed seedlings with an accuracy of 65% to above 90% using his algorithm. Naeem et al. (2007) classified narrow and broad leaves by measuring Weed Coverage Rate (WCR) which used a PDA as the processing device for this system. Ahmad et al. (2007) developed an algorithm to distinguish images into narrow and broad class based on the Histogram Maxima with threshold technique for selective herbicide application which achieved an accuracy of 95%. Ghazali et al. (2008) achieved above 80% accuracy rate using a combination of statistical GLCM, structural approach FFT, and SIFT features for intelligent real time weed control system in oil palm plantation.

The main objective of this work is to ascertain the feasibility of support vector machine as a classification model to classify crops and weeds from digital images and to determine whether this model can be potentially used in a real-time system. Both colour and shape features were investigated in this study. SVM was chosen because of its good generalization performance, the absence of local minima, and the sparse representation of its solution (Kurzynski et al., 2007).

II. MATERIALS AND METHODS

2.1 Image Acquisition

The images used for this study were taken from a chilli field. In addition, five weed species were chosen that are commonly found in chilli fields in Bangladesh. TABLE I lists both the English and the Scientific names of chilli and these selected weed species.

TABLE

SELECTED SPECIES

Class label

English name

Scientific name

1

Chilli

Capsicum frutescens

2

Pigweed

Amaranthus viridis

3

Marsh herb

Enhydra fluctuans

4

Lamb's quarters

Chenopodium album

5

Cogongrass

Imperata cylindrica

6

Burcucumber

Sicyos angulatus

The images were taken with a digital camera equipped with a 4.65 to 18.6 mm lens. The camera was pointed towards the ground vertically while taking the images. The lens of the camera was 40 cm above the ground level. An image would cover a 30 cm by 30 cm ground area with these settings. No flash was used while taking the picture and the image scenes were protected against direct sunlight. The image resolution of the camera was set to 1200-768. The images taken were all colour images. Figures 1A-F show the sample images of a chilli and the other five weed species.

A B C

E:\Final_Paper\Chilli.jpg E:\Final_Paper\2.1.JPG E:\Final_Paper\Marsh Herb.JPG

D E F

E:\Final_Paper\Lamb's quarter.JPG E:\Final_Paper\Cogongrass - Copy.JPG E:\Final_Paper\Burcucumber.JPG

Figure 1: Sample images of different plants; (A) chilli (B) pigweed (C) marsh herb

(D) lamb's quarter (E) cogongrass (F) burcucumber.

2.2 Pre-processing

Image segmentation method was applied to separate the plants from the soil in these images. A binarization technique based on global thresholding was used for this purpose. The fact that plants are greener than soil was used to guide the segmentation. Let 'G' denotes the green colour component of an RGB image. A gray-scale image was obtained from the original image by considering only the 'G' value. A binarization threshold value was then selected from the gray-level histogram using Otsu's method (Otsu, 1979), a nonparametric and unsupervised automatic threshold selection technique that minimizes the between group variance. Let 'T' denotes this threshold value. The pixels with 'G' value greater than 'T' were considered as plant pixels while the pixels with 'G' value lower than 'T' were considered as soil pixels. For each image, a binary image was obtained, where pixels with value '0' represent soil and pixels with value '1' represent plant.

For removing noise from these images, a morphological opening operation was first applied to the binary images. In opening, an erosion operation is applied after a dilation operation on the image. It has the effect of smoothing the contour of an object, breaking narrow isthmuses and eliminating thin protrusions from an image (Gonzalez and Woods, 2004). Then, a morphological closing operation was applied. In closing, a dilation operation is applied after an erosion operation on the image. It has the effect of eliminating small holes while filling gaps in the contour of an image (Gonzalez and Woods, 2004). Figures 2A-C show the result of applying the pre-processing steps on a sample image of pigweed.

A B C

E:\Final_Paper\2.1.JPG E:\Final_Paper\2.1.g.jpg E:\Final_Paper\2.1.b.JPG

Figure 2: Images of a pigweed; (A) RGB image (B) gray-scale image (C) segmented binary image

2.3 Feature Extraction

A total of fourteen features were extracted from each image. These features can be divided into three categories: colour features, size independent shape features, and moment invariants.

2.3.1 Colour Features

Object identification is often simplified by colour features as it is considered a powerful descriptor. Let 'R', 'G' and 'B' denote the red, green and blue colour components of a RGB image, respectively. For the purpose of this study, every colour component was divided by the sum of all the three colour components. This operation has the effect of making the colour features consistent with different lighting conditions.

r = (1)

g = (2)

b = (3)

While calculating the colour features, only plant pixels were considered. So, the colour features are based on only the plant colour but not the soil (background) colour. The colour features used were: mean value of 'r', mean value of 'g', mean value of 'b', standard deviation of 'r', standard deviation of 'g', and the standard deviation of 'b'.

2.3.2 Size Independent Shape Features

Size independent shape features are useful descriptors as they are dimensionless and independent of plant size, image rotation and plant location within most images (Woebbecke et al., 1995). Four size independent shape features were selected for this study: formfactor, elongatedness, convexity and solidity. For a circle the value of formfactor is '1' and for all other shapes it is less than '1'. Again, long narrow objects have a high elongation value than short wide objects. For an object which is already convex, the value of convexity will be close to '1'. This value decreases as the shape of an object becomes more straggly. On the other hand, a low solidity value towards '0' indicates objects having a rough edge and a high solidity value indicates a smooth object edge.

These shape features can be calculated using some size dependent object descriptors:

Formfactor = (4)

Elongatedness = (Guyer et al., 1986) (5)

Convexity = (6)

Solidity = (7)

Here, area is defined as the number of plant pixels (pixels with a value '1') in the binary image. Perimeter is defined as the number of pixels with a value '1' (plant pixels) for which at least one of the eight neighbouring pixels has the value '0' (background pixel), implying that perimeter is the number of border pixels of a plant. Thickness is twice the number of shrinking steps required to make an object (plant) disappear within an image. The process is defined as the elimination of border pixels of the object by one layer per shrinking step (Guyer et al., 1986). Convex area is defined as the area of the smallest convex hull that covers all the plant pixels in an image. Convex perimeter is the perimeter of the smallest convex hull that covers all the plant pixels in an image.

2.3.3 Moment Invariant Features

Moment invariants refer to certain functions of moments, which are invariant to different geometric transformations such as translation, scaling, and rotation (Jain, 1986). Only central moments are considered in our study.

Let, f(x,y) be a binary image function of a plant. Then, f(x,y) is '1' for those (x,y) that correspond to plant pixels and '0' for those that correspond to soil pixels. Under a translation of co-ordinates, xʹ = x + α, yʹ = y + β, the invariants of (p+q)th order central moments are:

µp,q = ∑x∑y (x − xÌ…)p (y − yÌ…)q f(x,y), p, q = 0, 1, 2, … … (8)

Here, 'xÌ…' and 'yÌ…' are the co-ordinates of the region's center of gravity (centroid). Normalized moments (Jain, 1986), which are invariants under a scale change xʹ = αx and yʹ = αy, can be defined as:

(9)

where

(10)

These normalized moments are invariants to size change. The moment invariants selected for this study are listed below:

Φ1 = η2,0 + η0,2 (11)

Φ2 = (η2,0 + η0,2)2 + 4η1,12 (12)

Φ3 = (η3,0 − 3η1,2)2 + (η0,3 − 3η2,1)2 (13)

Φ4 = (η3,0 + η1,2)2 + (η0,3 + η2,1)2 (14)

These moment features are invariant to rotation and reflection. The moment invariants were calculated on the object area. Natural logarithm was applied to these features to make the moment invariants more linear.

2.4 Classification Using Support Vector Machine

SVM (Cortes and Vapnik, 1995; Burges, 1998) is a novel machine learning approach based on modern statistical learning theory (Vapnik, 1998). The principle of structural risk minimization is the origin of SVM learning (El-Naqa et al., 2002). The objective of SVM is to construct a hyper plane in such a way that the separating margin between positive and negative examples is optimal (Harikumar et al., 2009). This separating hyperplane works as the decision surface. Even with training examples of a very high dimension, SVM is able to achieve high generalization. Furthermore, kernel function facilitates SVM to handle combinations of more than one feature in non-linear feature spaces (Kudo and Matsumoto, 2001).

A classification task in SVM requires separating the dataset into two different parts. One is used for training and the other for testing purpose. Each instance in the training set contains one class label and the corresponding image features. Based on the training data, SVM generates a classification model which is then used to predict the class labels of the test data when only the feature values are provided. A training set of tuples and their associated class labels was used. Each tuple is represented by an n-dimensional feature vector,

X =(x1, x2,… …, xn) where n = 14

Here, 'X' depicts n measurements made on the tuple from n features. There are six classes labelled 1 to 6 as listed in TABLE I.

In the case of SVM, it is required to represent all the data instances as a vector of real numbers. As the feature value for the dataset can have ranges that vary in scale, the dataset is normalized before use. This is to avoid features having greater numeric ranges dominate features having smaller numeric ranges. The LIBSVM 2.91 (www.csie.ntu.edu.tw/~cjlin/libsvm/, accessed August 2010) library was used to implement the support vector classification. Each feature value of the dataset was scaled to the range of [0, 1]. The RBF (Radial-Basis Function) kernel was used for both SVM training and testing which mapped samples nonlinearly onto a higher dimensional space. As a result, this kernel is able to handle cases where nonlinear relationship exists between class labels and features. A commonly used radial basis function is:

K(xi , xj) = exp(−γ || xi − xj ||2), γ>0 (15)

where

|| xi - xj ||2 = (xi - xj)t (xi − xj) (16)

Implementation of RBF kernel in LIBSVM 2.91 requires two parameters: 'γ' and a penalization parameter, 'C' (www.csie.ntu.edu.tw/~cjlin/libsvm/, accessed August 2010). Appropriate values of 'C' and 'γ' should be calculated to achieve a high accuracy rate in classification. By repeated experimentation, values of these two parameters C = 1.00 and γ = 1 / total number of features were chosen.

III. RESULT AND DISCUSSION

To test our proposed method, the full dataset is divided into two subsets - the training dataset and testing dataset set. The training set is used to train the SVM classifier while the testing set is used to predict the accuracy of the classifier. Cross validation is an improved testing procedure that prevents the over-fitting problem. Ten-fold cross validation was applied for the testing purpose. In a ten-fold cross validation, it is required to split the whole training set into ten subsets having equal number of instances. Subsequently, one subset is tested using the classifier trained on the remaining nine subsets. The cross validation accuracy is the percentage of correctly classified test data when each instance of the whole training set is used for testing purpose. The cross validation result of the developed system using all 14 features was 95.9% over 224 samples.

All the crop images were identified correctly by SVM. However, in the cases of weed images, there were some misclassifications. Five images of pigweed were misclassified as burcucumber. Two images of burcucumber were misclassified as pigweed. Two images of marsh herb were misclassified as lamb's quarters. No weed image was misclassified as Chilli. The overall classification result is shown in TABLE II.

TABLE II

CLASSIFICATION RESULT USING ALL FEATURES

English name of samples

Number of samples

Number of misclassified samples

Success rate

Chilli

40

0

100%

Pigweed

40

5

87.5%

Marsh herb

31

2

93.5%

Lamb's quarters

33

0

100%

Cogongrass

45

0

100%

Burcucumber

35

2

94.3%

Average Success Rate

95.9%

To further select the set of features that gives the best classification result, both forward-selection and backward-elimination methods were tried. In forward-selection, the selection process starts with a set having only one feature. Then other features are added to the set one at a time. At each step, each feature that is not the member of the set is tested whether it can be included in the set or not. If no further improvement is achieved, this feature selection procedure is stopped, otherwise it continues to find a better success rate. In backward-elimination, the best feature selection procedure starts with a set initially having all the features included. Then the feature having the least discriminating ability is removed from the set. This process continues until the best classification result is obtained. Forward-selection and backward-elimination methodologies are combined in a novel stepwise feature selection procedure to find out the best feature combination. In stepwise selection, features are added in the set at each step one at a time just like forward-selection. After each feature is added in the set by forward-selection, backward-elimination is applied on the set. Using this method, a set of nine features was selected which produces the best classification rate. Those nine features were:

Solidity

Elongatedness

Mean value of 'r'

Mean value of 'b'

Standard deviation of 'r'

Standard deviation of 'b'

ln(Φ1) of area

ln(Φ2) of area

ln(Φ4) of area

The result of ten-fold cross validation using these nine features was 97.3%. Four images of pigweed were misclassified as burcucumber and two images of burcucumber were misclassified as pigweed. All other images were classified accurately. The overall classification result using these nine features is given in TABLE III.

TABLE III

CLASSIFICATION RESULT USING BEST FEATURES

English name of samples

Number of samples

Number of misclassified samples

Success rate

Chilli

40

0

100%

Pigweed

40

4

90%

Marsh herb

31

0

100%

Lamb's quarters

33

0

100%

Cogongrass

45

0

100%

Burcucumber

35

2

94.3%

Average Success Rate

97.3%

IV. CONCLUSION

In this paper, an automated weeding system that has the ability to identify crops from weeds automatically and treat them accordingly is proposed. It is a machine vision system developed using digital image processing techniques that can result in very efficient sensor detection. For real-time implementation of this machine vision system, an efficient classification model that can classify crops and weeds with a high accuracy ratio must be included. The goal of this paper is to ascertain the feasibility of support vector machine (SVM) in crops and weeds classification. From our experimental results, it is clear that SVM provides very high classification accuracy while being highly robust. To achieve further increase in classification rate in real-time implementation of SVM in a weed classification system, we believe that good image segmentation and noise reduction techniques will be highly useful.

Writing Services

Essay Writing
Service

Find out how the very best essay writing service can help you accomplish more and achieve higher marks today.

Assignment Writing Service

From complicated assignments to tricky tasks, our experts can tackle virtually any question thrown at them.

Dissertation Writing Service

A dissertation (also known as a thesis or research project) is probably the most important piece of work for any student! From full dissertations to individual chapters, we’re on hand to support you.

Coursework Writing Service

Our expert qualified writers can help you get your coursework right first time, every time.

Dissertation Proposal Service

The first step to completing a dissertation is to create a proposal that talks about what you wish to do. Our experts can design suitable methodologies - perfect to help you get started with a dissertation.

Report Writing
Service

Reports for any audience. Perfectly structured, professionally written, and tailored to suit your exact requirements.

Essay Skeleton Answer Service

If you’re just looking for some help to get started on an essay, our outline service provides you with a perfect essay plan.

Marking & Proofreading Service

Not sure if your work is hitting the mark? Struggling to get feedback from your lecturer? Our premium marking service was created just for you - get the feedback you deserve now.

Exam Revision
Service

Exams can be one of the most stressful experiences you’ll ever have! Revision is key, and we’re here to help. With custom created revision notes and exam answers, you’ll never feel underprepared again.