Next Article in Journal
Research on the Fiber-to-the-Room Network Traffic Prediction Method Based on Crested Porcupine Optimizer Optimization
Previous Article in Journal
Whole-Genome Alignment: Methods, Challenges, and Future Directions
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Weed Detection and Classification with Computer Vision Using a Limited Image Dataset

by
László Moldvai
1,
Péter Ákos Mesterházi
2,
Gergely Teschner
1 and
Anikó Nyéki
1,*
1
Department of Biosystems Engineering and Precision Technology, Albert Kázmér Mosonmagyaróvár Faculty of Agricultural and Food Sciences, Széchenyi István University, 9200 Mosonmagyarovar, Hungary
2
AXIÁL Ltd., 6500 Baja, Hungary
*
Author to whom correspondence should be addressed.
Appl. Sci. 2024, 14(11), 4839; https://doi.org/10.3390/app14114839
Submission received: 26 April 2024 / Revised: 23 May 2024 / Accepted: 31 May 2024 / Published: 3 June 2024
(This article belongs to the Section Agricultural Science and Technology)

Abstract

:
In agriculture, as precision farming increasingly employs robots to monitor crops, the use of weeding and harvesting robots is expanding the need for computer vision. Currently, most researchers and companies address these computer vision tasks with CNN-based deep learning. This technology requires large datasets of plant and weed images labeled by experts, as well as substantial computational resources. However, traditional feature-based approaches to computer vision can extract meaningful parameters and achieve comparably good classification results with only a tenth of the dataset size. This study presents these methods and seeks to determine the minimum number of training images required to achieve reliable classification. We tested the classification results with 5, 10, 20, 40, 80, and 160 images per weed type in a four-class classification system. We extracted shape features, distance transformation features, color histograms, and texture features. Each type of feature was tested individually and in various combinations to determine the best results. Using six types of classifiers, we achieved a 94.56% recall rate with 160 images per weed. Better results were obtained with more training images and a greater variety of features.

1. Introduction

In contemporary agriculture, a significant trend is emerging: a diminishing interest in working within the agricultural sector. Despite this trend, the global population continues to grow, now surpassing 8.1 billion people, all of whom require food to survive. The challenge is clear: How can we produce sufficient food with fewer people willing to work in agriculture? This situation underscores the urgent need for innovative methods and technologies to enhance agricultural productivity and ensure adequate food supply for everyone.
In the field of computer vision, two prominent methodologies are particularly noteworthy: traditional feature-based approaches and deep learning methods. The former involves extracting meaningful features from images to facilitate classification tasks. This method relies on identifying distinctive characteristics within the image, such as shapes, textures, or color patterns, which are then used to classify objects or scenes.
Conversely, deep learning methods, especially those involving neural networks, have gained significant traction in recent years. These approaches train complex neural network models using large datasets of labeled images. Through iterative learning processes, the neural network automatically extracts relevant features and makes classifications based on the input images. The cornerstone of computer vision (CV) deep learning methods is the convolutional neural network (CNN), with one of its prominent implementations being the YOLO algorithm.
A previous study [1] included both artificial plants and real plants. Portulaca weeds were targeted, while square weeds and pepper plants were not targeted. For artificial plants, an accuracy and recall of 91% were achieved, while for real plants, an accuracy and recall of 71% and 78% were achieved, respectively. The YOLO deep learning solution was chosen for classification.
In the field of agriculture, accessible datasets play a crucial role. While it is possible to generate images, progress can be accelerated by utilizing other datasets, particularly those with labeled data, to conduct tests and enable the training of artificial networks. While there are numerous databases available on the internet that contain images of dogs, cats, and human faces, finding usable datasets using images of crops, plants, leaves, fruits, vegetables, or weeds can be challenging. One such dataset, referenced in [2], focuses on five types of weeds and comprises 1200 images for each category.
Similarly, in [3], the author discussed an on-site weed management computer vision system that utilizes a public weed database sourced from Kaggle. However, this dataset contains only 1300 images in total, further compounded by the fact that it is an augmented dataset. Originally, there were only 546 images available.
Ref. [4] provides an up-to-date overview of publicly available image databases for weed detection. Among the 36 identified datasets, there were limitations regarding data variations and distributional shifts. This study concluded that few datasets are suitable for examining the robustness of weed detection models. In this study, a new, two-season, eight-class weed dataset was constructed, consisting of images collected in the 2021 and 2022 seasons. Tests were conducted on the dataset using the YOLO algorithm.
The dataset discussed in [5] contains manually captured data from both handheld cameras and unmanned aerial systems, making it suitable for both ground-based and aerial weed control robots. This dataset comprises 3975 images featuring five different weed species commonly found in North Dakota. The images were captured under various lighting conditions, including sunny, cloudy, shadowy, and low-light conditions.
Despite the impressive capabilities of deep learning algorithms in image classification tasks, there remains a significant level of opacity in understanding how these networks arrive at their decisions. Unlike traditional feature-based approaches, where the rationale behind classifications can often be traced back to specific features or rules, deep learning models operate as complex “black boxes”.
To address the challenges associated with deep learning, it is beneficial to revert to the first method, which focuses on comprehending the content of images and extracting meaningful features from them. This approach involves employing techniques such as image processing and feature extraction to identify relevant characteristics within the images. By discerning key features like shapes, textures, and color patterns, the aim is to capture the essence of the objects or scenes depicted in the images.
Once these meaningful features are extracted, some vector classifiers are trained and tested. For instance, a support vector machine (SVM) is utilized for classification purposes. SVM is a powerful supervised learning algorithm that excels at separating data points into distinct classes based on the features extracted from the input data. By leveraging the discriminative capabilities of SVM, images can be effectively classified into different categories to identify, for instance, specific weed species within agricultural landscapes. However, SVM was not the winner in our case. The random forest algorithm outperformed SVM.
In [6], the authors presented a real-time, computer vision-based plant and weed recognition system for variable-rate agricultural spraying. The recognition and classification of plants and weeds were performed using the RF classifier. The results obtained from multiple field tests demonstrated the effectiveness of the proposed vision-based variable-rate agricultural spraying framework in real time.
Ensuring that the training dataset includes a wide range of variations, such as different growth stages, lighting conditions, and perspectives, can significantly enhance the robustness and generalization ability of the classification model. The other aspect is the algorithms. For instance, Giselsson [7] conducted research on recognizing plant silhouettes based on shape characteristics. Two methods were employed: one method approximated the distribution of distance-transformed image values using Legendre polynomials and classified these data, while the other method extracted 21 shape features and classified them using four different vector classifiers. The distance transformation approach achieved better recognition than the method using 21 features in classifying two types of plants.
Another study [8] focused on recognizing three plants (canola, maize, and radish) using texture analysis. For this, local binary pattern (LBP) parameters were utilized, and classification was performed using an SVM classifier. The images were captured in a weed-free, well-lit environment on a table. This research achieved a recognition rate of 91.85%.
Ramirez-Paredes [9] investigated malting barley using image processing techniques that involved shape recognition. Initially, they considered the application of Hu moments but ultimately utilized other central moments. Color features and local binary patterns (LBPs) were also employed. A linear SVM was used for classification. The images were captured against a clean background; however, a recurring issue was that the barley grains sometimes touched each other. Achieving good results required as many as 25,000 training images, which is feasible for seeds but challenging for weeds.
In [10], weed recognition was performed using local binary patterns (LBPs) to extract local texture features. The extracted features were classified using template matching and SVM. For LBPs, template matching achieved a classification rate of 83.3%, while SVM achieved a rate of 93.8%. The study included two types of weeds, thus conducting binary classification and using a limited set of 200 images for each class.
Bhunia [11] conducted a study focusing on image classification, employing color and texture-based feature extraction. For the color space, Bhunia opted for HSV (hue, saturation, and value). Texture parameters were derived from the gray-level co-occurrence matrix (GLCM) in addition to utilizing local binary patterns (LBPs). Bhunia classified the vectors using various distance calculation methods. The system was tested using five publicly available image databases.
Hamuda [12] utilized HSV color space transformations to detect cauliflower plants. He performed erosion and dilation procedures on the images and then identified the contour, center, and bounding rectangle of the cauliflower. This method achieved a 99% accuracy rate in detecting cauliflower, even in images with minimal weed interference. The experiment was tested under various weather conditions, including sunny, partially cloudy, and completely cloudy scenarios.
The subsequent study by Zhu [13] implemented the YOLO deep learning system to distinguish between two classes: wheat and weed. This research used a relatively large dataset of 5400 images, with 80% allocated for training and 20% for testing. Both the traditional YOLO and an optimized version were employed, with the traditional YOLO achieving a recognition rate of 93.86% and the optimized YOLO reaching 94.86%.
Bakhshipour’s research [14] focused on weed detection, aiming to recognize five different plant species. The study employed contour Fourier descriptors and extracted Hu moments and other parameters from the images. The obtained vectors were classified using artificial neural networks (ANNs) and support vector machines (SVMs), with the ANN classifier achieving a recognition rate of 92.67% and the SVM classifier achieving 93.33%.
During weed detection, the histogram of oriented gradients (HOG) is also useful, although achieving over 90% accuracy on its own is typically not attainable. One study [15] created a single-layer image using the excess green (ExG) index procedure. HOG values were computed on these images, which were then transformed using a visual word technique and classified. This method succeeded in achieving around 90% accuracy, and in some cases, even approached 95%.
In a recent study [16], researchers investigated the problem of detecting partially overlapping weeds and crops. They focused on identifying the boundary between a weed and a crop within the green vegetative area. The images were divided into 64 × 64, 32 × 32, and 16 × 16-pixel cells, and three texture parameters (HOG, LBP, and GLCM) were computed for each cell. These parameters, as well as their combinations, were classified using four different methods. The classified values were then assigned to the cells and propagated between layers, with adjustments made to the classified values as needed. This approach successfully separated weeds from crops.

