COLOUR AND SHAPE ANALYSIS TECHNIQUES
                             FOR WEED DETECTION IN CEREAL FIELDS

                             A.J. Pérez, F. López, J.V. Benlloch, S. Christensen*

                                  Universidad Politécnica de Valencia
                   Departamento de Ingeniería de Sistemas, Computadores y Automática
                                P.O. Box 22012. 46071 Valencia, Spain
                    (corresponding author)
                               *Danish Institute of Plant and Soil Science
                              Dept. of Weed Control and Pesticide Ecology
                              Forsoegsvej 1, DK-4200 Slagelse, Denmark

               Abstract: Information on weed distribution within the field is necessary to
               implement spatially variable herbicide application. This paper deals with the
               development of near-ground image capture and processing techniques in
               order to detect broad leaf weeds in cereal crops, under actual field
               conditions. The proposed methods use both colour and shape analysis
               techniques for discriminating crop, weeds and soil. The performance of
               algorithms was assessed by comparing the results with a human
               classification, providing a good success rate. The study shows the potential
               of using image processing techniques to generate weed maps.

               Keywords: Weed Detection, Image Processing Techniques, Colour, Shape
               Analysis, Patch Spraying.

1 Introduction

Since a number of recent investigations have shown that most weed species are aggregated and often
occur as patches within the arable fields (Rew & Cussans, 1995), the conventional practice of
applying herbicides uniformly across a whole field, seems undesirable in both economic and
environmental terms (Christensen et al., 1996). In order to implement spatially variable herbicide
application (Nordbo et al., 1994), information on distribution of weeds is required. As manual
surveying is a labour-intensive method, machine vision detection of weeds has been proposed.

         Taking into account that real-time patch spraying (weed monitoring and spraying are carried
out simultaneously) is still a difficult process, the overall objective of this research is to study the
feasibility of automatically mapping weeds, a few days before the herbicide application.

        This study is part of an E.C. Project “Patchwork” (Nº AIR3-CT93-1299), that aims to
develop, demonstrate and evaluate systems and techniques for carrying out spatially variable
treatments, such as patch weeding, by chemical or other means.

  First European Conference for Information Technology in Agriculture, Copenhagen, 15-18 June, 1997
2 Background and review of literature

For automatic weed monitoring in cultivated crops, two general approaches have typically been used
(Thompson et al., 1990). The first is to detect certain geometric differences between the crop and
weeds, such as leaf shape or plant structure. The second general approach is based on differences in
spectral reflectance. There may also be a difference in location of the crop compared with the weed.

          Guyer et al. (1986) studied the feasibility of using leaf shape for plant identification. The
initial investigation was limited to individual plants (three crop and five weed species) viewed against
a soil background, in laboratory conditions. The differences between vegetation and soil reflectances
in the near-infrared region, proved successful for segmenting plants from a soil background.

        Hatfield & Pinter (1993) reviewed the potential of remote sensing techniques for crop
protection in the field, and suggested that one way to distinguish between weeds and crops was by
examining the temporal patterns of vegetation indices throughout the growing season.

        Brown et al. (1994) reported that there appeared to be potential for distinguishing weeds from
agricultural crops based on their relative spectral reflectance characteristics. However, they added that
it might be necessary to look at identifying groups of weeds rather than individual species, in real
agricultural environments.

        Woebbecke et al. (1995) used shape feature analysis for discriminating between monocots
and dicots. The plants used in that experiment were grown individually in pots and colour information
was used to separate target plants from the soil and residue background.

         Zhang & Chaisattapagon (1995) have studied three different approaches to identify weeds in
wheat fields using machine vision: colour analysis, shape analysis and texture analysis. They used
black-white digital images with various colour filters, under laboratory conditions. The red and green
filters were effective in detecting reddish stems of some weed species. Shape parameters were
effective in distinguishing single leaves of broadleef weeds from wheat leaves.

       The study reported here uses both colour and shape analysis techniques to detect broad leaf
weeds in cereal crops, under actual field conditions. Species identification is beyond the scope of this

3 Materials and methods

Both slides and colour video near-ground images were taken in natural lighting conditions during
1995/6 in Danish cereal fields. The images represented samples of about 0.25 m2 (since this area is
commonly used in visual surveyings). Images were digitised using a colour scanner and a frame
grabber respectively.

3.1 Colour analysis

