# Farmland Weed Species Identification Based on Computer Vision

Shengping Liu, Junchan Wang, Liu Tao, Zhemin Li, Chengming Sun, Xiaochun Zhong

► To cite this version:

Shengping Liu, Junchan Wang, Liu Tao, Zhemin Li, Chengming Sun, et al. Farmland Weed Species Identification Based on Computer Vision. 11th International Conference on Computer and Computing Technologies in Agriculture (CCTA), Aug 2017, Jilin, China. pp.452-461, 10.1007/978-3-030-06137-1_41. hal-02124257

HAL Id: hal-02124257

https://inria.hal.science/hal-02124257

Submitted on 9 May 2019

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Farmland Weed Species Identification Based on Computer Vision

Shengping Liu¹, Junchan Wang², Liu Tao³, Zhemin Li¹, Chengming Sun³, and Xiaochun Zhong¹(✉)

¹ Institute of Agriculture Information, Chinese Academy of Agriculture Sciences/ Key Laboratory of Agro-information Services Technology, Ministry of Agriculture, Beijing, China

{ liushengping,lizhemin,zhongxiaochun}@caas.cn

² Lixiahe Regional Institute of Agricultural Sciences of Jiangsu Province, Yangzhou, China
wjc@wheat.org.cn

³ Jiangsu Key Laboratory of Crop Genetics and Physiology/Co-Innovation Center for Modern Production Technology of Grain Crops, Yangzhou University, Yangzhou, China
{tliu,cmsun}@yzu.edu.cn

**Abstract.** In order to alleviate the difficulties in collecting indexes for the analysis of farmland weed communities, we implemented a computer vision technology-based method for the identification of farmland weeds at the species level. By using the super-green and maximum interclass difference methods to obtain a green vegetation binary image, we were able to separate weeds from cultivated crops through multiple etching and the removal of small areas. A BP (back propagation) neural network was used for weed recognition, and the morphological characteristics of the weeds and each region were selected following etching to construct the input matrix of the recognition model for training and testing the BP network. After experimenting with the computational vision method for the identification of five weed species, we discovered that the recognition accuracy rate reached 96%. The results showed that the computer vision method could quickly and accurately extract a weed community analysis index, thereby providing a reference for the intelligent analysis of weed communities.

**Keywords:** weed communities, index extraction, image processing, class, computer vision

## 1 Introduction

Rice paddy weeds compete with rice for sunlight, nutrients, and water, which can severely impact the yield and quality of rice [1,2]. Conversely, weeds are an important component of a balanced and stable farmland ecosystem and play an important role in holding soil moisture and fertilizers, accelerating nutrient cycling, and providing a living environment for soil organisms [3,4]. Studying farmland weed communities is therefore of considerable significance for ensuring food security and maintaining ecosystem stability.

Weed species constitute the primary quantitative index in studying farmland weed communities. Three primary methods for identifying weeds in the field exist: the manual identification method, the remote sensing method, and the computer vision-based recognition method. Currently, data in a fixed area is mainly obtained manually [5-8]. The investigation of weed species usually requires the professional evaluation or the assistance of the weed primary color spectrum [3].

* Corresponding author. Tel: +86-10-82106768, E-mail: zhongxiaochun@caas.cn
The development of computer vision and image processing technologies has played an important role in weed species identification [12-17]. The identification of weed species has mainly been performed by extracting morphological, color, and texture parameters, and using these characteristic parameters to establish a weed identification model. The identification models commonly used include the camera supported model and the artificial neural network model [16-19].

Some scholars have used leaf color to identify weeds at the species level, but the recognition speed and accuracy is low and requires further improvement. Additionally, some scholars use morphological characteristics in identification, however, extracting the morphological characteristics is difficult as the leaves tend to intertwine with each other in the natural environment, and thus this method is not conductive for outdoor weed identification. Therefore, accurate weed identification cannot be achieved using only one factor, and multiple features are required for a comprehensive analysis. In this study, by extracting characteristic morphological, color, and texture parameters, an identification model for weed species was established using multi-characteristic parameters. The current research mainly uses a computer vision system to identify weeds from crop plants and measure the soil background to calculate their distribution [16,19]. Few studies have focused on the identification of farmland weed communities. In this study, we developed a computer vision extraction method for weed species, thereby providing a reference for the intelligent analysis of farmland weed communities.

## 2 Materials and Methods

The images used in this study were obtained from rice-wheat rotation fields from 2014 to 2016. Five common species of field weeds were selected for the species recognition experiments. There were 40 images in total (750 × 750 pixels) for each weed species. The identification process is shown in Fig. 1.

<figure><img src="image_2.png" /><figcaption>Fig.1 The processes of identify weed types</figcaption></figure>

### 2.1 Extraction