2. Materials and Methods

2.1. Dataset

A publicly available weed dataset was utilized for this study, accessible for non-commercial applications at https://github.com/zhangchuanyin/weed-datasets (accessed on 29 March 2024). The images were captured from a height of approximately 30 cm above the ground. Only a subset of the images from this dataset was employed in this research. To demonstrate the process, 6 plant types were selected. So, 3000 images were used altogether. Each class comprised the first 500 images from the original dataset. The CV processes were developed with Python programming language, and cv2 and skimage modules were used to handle the images.
The examples provided in Figure 1 demonstrate that the images were captured in real-world settings, as opposed to a controlled laboratory environment. Many deep learning solutions achieve impressive results with images obtained in a lab, which are typically created with a uniform white background and minimal environmental disturbances. However, images exhibit varying soil colors, are marred by cracks and straw, and often feature smaller weeds alongside the main crop. Furthermore, many images contain not just one, but two or three plants. By using these real-world images to develop classification models, we aimed to enhance their robustness.

2.2. Filtering the Images

Due to the presence of numerous distractors in the images, the initial step involved cleaning and preprocessing the images. It was essential to identify the main crop and eliminate any background clutter, as well as smaller or overlapping weeds. The pixel-level noise had to be removed first.
In [17], classification experiments were conducted with two types of weeds, measuring noise variance from no noise to 0.05 sigma noise across six steps. Their results showed that without noise, the classification accuracy was 98.4% without noise filtering and 98.29% with noise mean filtering, indicating nearly identical performance. However, even a small amount of noise, such as 0.01 sigma, reduced classification accuracy to 91.32% without noise filtering and 96.23% with noise reduction, highlighting the significant impact of noise on performance.
Furthermore, with larger noise levels, such as 0.05 sigma, classification accuracy decreased to 87.61% without filtering and increased to 92.85% with filtering, demonstrating a consistent 5% difference attributable to noise filtering. Various methods, including blur, median, and Gaussian filters, are commonly employed to address noise in images, albeit at the cost of slight image blurring.
To remove pixel-level noise from the image, first, a 5 × 5 Gaussian filter was employed. Given that the RGB color space may not be optimal for emphasizing green areas, the images were converted to the HSV color space. In the HSV image, the green areas were isolated, and all other pixels were set to black. The green color was defined by a range in HSV color space: lower_green = (30, 40, 40) and upper_green = (80, 255, 255). This process created a black-and-white mask highlighting the green regions. Figure 2b shows the mask, and it contains many other parts that are related to different plants. Subsequently, clusters of connected pixels within this mask were identified. Each cluster has a different color, as shown in Figure 2c.
From the identified clusters, the largest one was selected as the object of interest for further analysis. In this workflow, the focus was exclusively on this object. However, it was also plausible to consider the second largest object, followed by subsequent ones, for classification purposes. This approach allowed for a more comprehensive analysis, leveraging multiple objects within the image for classification tasks.
Based on the largest cluster, the region of interest was extracted from the image and stored for later use (Figure 2d). Additionally, this region was resized to a 256 × 256-pixel image. The shape parameters of the plant were analyzed on this resized image (Figure 2e,f).
After creating the mask from the image, small black spots may appear on the plant, potentially due to diseases, soil residue, or dried leaf fragments. It is possible to close these spots using erosion and dilation techniques, an important step for contour analysis.
In Figure 3, the main steps of image processing are depicted. The process began with an RGB image, which is shown in the top left corner. The Gaussian filter was applied to eliminate pixel-based noise. Subsequently, the image was transformed into the HSV color space to facilitate the extraction of the green mask, using the range previously specified. These image masks encompassed all green components, not just the primary object. The connected pixels were calculated, and an artificial coloring image was generated. The largest connected area was selected, and its color was used as a mask to isolate a single plant. In our dataset, these steps were enough to locate and extract a single plant. Occasionally, other small plants might adhere to the mask, but their proportion relative to the larger plant was minimal, causing no significant issues. With other datasets, where multiple plants may be present together, a maximum plant size parameter can be employed to determine whether the largest green mask in the image corresponds to a single plant or a group of plants. If it represents a group, the image can be discarded, or it can be subdivided into smaller parts, such as tiles, for further analysis using texture and color features. However, this constitutes a distinct task.
Following the extraction of the “one plant image mask”, the image was cropped, typically with an additional 5 pixels in every direction. This mask retained the same pixel/mm size as the original image and was utilized for distance transformation, which will be elaborated upon in subsequent sections.
Concurrently, the mask was resized to 256 × 256 pixels, and contours were computed, which is beneficial for area and Hu features.
Next, the mask was utilized to obtain the original RGB plant image, where the plant retained its original color, while the background was blackened. This image was suitable for generating RGB histogram color features. Additionally, an RGB-to-HSV color space transformation was performed, yielding HSV histogram color features.
Finally, a gray image comprising only one channel was generated, which is ideal for extracting texture features. Further details will be provided in subsequent sections.