The initial goal in the image analysis process was to divide the different pixels of the scene into two
classes: soil (background) and plants (crops and weeds). For accomplishing that, differences in
spectral reflectance between vegetation and soil were primarily used. The process includes the
following steps: Firstly, a normalised difference index using green and red channels was selected to
improve the contrast in the image while the amount of information was significantly reduced.
Secondly, segmentation techniques based on a global thresholding together with a growing process
were applied to discriminate between plant and background (Benlloch et al., 1995).
Once plant pixels were recognised, the position of crop rows could be computed, provided cereal
crops have a certain one-dimension periodicity (distance between rows should be approximately
constant). Since in the context of row crops, a weed is a plant out of place, a labelling step considered
all the plants in the inter-row-spaces, as weeds.

Nevertheless, using this approach, pieces of crop not connected to the rows (mainly due to twisted
leaves) were considered as weeds, resulting in an important error source.

3.2 Shape analysis

In order to overcome this problem, a shape analysis was considered on all these objects. The process
included feature extraction, feature selection, classifier design and classifier evaluation.

The first step aimed at describe unconnected objects as a function of some geometrical features: major
axis length, aspect ratio, area, ratios of the major (minor) axis length squared to the area, roundness,
seven geometric invariants based on normalised central moments, etc, Thus, each object was
represented as a vector in the feature space.
In order to determine which features were the most useful to discriminate between both classes
(weeds and crop), an initial selection process was carried out. For each feature, the Fisher ratio was
used as a measure of how overlapped the classes were:

                                                     x weed − x crop
                                    Vweed / crop =                                                    (1)
                                                     σ weed + σ crop
                                                       2        2

After this process, the following shape features were considered:
• C1 : Ratio of the major axis length squared to the area.
• C2 : First invariant central moment.
• C3 : Major axis length.
• C4 : Ratio of the perimeter squared to the area.
• C5 : Minor axis relation.
• C6 : Distance to the crop row.
• C7 :‘Weed-like’, heuristic index obtained after using some morphological operations such as
  erosions and dilations (based on the fact that most weeds are dicots).
Using this feature set, three Pattern Recognition methods have been essayed to design and evaluate
classifiers: heuristic approach, Bayes rule and K-Nearest Neighbour (Devijver & Kittler, 1982).
In all the cases, the whole set of samples has been randomly divided into two disjoint subsets, the
training set (70%) and the test set (30%), in such a way that we can consider the learning process as
not specialised in a part of the universe, but in all. In order to minimise the differences in magnitude
between features, values have been normalised.
        Heuristic approach. It is in fact a knowledge-based method, where a weight, or trust factor,
Kj, is assigned to each feature Cj, as a function of how well feature values are able to distinguish
between classes. At first, all the weights were equally set, but after the training process, each feature
weight is tuned up either increasing when the decisions are correct or decreasing, in the case of
The general idea, shown in Fig. 1, is to combine the weights of the different features before deciding
the class which a sample belongs to.

            Figure 1. Poll system.                                 Figure 2. Voter diagram.

For each voter two thresholds, Tc and Tw, were defined starting from the accumulated histograms. As
depicted in Figure 2, Tw is defined in such a way that feature values being smaller than, will probably
correspond to weeds (only a low percentage of crop pieces falls below this threshold). On the other
hand, Tc is defined in such a way that values being bigger than, will probably correspond to crop
The voter then returns a +K if features values are bigger than Tc, -K if values are smaller than Tw,
otherwise, it returns a null value. Thus, given a feature vector, all the corresponding weights (sign
included) are added. The final classification depends on the comparison between the sum and a global
        Bayes Rule. This method assumed a normal distribution for both classes and used Bayes rule
to calculate the probability of a sample of being weed or crop piece.
        K-Nearest Neighbours. Different approaches have been implemented, adopting the Euclidean
distance as distance measure. Firstly, all the training set was considered as prototypes for both classes
and the k-NN (k = 1) decision rule was applied over the test set. In order to reduce the
misclassifications due to the proximity between classes (fairly overlapped), other experiments
increasing k, from 3 to 45 (step 2) were carried out.

4 Results and discussion
A set of 32 colour images was used to validate the three methods. All the objects considered as
possible weeds, were classified by hand.
Both Bayes Rule as k-NN methods have used all the possible combinations of the former features to
evaluate the algorithms. The following table summarises the results of each method.
Table 1. Success rate of the different Pattern Recognition Methods.
       Method                     Bayes rule            k-NN (k = 5)                   Heuristic
  expected/detected            crop       weeds       crop       weeds              crop      weeds
        crop                  89.7%       10.3%      89.0%       11.0%             80.2%      19.8%
       weeds                  25.5%       74.5%      20.8%      79.2%              27.7%      71.3%

