Keywords

1 Introduction

The presence of Cirsium arvense, also known as Canadian thistle, and other types of weeds in organic cereal crops is a major concern in Nordic countries such as Norway and Denmark [2], primarily because they result in significant losses in crop efficiency, causing an average of 29.2% production losses worldwide if weed control is not applied [3]. Therefore, there is a need to identify areas with weeds so that farmers can take the appropriate actions. These weeds are usually controlled via the application of glyphosate before or after harvest [4], which can sometimes lead to the indiscriminate use of these chemicals, increasing production costs, soil depletion, and environmental contamination [5, 6].

Site-specific weed management (SSWM) is a precision agriculture approach that refers to the variable application of weed control to minimize the use of herbicides [7]. Currently, different machine learning based methods are being implemented to detect specific areas of weed-growing cultures. For example, Gao et al. [8] implemented a method based on randomized forests and compared it to the K-nearest neighbors method to recognize weeds in corn crops using hyperspectral images and obtained accuracies higher than 93%. Image processing methods have also been used; Pérez et al. [9] detected broadleaf weeds by analyzing the colors and shapes to discriminate bottom vegetation and obtained better results than human experts. In a study focused on the detection of Cirsium arvense conducted by Sorensen [1], convolutional neural networks (CNNs) were implemented, obtaining accuracies higher than 97%, based on detecting the excess of green (ExG) characteristic of the weed.

In this study, we introduce a tool based on image processing that allows the easy and rapid detection of perennial weeds in cereal crops. To determine its efficiency, the results are compared to those produced by other popular techniques based on machine learning such as naive Bayes, descendant gradient, decision trees, nearest neighbors, neural networks, and support vector machine. Similarly, a comparative study was performed using previous results based on CNNs.

2 Materials

In this study, 26 photographs of cereal crops showing the presence of the Cirsium arvense (weed) plant, taken by a Canon PowerShot G15 camera with a size of 4000 × 3000 pixels, were used, among which 13 were taken at a height of 10 m and the rest were taken at a height of 50 m [1]. The images were cut from the original photographs to reduce the computational cost required by the process. A database of 800 samples of 5 × 5 pixels obtained from 20 of the images was constructed for use in the learning and adjustment of the machine learning based algorithms, as illustrated in Fig. 1. Half of the samples correspond to weeds (positive samples) and the rest to culture (negative samples). A total of 30 subimages of 200 × 200 pixels each (see Fig. 2) were obtained from the remaining six images and were used to validate and compare the methods.

Fig. 1.
figure 1

Sample 5 × 5 pixel images used for the estimation and training of the machine learning algorithms: (a) weed and (b) crop images.

Fig. 2.
figure 2

Example of an image employed for the validation of the algorithms.

The study used an HP-2840 computer with 15.6 GB of memory, an Intel Xeon processor (R) CPU E5-2650v4 @ 2.20 GHz × 24, a NVIDIA Quadro P600 graphics card, and a Linux-Ubuntu operating system 16.04LTS. The machine learning algorithms were implemented in Python 2.7 using the OpenCV, Scikit-learn, NumPy, and Time releases. The image processing method was implemented using the free access software ImageJ.

3 Methods

A visual analysis of the photographs indicates that the RGB color space is not the most appropriate one for learning as it is difficult to recognize the areas where the weed is found, as shown in Fig. 3a. This observation was corroborated via a learning analysis with a reduced number of samples, where it was found that the accuracy was very low. Transforming the images into the Lab color space provides a better visual differentiation, particularly in channel a*, as shown in Fig. 3b.

Fig. 3.
figure 3

Cereal crops: (a) original RGB image and (b) channel a* of the Lab color space.

To train the learning algorithms, 80% of the extracted data were used (600 samples of 5 × 5 pixels) for the estimation of the parameters. The remaining 20% of the extracted data were used to find the optimal values of each classifier according to the precision, as presented in Table 1. Finally, the classification was performed and the accuracies of the methods listed in Table 1 were evaluated using 30 validation images.