2.3. Shape Features

The contour of the plant was determined based on the mask using the Canny edge detection algorithm, and the convex hull lines were also drawn, as can be seen in Figure 4. From the contour, parameters such as area, hull area, and solidity were derived.
To calculate the hull and hull area, the convex hull of the plant contour was measured. The convex hull is the smallest convex polygon that can enclose all points of the contour. The hull area represents the total area enclosed by this convex polygon.
Solidity is a metric that quantifies the compactness of an object’s shape relative to its convex hull. It is calculated as the ratio of the object’s area to the area of its convex hull. Solidity values range from 0 to 1, where a solidity of 1 indicates a completely solid shape without concavities, while a lower solidity value suggests the presence of concavities or indentations in the shape.

2.4. Hu Moments

Named after Ming-Kuei Hu, Hu moments consist of seven mathematical moments used to characterize the shape of an object in an image. These moments are derived from the normalized central moments of the object’s binary image. Hu moments are invariant to translation, scale, and rotation, making them invaluable for shape analysis and pattern recognition tasks in computer vision. They provide a compact representation of an object’s shape features, facilitating applications such as object classification, recognition, and shape matching.
Hu moments are particularly well suited for analyzing simple shapes due to their robustness to translation, scale, and rotation. However, they may not perform as effectively when applied to complex shapes, such as plants, which often exhibit intricate and irregular contours. In these cases, other shape descriptors or feature extraction methods that capture the detailed structure and texture of the object may be more suitable for accurate analysis and classification.

2.5. Distance Transformation

Image distance transformation, also known as distance mapping or distance transform, is a technique used in image processing to compute the distance of each pixel from the nearest contour pixel within an image. This distance is typically calculated using a defined metric, such as Euclidean or Manhattan distance.
The result of distance transformation is a new image in which each pixel value represents the distance from that pixel to the nearest contour pixel. This transformation is useful for various tasks, including object segmentation, shape analysis, and feature extraction.
One common application of image distance transformation is in morphological operations, such as skeletonization or thinning, where it is used to identify the medial axis or centerline of objects within an image.
After obtaining the distance image, local maxima within the image were identified. Each local maximum corresponded to a point where the distance to the nearest border was maximized. These local maxima served as key reference points within the image. To visualize these points, circles centered at each local maximum were drawn, with a radius equal to the value of the local maximum (as shown in Figure 5). This process effectively outlined the boundaries of the objects in the image, with each circle’s radius extending to the nearest border. By visually representing these contours, we gained valuable insights into the spatial distribution and shape characteristics of the objects present in the image.
The local maximum values were organized in ascending order. This categorization allowed us to rank the objects according to their size, with larger local maximum values typically corresponding to larger objects. By systematically analyzing and categorizing these values, we gained valuable insights into the spatial attributes within the image. This approach enabled us to effectively classify and differentiate between objects of varying sizes, providing valuable information for further analysis and interpretation of the image data.

2.6. Color Features

In the next phase, color feature vectors were extracted from the dataset. This approach allowed us to capture a comprehensive range of information from the image colors, enhancing the efficacy of weed detection and classification algorithms.
For the color-based features, color histograms were utilized. Initially, we analyzed the original RGB images, which were composed of three bands: red, green, and blue. Furthermore, we transformed the images into the HSV color space, where the three bands represented hue, saturation, and value. From these six channels, histograms comprising 32 bins each for the R, G, B, H, S, and V bands were constructed, yielding a total of 192 parameters. These histograms provided valuable insights into the distribution of colors within the images, thereby facilitating weed detection and classification efforts. The HSV channel histograms are displayed in Figure 6.

2.7. Texture Features

In addition to color-based features, the histogram of oriented gradient (HOG) features were integrated into the analysis. These features provided a detailed depiction of the gradient information inherent in the images, capturing essential texture and shape characteristics vital for weed detection. With 3780 parameters, the HOG features offered a comprehensive descriptor of the image content, thereby augmenting the accuracy and robustness of our weed classification algorithms.
Furthermore, the gray-level co-occurrence matrix (GLCM) features, which included 72 parameters, were used. GLCM features utilized in [18] were employed for classifying both plants and weeds. These features provided insights into the spatial relationships of pixel intensities within the images and valuable information about texture patterns, enhancing our understanding of the images’ structural properties.
To expand the analysis, we integrated local binary pattern (LBP) features, which are renowned for capturing micropatterns and texture variations within images. LBP features are particularly valuable for distinguishing weeds. By incorporating LBPs alongside existing features like HOG and GLCM, we aimed to improve the discriminative capability of the classification models, ultimately enhancing weed detection accuracy.
The sizes of the three types of texture feature vectors are detailed in Table 1.

2.8. Features and Feature Combinations

In the preceding sections, the foundational features extractable from an image were introduced. These features serve as the basis for classification tasks or deepening the understanding of their behavioral characteristics. With the three fundamental shape-based features at our disposal, feature combinations were constructed from these attributes. Similarly, three distinct types of texture combinations were explored, and texture-based feature combinations were assembled for testing purposes. The integration of all features was a pivotal step in the analysis. Subsequently, the least impactful texture and shape features were selectively removed to assess their individual contributions. The foundational features and their combinations are depicted in Figure 7.

2.9. Classification Methods

To determine the optimal prediction outcome, we evaluated six classifier algorithms, as outlined in Table 2. Subsequently, all the fundamental features and feature combinations mentioned earlier were trained and tested with each of the six classifiers.

3. Results

Our objective was to determine the recognition rate of the system, even when working with a limited number of sample images. For this purpose, we utilized 5, 10, 20, 40, 80, and 160 samples per plant for training, while the remaining images were used for testing, leaving 495, 490, 480, 460, 420, and 340 images, respectively, for this phase.

3.1. Area-Based Features

For the classification task, we selected only three parameters: weed area, hull area, and solidity. The six classifiers were employed to analyze the results. The outcomes of this approach are presented in Table 3. Initially, when only five training images were used, the recognition rate was 40.99%. However, even when the number of training images was increased to 160, the result improved modestly to 538.5%. This indicates challenges in achieving high accuracy with a limited dataset. In some cases when testing, there were classes with zero matches. In these cases, the average precision or average recall are presented as “nan” in the table.

3.2. Hu Features

Hu moments, which consist of seven features, were initially considered for our analysis. However, due to the complex shapes of weeds, Hu moments proved less effective, as they are better suited for simpler shapes. Consequently, the recognition rate with Hu moments remained slightly above 50%, even when the number of training images was increased to 160, as shown in Table 4.

3.3. Distance Transformation Features

Following distance transformation, we arranged the maximal distance transform values in descending order. Given that each distance-transformed image contained a variable number of maxima, it was essential to determine the appropriate number of maxima for comparison. Depending on the scenario, the analysis may require only one data point or multiple data points. In our approach, we assumed that the highest values held greater significance than the lower ones.
To assess the impact of the number of training images on classification performance, we conducted classification tests using 20 and 60 training images (as detailed in Table 5). Various combinations were explored to evaluate their effectiveness. Below are the results of the experiments.
As illustrated in Figure 8, the classification accuracy of the second column surpasses that of the first. However, the combination of the first three columns demonstrates promising results. In contrast, as shown in the fourth and fifth columns, with the addition of further combinations, the performance deteriorates. Therefore, it may be prudent to either utilize the second column alone or integrate the first three columns. It appears that the first three columns collectively offer slightly more information than the second column alone. Consequently, we proceeded with the first three largest distance maximum values for further analysis and classification tasks.
Table 6 presents the classifiers’ results using the three largest distance transformation values. Remarkably, even with only 10 images, the classification accuracy reached 61%. On the other hand, with 160 training images, the best precision result was still around 66%.