The comparative study has demonstrated that classical approaches provide better results (k-Nearest
Neighbours with k = 5, and Bayes Rule), although heuristic method may be useful when processing
time restrictions are present.
Finally, the global performance of weed detection algorithms has been assessed by comparing the
results provided by the algorithms with those of visual surveying. Correlation graphs (Fig. 3) show
that a 75 % of real weeds were initially detected, rising up to a 85%, when shape analysis was

                    VISUAL vs DETECTED                            VISUAL vs DETECTED
                      (no shape analysis)                              (shape analysis)
          100                                               100
           80                                                80
           60                                                60
           40                                                40
           20                                                20
            0                                                 0
                0        20        40       60                    0       20       40      60

                    Figure 3. Correlation graphs between visual and automatic methods.

Even the high correlation, a general underestimation appears in automatic methods, mainly due to
factors as: natural lighting conditions (highlights and shadows), weeds embedded into the crop, the
lack of periodicity in he crop geometry, as well as the smallness and the variability of weeds.

A practical example of the proposed methods can be seen in the images below (Fig. 4).

           Fig 4.a) Original image.                                   Fig. 4.b) Processed image.
5 Conclusions and further work

Weed detection using image processing techniques have shown a good potential to estimate weed
distribution even the difficulties due to the similarity in spectral reflectance between weed and crop
plants, and because of the variability of natural scenes. It seems convenient that this approach be
complemented by other sources of information (species identification, historic yield maps,...) in order
to generate weed maps that are sufficiently comprehensive to use in a patch spraying system.

         In order to reduce the error rate, different approaches are being undertaken. Concerning
acquisition, B/W video cameras equipped with NIR filters, seems to provide enhanced images which
facilitates initial segmentation. On the other hand, illuminant modelling algorithms try to overcome
the drawbacks own to the presence of highlights and shadows. Finally, more resolution images should
be obtained to reduce the error rate of shape analysis steps.


Benlloch, J.V., M. Agustí M., A. Sánchez & A. Rodas (1995). Colour Segmentation Techniques For
Detecting Weed Patches In Cereal Crops. In: Proceedings of the 4th Workshop on Robotics in
Agriculture & the Food-Industry. 71-81. Toulouse, France.

Brown, R.W.; J.P.G.A. Steckler & G.W. Anderson (1994). Remote Sensing for Identification of
Weeds in no-Till Corn. Transactions of the ASAE. 37(1): 297-302.

Christensen, S., T. Heisel & M. Walter (1996). Patch spraying in cereals. In: Proceedings of the
Second International Weed Control Congress. 963-8. Copenhagen, Denmark.

Devijver, P.A. & J. Kittler (1982). Pattern Recognition: a Statistical Approach, Ed. Prentice-Hall.

Guyer, D.E., G.E. Miles, M.M Schreiber, O.R. Mitchell & V.C Vanderbilt (1986). Machine vision
and image processing for plant identification. Transactions of the ASAE 29(6): 1500-1507.

Hatfield, J.L. & P.J. Pinter (1993). Remote sensing for crop protection. Crop Protection 12 (6): 403-

Nordbo, E., S. Christensen, S., K. Kristensen & M. Walter (1994). Patch spraying of weed in cereal
crops. Aspects of Applied Biology 40: 325-334.

Rew, L. J. & G. W. Cussans (1995). Patch ecology and dynamics - how much do we know? In: Proc.
Brighton Crop Protection Conference BCPC Publications. 1059-1068.

Thompson, J.F., J.V. Stafford & B. Ambler (1990). Weed Detection in Cereal Crops. American
Society of Agricultural Engineers Paper 90-1629. American Society of Agricultural Engineers, St
Joseph, MI 49085.

Woebbecke D. M., G.E. Meyer, K. Von Bargen and D. Mortensen (1995). Shape features for
identifying young weeds using image analysis. Transactions of the A.S.A.E. 38 (1): 271-281.

Zhang N. & C. Chaisattapagon (1995). Effective criteria for weed identification in wheat fields using
machine vision. Transactions of the A.S.A.E. 38 (3): 965-974.

To top