As shown in Fig. 2a, the original image includes rice plants, *Monochoria* seedlings, duckweed, and *Spirogyra*. The green vegetation of the samples was extracted using
equation (1) and the OTSU method [17], and the extraction results are shown in Fig. 2b (including crops, weeds, and Spirogyra). In the RGB images (Fig. 3), the green band of Spirogyra was relatively smaller than the weeds and crops. Further threshold segmentation using green bands reduced the effects of the Spirogyra on weed extraction. The results are shown in Fig. 2c. The method was effective at reducing the influence of Spirogyra in paddy fields.

$$ ExG = 2G - R - B \qquad (1) $$

<figure><img src="image_3.png" /><figcaption>Fig.3 Green band histogram of crop/weed/ spirogyra</figcaption></figure>

We first removed the areas with fewer than 1,000 pixels in Fig. 4a, and then used a 3 × 3 template to etch the binary images, and then removed the areas with fewer than 800 pixels in the binary images. Following this, we used the same operation to etch the binary images twice and removed the areas with fewer than 600 pixels and 400 pixels; performed 3 expansion operations on the obtained binary images by using the 3 × 3 templates; filled the smaller holes in the region by using the hole-filling algorithm [21]; and obtained the binary images of the weeds.

## 2.2 Weed Species Identification

Weeds are difficult to identify at the seedling stage. We therefore selected *Galium aparine*, *Veronica didyma*, *Chenopodium serotinum*, *Monochoria vaginalis*, and *Vicia sativa* as study objects. The binary images of the weeds (Fig. 4) were obtained by using the green vegetation extraction method detailed in Section 2.1.
<figure><img src="image_4.png" /><figcaption>Fig.4 Binarization for weed images</figcaption></figure>

## 2.3 Feature Parameter Selection

Due to the influence of light, image acquisition equipment, and other factors, the color and texture characteristics of the same weed species obtained in the wild often differ. However, the morphological characteristics are not affected by these environmental factors. Therefore, we selected the following morphological parameters to construct the feature vector for identifying weed species:

$$ \text{compactness: } C_o = \frac{4\pi A}{P} \qquad (2) $$

$$ \text{quasi circularity: } R = \frac{4A}{\pi M} \qquad (3) $$

$$ \text{foliaceous: } B = \frac{R}{M} \qquad (4) $$

$$ \text{centrifugal rate: } B = \frac{S}{L} \qquad (5) $$

Where A is the area of the binary region, P is the circumference of the binary region, M is the major axis length of the smallest circumscribed rectangle, R is the shortest distance from the regional centroid to the boundary, S is the minor axis length of the region, and L is the major axis length of the region. To better reflect the blade shape and blade configuration, we used a template of a certain size (the size of the template approximately equal to 1/60 of the binary region) to etch the region. The number N of the binary region in the image following etching is the characteristic value, and the mean and variance of the quasi circularity, foliaceous, and centrifugal rate of each region also constitute characteristic values used to identify the weed species.

## 2.4 Selection of the Recognition Model

In this study, we used the BP (back propagation) neural network to identify the five weed species. The back propagation (BP) neural network is a multi-layer feedforward network trained according to error back-propagation algorithm and is one of the most widely used neural network models. BP network can be used to learn and store a large number of mapping relations of input-output model without prior description of the mapping relationship [22]. In the study, 20 images were selected for each species for the construction and training of the network. The network input data constitute the 11 characteristic values described in Section 1.3 and were extracted from each image. The input data were normalized to increase the network convergence speed and diagnostic accuracy [23]. A three-layer BP neural network was constructed, and the network input layer consisted of 11 neurons corresponding to 11 eigenvalues,
respectively. There were 20 neurons in the hidden layer, and one neuron in the output layer. The learning rate was set to 0.5, the inertial coefficient was 0.8, the number of iterations was set to 1,000, and the target error was set to 0.001. The hidden layer transfer function was selected as the Tansig type, namely:

$$f(x) = \frac{2}{1 + e^{-ax}} - 1 \qquad (6)$$

Where a is the slope function of the Tansig function, and a is 2 in this paper.

The training process of the weed recognition model is shown in Fig. 5. The 100 network training samples were numbered in sequence: 1–20 for *G. aparine*, 21–40 for *V. didyma*, 41–60 for *C. serotinum*, 61–80 for *M. vaginalis*, and 81–100 for *V. sativa*. The input sample matrix of the network training was 11 × 100 and the output matrix of the network training was 1 × 100, with each element corresponding to the classification of the sample and a value of 1, 2, 3, 4, and 5, respectively. After 1,000 iterations, the target error of 0.001 was achieved. The training results are shown in Fig. 6. It was evident that all the samples had been correctly identified.

<figure><img src="image_5.png" /><figcaption>Fig.5 Training iteration of weed identification</figcaption></figure>