3.4. Shape Features: Area, H, and Distance Transformation Features Together

The results are presented in Table 7, which displays the combinations of the three shape features with the three distance transformation features. Even with only 10 training images, it was possible to achieve a 71% recognition rate, while using 160 training images yielded a favorable 79.48% precision result.

3.5. Color Histogram

The color histograms were constructed from the three RGB and three HSV channels, with each channel represented by a 32-bin histogram without background suppression. Consequently, the color histogram vector comprised 192 elements. Preliminary results indicate that a training set of merely five images achieved a classification accuracy of 76%, while increasing the training set to 160 images enhanced the accuracy to 92%, as detailed in Table 8. These findings are encouraging; however, it is critical to validate these results with a more extensive dataset and images captured under various weather conditions to ensure robust color classification.

3.6. HOG Features

The HOG features exhibited poor performance with only 10 training images. However, even with 160 training images, the results remained relatively weak, reaching only 64%, as depicted in Table 9.

3.7. GLCM Features

The analysis of GLCM features demonstrated that with 10 test images, a 65% accuracy was achieved, while with 160 training images, it reached 82%, as illustrated in Table 10. This outcome surpasses the results obtained with HOG features.

3.8. LBP Features

The third texture feature set comprised the LBP features, which yielded results similar to those obtained with GLCM. The maximum precision achieved with 160 training images was 78.2%, as depicted in Table 11.

3.9. Texture Features

The texture features, which comprised three different types of features (HOG, GLCM, and LBP combination), achieved a recognition rate of 80.5% with 160 training images. The results are listed in Table 12.

3.10. All Features Together

When all extracted features were combined, including color histograms, shape features, distance transformation features, and texture features, optimal close recognition results were achieved. As demonstrated in Table 13, a training set of only five images could potentially yield a 60% recognition rate. This rate increased to 82% with 20 training images and reached an impressive 93.49% with 160 training images (Table 13).

3.11. All Features Together except Hu Moments

When combining all extracted features, except for Hu moments, we observed nearly identical results. Although the RF method showed slightly weaker performance, the GBM exhibited a slight improvement, as shown in Table 14.

3.12. All Features except HOG Features

When all extracted features, excluding HOG features, were combined, the results improved significantly. Even in RF, we observed a precision result of 93.71% with 160 training images, while the GBM reached the maximum value of 94.56%. The results are presented in Table 15.

3.13. All Features except HU Moments and HOG Features Together

When all extracted features, excluding Hu moments and HOG features, were combined, the results were very similar to the previous one. As shown in Table 16, there was only a slight decrease. Here, with the GBM classifier, a maximum precision result of 94.35% was achieved.

3.14. Confusion Matrix

A confusion matrix was constructed for the best-case scenario, in which all available features except for the HOG features were utilized, and the GBM was trained with 160 images per weed or plant species. For this scenario, 340 images per species were retained for testing. The results are detailed in Figure 9.

3.15. Comparison of the Methods

To visualize and compare the results, we created a graph (Figure 10). The x-axis represents the classifier methods, while the y-axis shows the recognition rate. The color shows the number of training images used.
It is apparent that individual features alone were not enough to achieve satisfactory results; rather, a combination of multiple features was necessary. None of the base features, when used independently, met the desired performance criteria. Moreover, the quantity of training images played a critical role in enhancing classification accuracy. In this study, each weed species was represented by 500 images, of which 5–160 were allocated for training purposes. To rigorously assess the effectiveness of our method, future experiments should explore the use of different training set sizes, such as 300 or 500 images per weed. Should these smaller sets fail to maximize the potential of the method, it would indicate that more than 80–160 images are essential for optimal training. However, it is important to note that even the use of 160 training images per category is minimal compared to the extensive data requirements typical of neural network systems.

3.16. The Maximum Precisions by Training Image Number

To find the best classification method, we selected the three best precision results by training image number. Table 17, Table 18, Table 19, Table 20, Table 21 and Table 22 show the results. The bold highlighted columns show the maximum achieved precision results with training images per plant.
When training with only a few images, the RF classifier emerged as the optimal choice. However, as the number of images increased, the GBM classifier tended to yield superior results.
It appears that feature combinations offer the most promising outcomes, as opposed to using all features together. Notably, the inclusion of HOG features and Hu moments tended to degrade classification performance.
For datasets comprising fewer than 20 training images, it is advisable to utilize all features except Hu moments and HOG features with the RF classifier. Conversely, datasets with more than 40 training images may benefit from using all features except HOG features with the RF classifier.
In cases where a large number of images are available, such as 160, and optimal weed classification is desired, employing the GBM classifier is recommended. However, it is essential to note that GBM was slower than RF and only marginally improved the results.
It is encouraging to observe that even with as few as 10 training images, an 84% precision classifier can be developed. With approximately 40 training images, a precision of 91% was achieved. For datasets containing around 160 training images per plant, precision results approaching 95% were attained. In our study, the maximum precision achieved was 94.56%.

3.17. Comparison of the Six Classifiers

A comparison was performed using all features except HOG because this feature set yielded the best results. The Table 23 illustrates that both KNN and ANN yielded the poorest results, failing to achieve even a 60% classification accuracy despite the availability of 160 images per weed. SVM and NB performed slightly better, with SVM outperforming NB, yet still falling short of practical usability, with SVM achieving only 78.75% accuracy. In contrast, RF and GBM demonstrated promising results in our study. RF yielded a 75% accuracy even with just 5 images while achieving a remarkable 94% accuracy with 160 images per weed. Two algorithms (RF and GBM) proved to be effective for weed detection and classification purposes.
Figure 11 illustrates that the RF classifier performed best with a small number of images, while the GBM slightly outperformed it with a larger dataset. Conversely, the ANN model struggled to learn the data structure even with 160 images, and with fewer than 40 images, it appeared to make random guesses.

4. Discussion