Table 1. Parameters selected for the different machine learning algorithms.

In Sorensen’s original article [1], it is mentioned the areas where the weeds are found correspond to points where excess green is found, i.e., where the green intensity is very high; therefore, a processing technique was developed for images based on this idea. To find the areas where weeds are found, the green end areas are searched for in the photographs. To do this, a monochromatic image is obtained using the standard BT.601 given in Eq. 1 because it provides the image in gray based on the human vision model. Then, this image is subtracted from the green channel one. As shown in Fig. 4b, most of the image corresponding to the crop remains in the background and areas of extreme green are detected as objects of interest. Then, the next step is to binarize the image to isolate the pixels whose extreme green values are above a given value. It was empirically found that a value of 3 resulted in the best segmentation between the background and the object. As seen in Fig. 4c, some isolated pixels are also selected as part of the object; these pixels are produced by noise in the image. To eliminate them, morphological erosion is performed, so that the final image contains only the regions of interest. The resulting image is shown in Fig. 4d. The results obtained using this method were compared to those of the techniques listed in Table 1, and the precision provided by the algorithm was calculated, comparing the pixels of the images that were segmented manually and those that were chosen via the algorithms.

Fig. 4.
figure 4

Steps of the image processing method: (a) original RGB image, (b) result of the subtraction of the green channel from the grayscale image, (c) resulting binarized image, and (d) eroded image. (Color figure online)

$$ {\text{Y}} = 0.299{\text{R}} + 0.5876{\text{G}} + 0.114{\text{B}} $$
(1)

4 Results

The results obtained for each of the analyzed algorithms are summarized below.

4.1 Parameter Estimation

Considering the selected parameters of interest and their qualitative or quantitative nature, the values shown in Table 1 were obtained, for which the analyzed learning techniques present better accuracies based on the estimation data.

4.2 Classification

Once the parameters of interest for each of the analyzed algorithms were selected, we proceeded with the training and precision calculations. The times required to perform the training classification of the selected samples are shown in Table 2.

Table 2. Execution times and accuracy of the methods.

The accuracies generated by each of the studied algorithms are summarized in Table 2, along with Figs. 5 and 6, which show the operating characteristic curve of the receiver (ROC) for each of the analyzed methods and the white color demarcation of the areas in which the presence of weeds was detected in one of the images used for validation, respectively.

Fig. 5.
figure 5

Operating characteristic curve of the receiver (ROC) for the different classifiers.

Fig. 6.
figure 6

Results obtained using the different methods: (a) original image, (b) image processing method, (c) Gaussian naive Bayes, (d) stochastic gradient descent, (e) decision trees, (f) nearest neighbors, (g) support vector machines, and (h) neural network.

5 Discussion

Table 2 show that the machine learning and image processing algorithms present similar results and comparable to the results obtained in [1], also can be observe that the execution times for algorithms Naive Bayes Gaussian, Stochastic Gradient Descent and Decision Trees are roughly equal. However, the method of image processing is computationally efficient because it does not require training and does not require a large amount of memory and computer resources. In addition, it presented the highest precision of the studied algorithms. Among the other methods, the SVM presented the highest precision, even though it requires a long analysis time. The Bayesian classifier, conversely, was the fastest algorithm and had a precision close to that of the SVM, making this case the best option for this type of method.

6 Conclusions

In this study, a new method was presented for the classification of Cirsium arvense based on image processing and was compared to other methods based on machine learning. Contrary to expectations, this new method is not only faster but also more accurate than the other methods because it does not require training and previous adjustments; therefore, a complete image can be directly processed and the classification can be performed with low execution times and computational cost. Similarly, it was confirmed that good image classification accuracy can be obtained using algorithms with a reduced level of complexity, such as the Stochastic Gradient Descent and Gaussian naive Bayes.

Therefore, the results show that, even though techniques based on machine learning are very powerful, methods based on image processing should not be forgotten and these methods can be combined with learning techniques to make the identification of patterns increasingly efficient when there are large amounts of information available and the basic principles of image theory can be used.