<figure><img src="image_6.png" /><figcaption>Fig.6 Simulation output of training samples</figcaption></figure>

## 3 Results

The 100 samples for the verification of the recognition model were numbered in sequence: 1–20 for *G. aparine*, 21–40 for *V. didyma*, 41–60 for *C. serotinum*, 61–80 for *M. vaginalis*, and 81–100 for *V. sativa*. We extracted the 11 characteristic values of each sample to construct the 11 × 100 input matrix and normalized the data. The normalized test samples were input into the network to perform the simulation. The output result of the simulation is shown in Fig. 7, and all test samples were identified.
The recognition accuracy was only 87% when only the four feature values for the
weeds were used in the training and development of the method, without using the
morphological characteristics of each region following etching. The recognition was
even lower for *G. aparine* and *V. didyma* at only 80% and 85%, respectively. The
simulation output result is shown in Fig. 8.

<figure><img src="image_7.png" /><figcaption>Fig.7 Simulation output of test examples</figcaption></figure>

<figure><img src="image_8.png" /><figcaption>Fig.8 Simulation output of test examples (only use characteristics of weeds itself)</figcaption></figure>

4 Discussion

Common methods of farmland weed recognition include these features: threshold
segmentation method based on machine vision, weed identification method based on
genetic algorithm, weed identification based on polarization spectrum and weed
identification method based on BP network. According to the external characteristics
of weeds, threshold segmentation method based on machine vision realizes image
segmentation and weed recognition through using the threshold segmentation model.
The recognition rate was about 85% [24]. The weed recognition method based on
genetic algorithm can identify weeds quickly and accurately, and reduce the
occurrence of local optimal value. The recognition rate was about 93% [25]. The
method of recognizing weeds based on polarization spectrum can identify the weed
model well by analyzing and comparing the spectral response law, spectrum
characteristics and decision precision of weeds, and the comprehensive recognition
rate of different polarization states reaches more than 90% [26]. After the training of
samples, weed recognition method based on BP neural network can recognize 96% of
weeds in seedling stage. According to different site requirements, the most suitable
identification algorithm can be selected for application in practical application.

5 Conclusion

The correct identification of weed species in farmlands is a prerequisite for the
analysis of farmland weed communities. In this study, we proposed a weed extraction
method for the field environment and successfully identified weed species in this
environment using a combination of 11 morphological features and a BP neural
network. We reached the following conclusions:
1) We proposed a computer vision-based weed extraction method for the field environment. The green vegetation in the field could be successfully extracted by using the super-green method and OTSU algorithm. The effect of Spirogyra on the paddy field images was eliminated by using the green component and the OTSU algorithm in the RGB mode.

2) We proposed a weed identification method based on the BP neural network. Including the morphological characteristics of the weeds and of each area following etching could better reflect the weed species. When only weed characteristic values were used, the recognition accuracy rate was 87%, and the accuracy rate did not exceed 85% for the identification of *G. aparine* and *V. didyma*, which share similar morphological characteristics. The network trained by the two types of characteristic values at the same time was thus able to identify the samples. This indicated that the method proposed in this paper could effectively identify and classify field weeds with a recognition accuracy rate above 96%.

3) In this paper, we segmented and identified five common weed species occurring in the field environment. The process was neither affected by the external lighting conditions nor the image acquisition equipment, has wide adaptability, and can provide a reference for the recognition of other weeds under natural conditions. However, weeds at the seedling stage were selected for the weed identification experiment, and thus the identification of weeds at maturity still requires further study.

# 6 Acknowledgment

This research was supported by Technology Innovation Project Fund of Chinese Academy of Agricultural Sciences (2017).

# References

1. Shuren Chen, Huadong Zou, Ruimei Wu, et al. Identification for Weedy Rice at Seeding Stage Based on Hyper-spectral Imaging Technique[J]. Transactions of the Chinese Society for Agricultural Machinery. 44(05): 253-257 (2013)

2. Ali A, Streibig J C, Andreasen C. Yield loss prediction models based on early estimation of weed pressure[J]. Crop Protection. 53(0): 125-131 (2013)

3. Linlin Shi, Mingxing Shen, Min Jiang, et al. Effect of long-term different fertilization management on weed community in rice-wheat rotation field[J]. Scientia Agricultura Sinica. 46(02): 310-316 (2013)

4. Lake E C, Hough-Goldstein J, Shropshire K J, et al. Establishment and dispersal of the biological control weevil Rhinoncomimus latipes on mile-a-minute weed, Persicaria perfoliata[J]. Biological Control. 58(3): 294-301 (2011)

5. Radicetti E, Mancinelli R, Campiglia E. Impact of managing cover crop residues on the floristic composition and species diversity of the weed community of pepper crop (Capsicum annuum L.)[J]. Crop Protection. 44(0): 109-119 (2013)