In this study, we extracted more distinct types of features from plant images to comprehensively characterize their visual properties. These included shape descriptors, distance transform-based measures, color histograms, and three types of texture features. The integration of these diverse feature sets aimed to provide a holistic representation of the plants’ morphological structures, spatial distributions, color compositions, and textural patterns. This multifaceted approach facilitated a robust analysis and interpretation of the visual information encoded within the images.
We developed a dataset comprising images of six distinct types of weeds or plants, with each category represented by 500 images. To train six types of classifiers, we employed varying subsets of this dataset, consisting of 5, 10, 20, 40, 80, and 160 images from each category, with the remaining images reserved for testing purposes. By systematically adjusting the size of the training dataset, we aimed to assess the impact of varying levels of training data on the classifier’s performance. This methodology allowed us to evaluate the classifier’s robustness and generalization ability across different training scenarios, thereby providing valuable insights into the effectiveness of our classification approach.
With only 10 training images, the detection rate hovered around 83%. When we expanded our training dataset to include 20 to 40 images per weed category, we observed a substantial improvement in detection rates, reaching approximately 86–91%. This increase in training data facilitated a more comprehensive learning process for the classifier, enabling it to better discern subtle variations and nuances among different weed categories. Consequently, the classifier demonstrated enhanced performance and accuracy in distinguishing between weed species, underscoring the importance of sufficient but not too much training data in achieving robust classification outcomes.
In the final experiment, where we employed 160 images per weed category and utilized all available features, we achieved a notable detection result of 94.56%. Therefore, although the results are encouraging, further validation with larger and more diverse test datasets is essential to comprehensively assess the classifier’s robustness and reliability in real-world scenarios.
Our computer vision-based approach is comparable to those of CNN-based neural network approaches, with the added advantage of requiring only approximately 50–200 images per weed category for training. This requirement stands in stark contrast to the 1000–2000 images typically needed to train neural networks effectively. With our method, the proportion of training images relative to the total dataset was reduced to around 5% or a maximum of 10%. This significant reduction in training data requirements underscores the efficiency and practicality of our approach, offering a compelling alternative for weed detection and classification tasks, particularly in resource-constrained environments.
For example, Wei [19] conducted a thorough analysis of various datasets, but none were specifically tailored for weed detection. The closest dataset they used was Veg200, which focuses on vegetables but lacks specific plant and weed datasets. The Veg200 dataset comprises 200 vegetable classes and contains 91,117 images, making it suitable for training a CNN. However, in agricultural settings where robots need to operate efficiently, there are typically only 5–10 different types of plants requiring attention. In such scenarios, providing a robot with 10–20 samples of each weed type should suffice. Therefore, our research aimed to develop a solution for weed detection that could learn plant features from a limited number of sample images. Wei demonstrated the significance of fine-grained image analysis using deep learning. This approach emphasizes that not only the overall image but also the details can be crucial for classification. This methodology is important in the context of weed detection, as often, the differences lie in subtle details. Our approach inherently separates color, texture, and shape factors. In the future, we aim to further expand the features by observing leaf orientation, direction, vein texture, and edge patterns, thus enhancing the feature set.
In other work, Zhang [20] utilized drone or remote sensing data, which is similar to our dataset in the sense that the images were captured from above. They employed a combination of deep learning techniques for localization and classification, utilizing 70 categories with a vast range of 700–13,405 images per category. The training process took approximately 2 days.
Speed is crucial in weed control, especially after rainfall when weeds can proliferate rapidly. While there are numerous weed types, only a few species typically appear at any given time. This means that when new weeds emerge, we can capture and label some images. However, it is impractical to generate thousands of images per weed and label them manually. Additionally, the agricultural field cannot afford to wait for days to label images and train a network.
In future research endeavors, we aim to enhance detection results by incorporating additional shape-based features into the analysis. Potential methods could include Fourier descriptors, Zernike moments, or deep learning-based feature extraction approaches. These techniques offer greater flexibility and adaptability to accommodate the complex shape variations inherent in plant imagery. Additionally, we intend to explore the integration of more texture-based features to further enrich the feature representation and improve the classifier’s ability to discriminate between different weed species. By leveraging a broader range of feature descriptors, we anticipate advancing the accuracy and robustness of our weed detection and classification algorithms, ultimately facilitating more effective weed management strategies in agricultural settings.

5. Conclusions

Selecting an appropriate CV method for classification tasks significantly depends on the size and availability of the labeled image dataset. If there is an abundance of labeled images, it is recommended to use approximately 2–3 thousand or more per weed category, utilizing CNN-based neural network models. However, if the available dataset contains fewer than a hundred images per category, it is pragmatic to initially employ traditional feature-based computer vision methods.
When constructing the dataset, particularly if images are collected via automated methods such as robots or drones, one can amass thousands of images. These images, however, require extensive labeling and segmentation from the background, demanding significant plant expert hours. In such scenarios, we propose the use of traditional computer vision techniques to initially extract individual plants and weeds. This process should be followed by involving a plant expert to select approximately 40 representative samples for each class.
At this juncture, the methodologies described in this study can be applied to classify an additional 100 images per weed category. The experts only need to verify and correct the misclassified images, typically around 15% of the dataset. Following this correction process, the classification scripts can be re-run, this time utilizing several thousands of images, achieving classification accuracies of approximately 95–96%. Consequently, each class directory will predominantly contain high-quality images, with about 4–5% that are inaccurately classified. These erroneous images can be swiftly identified and corrected by a plant expert, thereby ensuring a high-quality and sizable dataset suitable for training both SVM- and CNN-based classification networks.

Author Contributions

L.M.: writing—original draft preparation; P.Á.M.: writing—review and editing; G.T.: writing—review and editing; A.N.: writing—supervision. All authors have read and agreed to the published version of the manuscript.

Funding

The APC was funded by Széchenyi István University.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Data is contained within the article.

Acknowledgments

This research was carried out by Precision Bioengineering Research Group, supported by Széchenyi István University Foundation.

Conflicts of Interest

Author Péter Ákos Mesterházi was employed by the company Leader of precision agriculture team, Axiál Ltd. The remaining authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

References

  1. Partel, V.; Charan Kakarla, S.; Ampatzidis, Y. Development and Evaluation of a Low-Cost and Smart Technology for Precision Weed Management Utilizing Artificial Intelligence. Comput. Electron. Agric. 2019, 157, 339–350. [Google Scholar] [CrossRef]
  2. Hasan, A.S.M.M.; Diepeveen, D.; Laga, H.; Jones, M.G.K.; Sohel, F. Object-Level Benchmark for Deep Learning-Based Detection and Classification of Weed Species. Crop Prot. 2024, 177, 106561. [Google Scholar] [CrossRef]
  3. Dandekar, Y.; Shinde, K.; Gangan, J.; Firdausi, S.; Bharne, S. Weed Plant Detection from Agricultural Field Images Using YOLOv3 Algorithm. In Proceedings of the 2022 6th International Conference On Computing, Communication, Control and Automation ICCUBEA, Pune, India, 26–27 August 2022; pp. 1–4. [Google Scholar] [CrossRef]
  4. Deng, B.; Lu, Y.; Xu, J. Weed Database Development: An Updated Survey of Public Weed Datasets and Cross-Season Weed Detection Adaptation. Ecol. Inform. 2024, 81, 102546. [Google Scholar] [CrossRef]
  5. Rai, N.; Mahecha, M.V.; Christensen, A.; Quanbeck, J.; Zhang, Y.; Howatt, K.; Ostlie, M.; Sun, X. Multi-Format Open-Source Weed Image Dataset for Real-Time Weed Identification in Precision Agriculture. Data Brief 2023, 51, 109691. [Google Scholar] [CrossRef] [PubMed]
  6. Alam, M.; Alam, M.S.; Roman, M.; Tufail, M.; Khan, M.U.; Khan, M.T. Real-Time Machine-Learning Based Crop/Weed Detection and Classification for Variable-Rate Spraying in Precision Agriculture. In Proceedings of the 2020 7th International Conference on Electrical and Electronics Engineering (ICEEE), Antalya, Turkey, 14–16 April 2020; pp. 273–280. [Google Scholar] [CrossRef]
  7. Giselsson, T.; Midtiby, H.; Jørgensen, R. Seedling Discrimination with Shape Features Derived from a Distance Transform. Sensors 2013, 13, 5585–5602. [Google Scholar] [CrossRef] [PubMed]
  8. Nguyen Thanh Le, V.; Apopei, B.; Alameh, K. Effective Plant Discrimination Based on the Combination of Local Binary Pattern Operators and Multiclass Support Vector Machine Methods. Inf. Process. Agric. 2019, 6, 116–131. [Google Scholar] [CrossRef]
  9. Ramirez-Paredes, J.-P.; Hernandez-Belmonte, U.-H. Visual Quality Assessment of Malting Barley Using Color, Shape and Texture Descriptors. Comput. Electron. Agric. 2020, 168, 105110. [Google Scholar] [CrossRef]
  10. Ahmed, F.; Kabir, H.; Bhuyan, S.; Bari, H.; Hossain, E. Automated Weed Classification with Local Pattern-Based Texture Descriptors. Int. Arab J. Inf. Technol. 2014, 11, 87–94. [Google Scholar]
  11. Bhunia, A.K.; Bhattacharyya, A.; Banerjee, P.; Roy, P.P.; Murala, S. A Novel Feature Descriptor for Image Retrieval by Combining Modified Color Histogram and Diagonally Symmetric Co-Occurrence Texture Pattern. Pattern Anal. Appl. 2020, 23, 703–723. [Google Scholar] [CrossRef]
  12. Hamuda, E.; Mc Ginley, B.; Glavin, M.; Jones, E. Automatic Crop Detection under Field Conditions Using the HSV Colour Space and Morphological Operations. Comput. Electron. Agric. 2017, 133, 97–107. [Google Scholar] [CrossRef]
  13. Zhu, H.; Zhang, Y.; Mu, D.; Bai, L.; Wu, X.; Zhuang, H.; Li, H. Research on Improved YOLOx Weed Detection Based on Lightweight Attention Module. Crop Prot. 2024, 177, 106563. [Google Scholar] [CrossRef]
  14. Bakhshipour, A.; Jafari, A. Evaluation of Support Vector Machine and Artificial Neural Networks in Weed Detection Using Shape Features. Comput. Electron. Agric. 2018, 145, 153–160. [Google Scholar] [CrossRef]
  15. Abouzahir, S.; Sadik, M.; Sabir, E. Bag-of-Visual-Words-Augmented Histogram of Oriented Gradients for Efficient Weed Detection. Biosyst. Eng. 2021, 202, 179–194. [Google Scholar] [CrossRef]
  16. Zhang, L.; Zhang, Z.; Wu, C.; Sun, L. Segmentation Algorithm for Overlap Recognition of Seedling Lettuce and Weeds Based on SVM and Image Blocking. Comput. Electron. Agric. 2022, 201, 107284. [Google Scholar] [CrossRef]
  17. Ahmad, J.; Muhammad, K.; Ahmad, I.; Ahmad, W.; Smith, M.L.; Smith, L.N.; Jain, D.K.; Wang, H.; Mehmood, I. Visual Features Based Boosted Classification of Weeds for Real-Time Selective Herbicide Sprayer Systems. Comput. Ind. 2018, 98, 23–33. [Google Scholar] [CrossRef]
  18. Sunil, G.C.; Zhang, Y.; Koparan, C.; Ahmed, M.R.; Howatt, K.; Sun, X. Weed and Crop Species Classification Using Computer Vision and Deep Learning Technologies in Greenhouse Conditions. J. Agric. Food Res. 2022, 9, 100325. [Google Scholar] [CrossRef]
  19. Wei, X.-S.; Song, Y.-Z.; Mac Aodha, O.; Wu, J.; Peng, Y.; Tang, J.; Yang, J.; Belongie, S. Fine-Grained Image Analysis with Deep Learning: A Survey. IEEE Trans. Pattern Anal. Mach. Intell. 2021, 44, 8927–8948. [Google Scholar] [CrossRef]
  20. Zhang, C.; Liu, T.; Xiao, J.; Lam, K.-M.; Wang, Q. Boosting Object Detectors via Strong-Classification Weak-Localization Pretraining in Remote Sensing Imagery. IEEE Trans. Instrum. Meas. 2023, 72, 1–20. [Google Scholar] [CrossRef]