6. Chuanpeng Cheng, Kaiyuan Wan, Yong Tao, et al. The effects of fertilization on weed communities and wheat growth in winter wheat (Triticum aestivum L.) field under different cropping rotations[J]. Ecology and Environmental Sciences. 22(03): 370-378 (2013)

7. Chunhua Dong, Qiang Liu, Jusheng Gao, et al. Effects of different fertilization models on the characteristics of weed communities during the rice growing seasons[J]. ACTA PRATACULTURAE SINICA. 22(03): 218-226 (2013)

8. Rong Yang, Yongzhong Su. Effects of cultivation regimes on weed community structures in newly reclaimed sandy farmlands[J]. Chinese Journal of Eco-Agriculture. 18(06): 1218-1222 (2010)

9. Dongjian He, Yongliang Qiao, Pan Li, et al. Weed recognition based on SVM-DS multi-feature fusion[J]. Transactions of the Chinese Society for Agricultural Machinery. 44(02): 182-187 (2013)

10. Wenbo Zhang, Bingjun Lu, Wei Shi. Determination of vegetation coverage by photograph and automatic calculation[J]. Bulletin of Soil and Water Conservation. 29(02): 39-42 (2009)

11. Lian Hu, Xiwen Luo, Shan Zeng, et al. Plant recognition and localization for intra-row
mechanical weeding device based on machine vision[J]. Transactions of the Chinese Society of Agricultural Engineering. 29(10): 12-18 (2013)

12. Bauer T, Strauss P. A rule-based image analysis approach for calculating residues and vegetation cover under field conditions[J]. CATENA. 113(0): 363-369 (2014)

13. Swain K C, Nørremark M, Jørgensen R N, et al. Weed identification using an automated active shape matching (AASM) technique[J]. Biosystems Engineering. 110(4): 450-457 (2011)

14. Tellaeche A, Pajares G, Burgos-Artizzu X P, et al. A computer vision approach for weeds identification through Support Vector Machines[J]. Applied Soft Computing. 11(1): 908-915 (2011)

15. Jinchun Zhang, Hongxiao Yang. Application of self-organizing neural networks to classification of plant communitiee in panquangou nature reserve,North China[J]. ACTA ECOLOGICA SINICA. 27(03): 1005-1010 (2007)

16. Deyao Fan, Jing Yao, Baojun Yang, etl. Progress in research on intelligentization of field weed recognition and weed control technology[J]. Scientia Agricultura Sinica. 43(09): 1823-1833 (2010)

17. Jun Zhou, Mingjun Wang, Qiaolin Shao. Adaptive segmentation of field image for green plants[J]. Transactions of the Chinese Society of Agricultural Engineering. 29(18): 163-170 (2013)

18. Decai Zhang, Chunguang Zhou, Qiang Zhou, etl. Hole-Filling Algorithm Based on Contour[J]. Journal of Jilin University(Science Edition). 49(1): 82-86 (2011)

19. Xiuguo Zou, Weimin Ding, Deying Liu, etl. Transactions of the Chinese Society of Agricultural Engineering[J]. Classification of rice planthopper based on invariant moments and BP neural network. 29(18): 171-178 (2013)

20. Xiaotong Liu. Study on data normalization in BP neural network[J]. Mechanical Engineering & Automation. (03): 122-123 (2010)

21. Pulido, Camilo, Solaque, Leonardo, Velasco, Nelson. Weed recognition by SVM texture feature classification in outdoor vegetable crop images [J]. Ingenieria E Investigacion. 37(1): 68-74 (2017)

22. Pantazi, Xanthoula-Eirini, Moshou, Dimitrios, Bravo, Cedric. Active learning system for weed species recognition based on hyperspectral sensing [J]. Biosystems Engineering. 146(SI): 193-202 (2016)

23. Rahman, Mahbubur, Blackvvell. Smartphone-based hierarchical crowdsourcing for weed identification [J]. Computers and Electronics in Agriculture. 113: 14-23 (2015)

24. Saha, Dheeman, Hanson, Austin, Shin, Sung Y. Development of Enhanced Weed Detection System with Adaptive Thresholding and Support Vector Machine. Conference on Research in Adaptive and Convergent Systems (RACS). ACM. pp. 85-88 (2016)

25. Yang jianjiao, Qi ji, Zhu fengwu. Study on identification of the field weed based on genetic neural network [J]. Journal of Chinese Agricultural Mechanization, 37(9): 223~226, 230 (2016)

26. Lin Fenfang, Zhang Dongyan, Wang Xiu, Wu Taixia, Chen Xinfu. Identification of corn and weeds on the leaf scale using polarization spectroscopy[J]. Infrared and Laser Engineering. 45(12):361-370 (2016)