Figure 1. The 6 classes: (a) bluegrass sample; (b) white goosefoot sample; (c) lettuce sample; (d) sedge sample; (e) corn sample; (f) Cirsium setosum sample.
Figure 1. The 6 classes: (a) bluegrass sample; (b) white goosefoot sample; (c) lettuce sample; (d) sedge sample; (e) corn sample; (f) Cirsium setosum sample.
Applsci 14 04839 g001aApplsci 14 04839 g001b
Figure 2. The image processing steps: (a) original image; (b) green mask; (c) artificial coloring of the regions; (d) the largest green object mask; (e) the mask was cut and resized to 256 × 256 pixels; (f) the 256 × 256-pixel mask was used on the image to have the largest plant image.
Figure 2. The image processing steps: (a) original image; (b) green mask; (c) artificial coloring of the regions; (d) the largest green object mask; (e) the mask was cut and resized to 256 × 256 pixels; (f) the 256 × 256-pixel mask was used on the image to have the largest plant image.
Applsci 14 04839 g002aApplsci 14 04839 g002b
Figure 3. The main steps of image processing: from RGB images to features.
Figure 3. The main steps of image processing: from RGB images to features.
Applsci 14 04839 g003
Figure 4. The weed contour: (a) mask contour; (b) convex hull area.
Figure 4. The weed contour: (a) mask contour; (b) convex hull area.
Applsci 14 04839 g004
Figure 5. The distance transformation method: (a) the weed distance transformation map; (b) the local maximums and the values as radius.
Figure 5. The distance transformation method: (a) the weed distance transformation map; (b) the local maximums and the values as radius.
Applsci 14 04839 g005
Figure 6. The HSV color space histograms.
Figure 6. The HSV color space histograms.
Applsci 14 04839 g006
Figure 7. Image features and feature combinations.
Figure 7. Image features and feature combinations.
Applsci 14 04839 g007
Figure 8. Visualization of the optimum distance transformation features. The first, second, and third features together show the optimum.
Figure 8. Visualization of the optimum distance transformation features. The first, second, and third features together show the optimum.
Applsci 14 04839 g008
Figure 9. Confusion matrix (green: correct recognition; red: incorrect recognition).
Figure 9. Confusion matrix (green: correct recognition; red: incorrect recognition).
Applsci 14 04839 g009
Figure 10. Comparison of the classification methods.
Figure 10. Comparison of the classification methods.
Applsci 14 04839 g010
Figure 11. The precision results using all features except HOG features by training image number and classifier method.
Figure 11. The precision results using all features except HOG features by training image number and classifier method.
Applsci 14 04839 g011
Table 1. Texture feature types and the features’ vector size.
Table 1. Texture feature types and the features’ vector size.
Texture Feature TypesVector Size
GLCM features72
HOG features3780
LPB features26
Table 2. The 6 classifier abbreviations and names.
Table 2. The 6 classifier abbreviations and names.
AbbreviationMethod Name
SVMSupport Vector Machine
RFRandom Forest
KNNk-Nearest Neighbors
ANNArtificial Neural Network
NBNaïve Bayes
GBMGradient Boosting Machine
Table 3. Area-based features’ results.
Table 3. Area-based features’ results.
Training Image Number 510204080160
Test Image Number 495490480460420340
SVMprecision32.8037.0834.5741.8241.8743.06
recall28.2534.3935.2440.8740.6342.50
RFprecision40.9943.3346.7249.5051.6352.50
recall38.9242.1846.1148.3750.2851.13
KNNprecision33.6639.0641.4748.2247.2246.19
recall30.6738.4040.9045.2245.4445.25
ANNprecisionnan28.04nan40.0039.7439.88
recall16.8421.8421.4634.0637.5036.37
NBprecision37.00nannannannannan
recall36.8438.1642.4342.2143.5744.41
GBMprecision38.2345.3043.2348.3550.5453.85
recall37.1043.4442.4047.0748.9751.91
Table 4. Hu moment results.
Table 4. Hu moment results.
Training Image Number 510204080160
Test Image Number 495490480460420340
SVMprecision40.6841.0338.76nannan48.02
recall25.4224.4633.5434.0937.5041.47
RFprecision31.7641.3840.2944.9748.4950.92
recall29.2338.4739.2744.0648.1049.75
KNNprecisionnan35.9340.5842.0043.1247.68
recall26.0332.3136.4240.9142.5446.47
ANNprecision40.1446.8642.13nan51.1752.94
recall34.5540.6139.3141.8147.2248.68
NBprecision39.1843.8842.4544.2039.4642.46
recall35.5637.5535.6937.8636.6733.14
GBMprecision29.6736.5738.3343.0246.6149.99
recall27.4134.4936.9841.8145.8748.63
Table 5. Some distance transformation parameter combinations to find the optimum features with 20 and 60 training images (1 is the largest value, 2 is the second largest, and so on).
Table 5. Some distance transformation parameter combinations to find the optimum features with 20 and 60 training images (1 is the largest value, 2 is the second largest, and so on).
Columns11, 21, 2, 31, 2, 3, 41, 2, 3, 4, 522, 31
20 training images71.25%77.19%77.5%73.44%72.81%76.88%77.19%71.25%
60 training images70%75.63%75.63%75.63%73.75%79.38%74.38%70%
Table 6. The distance transformation features’ results.
Table 6. The distance transformation features’ results.
Training Image Number 510204080160
Test Image Number 495490480460420340
SVMprecision53.6955.8955.6057.2759.1859.51
recall52.2955.3455.8358.1560.2060.69
RFprecision60.6561.0857.6960.5562.4563.57
recall60.0059.4957.2960.8062.5863.97
KNNprecision54.8956.8558.4560.7064.8665.69
recall57.1056.7758.6861.2064.2565.44
ANNprecision50.3558.43nan58.8863.7966.08
recall48.9255.8222.5357.5063.8165.88
NBprecision57.9561.6561.5462.6163.7063.06
recall56.7760.3461.2563.2664.2163.58
GBMprecision55.6760.2857.9860.5661.1063.38
recall53.0656.8456.6360.1460.9563.38
Table 7. The shape features: the results of area, Hu, and distance transformation features’ combination.
Table 7. The shape features: the results of area, Hu, and distance transformation features’ combination.
Training Image Number 510204080160
Test Image Number 495490480460420340
SVMprecision48.0059.9766.2769.0571.5570.07
recall43.1654.5963.4067.7270.9569.17
RFprecision64.4271.4172.6974.7976.5278.68
recall63.7470.8272.6474.7876.5978.53
KNNprecision33.5648.7851.9156.0458.2960.41
recall31.5547.9352.4055.5858.2959.71
ANNprecisionnannannannan47.2748.63
recall19.4930.3419.1330.6239.0544.75
NBprecision65.7870.2270.4172.6170.0971.48
recall62.5367.8268.0671.1662.6264.41
GBMprecision66.6467.5670.9272.3275.7479.44
recall65.0863.8469.3871.7875.7179.31
Table 8. The color histogram features’ results.
Table 8. The color histogram features’ results.
Training Image Number 510204080160
Test Image Number 495490480460420340
SVMprecision52.7869.9773.4473.2577.6881.24
recall47.3760.9565.1472.3977.3480.93
RFprecision76.1982.1684.2487.5289.7691.18
recall76.5380.8883.9287.4389.6091.03
KNNprecision50.5861.1970.9177.7981.5284.73
recall47.2158.1068.3776.5681.0383.92
ANNprecision65.4772.1079.3385.1287.8291.06
recall65.4271.2279.1385.0487.7490.98
NBprecision58.0672.5769.4275.8777.6875.97
recall52.3671.7769.9775.3676.1172.55
GBMprecision57.1572.0478.1186.3289.6892.13
recall57.1470.5176.8885.9489.3391.96
Table 9. HOG features’ results.
Table 9. HOG features’ results.
Training Image Number 510204080160
Test Image Number 495490480460420340
SVMprecision42.0545.4648.7352.6055.4260.42
recall40.2744.6947.3651.9954.6860.15
RFprecision41.2546.2350.7856.1259.2464.13
recall40.1045.5150.4556.2058.9364.17
KNNprecision38.0141.2944.6449.0651.9356.14
recall35.8238.2040.8345.1148.2951.47
ANNprecision33.2836.7640.3543.8547.2557.98
recall33.9136.1640.0744.3847.4658.09
NBprecisionnan32.3334.4737.2243.0549.71
recall17.3419.0527.3635.6944.5649.85
GBMprecision28.4731.6541.4150.8053.6662.54
recall28.6931.4641.1848.8052.1461.76
Table 10. GLCM features’ results.
Table 10. GLCM features’ results.
Training Image Number 510204080160
Test Image Number 495490480460420340
SVMprecision36.4840.3158.2769.6277.3782.06
recall33.6040.0757.7169.2876.5581.62
RFprecision54.7265.4166.5372.7175.9577.56
recall55.2261.6063.8272.2175.2877.35
KNNprecision24.6234.6037.4338.3740.5944.83
recall25.9932.4134.5537.3640.2444.17
ANNprecision17.1542.3644.6535.7949.3454.05
recall15.4542.3529.9037.1747.3848.33
NBprecision54.7761.6762.0958.6459.6959.21
recall54.7558.6458.9658.7359.2958.87
GBMprecision50.2860.2867.5673.3476.1778.62
recall50.9158.6765.7672.7975.5678.43
Table 11. LBP features’ results.
Table 11. LBP features’ results.
Training Image Number 510204080160
Test Image Number 495490480460420340
SVMprecision51.11nan44.8145.6143.1346.92
recall51.1146.4347.0144.2444.5647.21
RFprecision60.1263.8068.8571.0476.3278.20
recall56.5061.3668.5170.5475.9977.94
KNNprecision47.1750.1151.0556.9059.9364.53
recall47.8550.1051.0157.3660.1264.51
ANNprecision52.6558.0456.0157.7461.7270.20
recall51.5557.6556.4656.3461.4770.15
NBprecision53.7158.4155.0655.4855.5156.43
recall50.2456.9055.1454.6454.1754.80
GBMprecision56.6861.6464.2469.1274.4777.74
recall54.9259.8362.8168.4874.1377.45
Table 12. The 3 texture features: HOG, GLCM, and LBP combination results.
Table 12. The 3 texture features: HOG, GLCM, and LBP combination results.
Training Image Number 510204080160
Test Image Number 495490480460420340
SVMprecision36.8442.8861.7069.3074.3279.43
recall34.3442.3160.6668.7073.7779.17
RFprecision52.3260.6064.2868.7471.6574.32
recall51.3861.0563.5868.1970.8773.97
KNNprecision24.6234.6337.4338.3740.5544.94
recall25.9932.4534.5537.3640.2044.31
ANNprecision41.1445.2150.7159.9266.5974.79
recall41.5844.9050.6360.0066.9074.61
NBprecision33.0234.7334.9342.6747.9456.01
recall18.2223.7134.2042.6148.6954.90
GBMprecision38.7443.2260.3173.3576.2980.50
recall39.1240.0359.4872.2875.8380.29
Table 13. The results of color histogram, shape, and texture features’ combination.
Table 13. The results of color histogram, shape, and texture features’ combination.
Training Image Number 510204080160
Test Image Number 495490480460420340
SVMprecision41.8357.7867.8673.2174.3379.89
recall41.2854.7666.2271.8173.0279.26
RFprecision60.0273.7082.7686.5389.9392.08
recall59.0273.2382.6486.3089.8092.01
KNNprecision33.6344.3846.4052.0254.3758.60
recall36.2643.0643.2650.4353.5357.79
ANNprecision51.44nan27.4346.5762.6968.59
recall46.9015.8525.1739.0957.9065.78
NBprecision60.2063.7366.9067.1267.7569.68
recall58.8262.0465.4265.5864.0565.10
GBMprecision39.9564.6373.5489.4091.6693.49
recall39.7064.4271.7789.2891.5193.38
Table 14. The results of combining all features except Hu moments.
Table 14. The results of combining all features except Hu moments.
Training Image Number 510204080160
Test Image Number 495490480460420340
SVMprecision41.8357.7867.8073.0474.0079.48
recall41.2854.7666.0871.5672.8278.82
RFprecision66.2775.9282.5787.2689.7291.71
recall64.5875.7882.1587.0789.6091.67
KNNprecision33.6344.3846.4052.0254.3758.60
recall36.2643.0643.2650.4353.5357.79
ANNprecision45.1548.2035.8461.6457.4757.29
recall39.8745.9924.4158.4451.6352.50
NBprecision59.2462.9165.4065.8967.0569.22
recall58.3261.5664.7264.9365.0465.59
GBMprecision40.4762.2773.7389.0891.8893.51
recall40.1762.0471.9188.9191.7193.38
Table 15. The results of combining all features except HOG features.
Table 15. The results of combining all features except HOG features.
Training Image Number 510204080160
Test Image Number 495490480460420340
SVMprecision41.8659.2166.5470.9174.2678.75
recall41.3156.0964.5169.8972.9877.84
RFprecision75.4383.0486.1691.2092.8593.71
recall75.2982.1886.1891.1692.8293.68
KNNprecision33.6344.3846.4052.0254.3758.60
recall36.2643.0643.2650.4353.5357.79
ANNprecision39.09nan20.0844.3643.9350.08
recall25.5223.9113.7243.9141.9853.73
NBprecision59.8861.0462.6563.3462.8263.26
recall57.6157.9659.5862.5760.7161.37
GBMprecision66.2274.0383.0090.4692.8194.56
recall39.7064.4271.7789.2891.5193.38
Table 16. The results of combining all features except HU moments and HOG features.
Table 16. The results of combining all features except HU moments and HOG features.
Training Image Number 510204080160
Test Image Number 495490480460420340
SVMprecision41.8659.2166.5671.6673.9678.99
recall41.3156.0964.6270.6272.9077.94
RFprecision76.8684.3386.5390.4592.7293.77
recall76.4683.9886.5390.4392.7093.73
KNNprecision33.6344.3846.4052.0254.3758.60
recall36.2643.0643.2650.4353.5357.79
ANNprecision35.0847.7922.8656.7948.5365.19
recall28.8644.5223.1649.6744.7659.41
NBprecision58.3259.6061.1461.7363.2463.22
recall56.5757.3559.7962.2563.6963.68
GBMprecision66.5774.5881.9990.3092.7594.35
recall67.0072.9981.2890.0492.6294.26
Table 17. The three best results with five training images.
Table 17. The three best results with five training images.
FeaturesClassifier510204080160
ColorRF76.1982.1684.2487.5289.7691.18
All exp. Hu, HOGRF76.8684.3386.5390.4592.7293.77
All exp. HOGRF75.4383.0486.1691.2092.8593.71
The bold column is the best precision values.
Table 18. The 3 best results with 10 training images.
Table 18. The 3 best results with 10 training images.
FeaturesClassifier510204080160
ColorRF76.1982.1684.2487.5289.7691.18
All exp. Hu, HOGRF76.8684.3386.5390.4592.7293.77
All exp. HOGRF75.4383.0486.1691.2092.8593.71
The bold column is the best precision values.
Table 19. The 3 best results with 20 training images.
Table 19. The 3 best results with 20 training images.
FeaturesClassifier510204080160
ColorRF76.1982.1684.2487.5289.7691.18
All exp. Hu, HOGRF76.8684.3386.5390.4592.7293.77
All exp. HOGRF75.4383.0486.1691.2092.8593.71
The bold column is the best precision values.
Table 20. The 3 best results with 40 training images.
Table 20. The 3 best results with 40 training images.
FeaturesClassifier510204080160
All exp. Hu, HOGRF76.8684.3386.5390.4592.7293.77
All exp. HOGRF75.4383.0486.1691.2092.8593.71
All exp. HOGGBM66.2274.0383.0090.4692.8194.56
The bold column is the best precision values.
Table 21. The 3 best results with 80 training images.
Table 21. The 3 best results with 80 training images.
FeaturesClassifier510204080160
All exp. Hu, HOGGBM66.5774.5881.9990.3092.7594.35
All exp. HOGRF75.4383.0486.1691.2092.8593.71
All exp. HOGRF66.2274.0383.0090.4692.8194.56
The bold column is the best precision values.
Table 22. The 3 best results with 160 training images.
Table 22. The 3 best results with 160 training images.
FeaturesClassifier510204080160
All exp. Hu, HOGRF76.8684.3386.5390.4592.7293.77
All exp. Hu, HOGGBM66.5774.5881.9990.3092.7594.35
All exp. HOGGBM66.2274.0383.0090.4692.8194.56
The bold column is the best precision values.
Table 23. The comparison of the 6 classifiers’ results.
Table 23. The comparison of the 6 classifiers’ results.
FeaturesClassifier510204080160
All exp. HOGSVM41.8659.2166.5470.9174.2678.75
All exp. HOGRF75.4383.0486.1691.2092.8593.71
All exp. HOGKNN33.6344.3846.4052.0254.3758.60
All exp. HOGANN39.09nan20.0844.3643.9350.08
All exp. HOGNB59.8861.0462.6563.3462.8263.26
All exp. HOGGBM66.2274.0383.0090.4692.8194.56
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Moldvai, L.; Mesterházi, P.Á.; Teschner, G.; Nyéki, A. Weed Detection and Classification with Computer Vision Using a Limited Image Dataset. Appl. Sci. 2024, 14, 4839. https://doi.org/10.3390/app14114839

AMA Style

Moldvai L, Mesterházi PÁ, Teschner G, Nyéki A. Weed Detection and Classification with Computer Vision Using a Limited Image Dataset. Applied Sciences. 2024; 14(11):4839. https://doi.org/10.3390/app14114839

Chicago/Turabian Style

Moldvai, László, Péter Ákos Mesterházi, Gergely Teschner, and Anikó Nyéki. 2024. "Weed Detection and Classification with Computer Vision Using a Limited Image Dataset" Applied Sciences 14, no. 11: 4839. https://doi.org/10.3390/app14114839

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop