1. Introduction
Moringa (
M. oleifera) is a valuable plant widely recognized for its rich nutritional content and diverse health benefits [
1]. The highest quality dried
Moringa leaves in
Class A are commonly processed into fine powder and are used in medicine, known for their
antioxidant [
2],
antidiabetic [
3], and
anti-inflammatory [
4]. In contrast, lower-quality
dried Moringa leaves in
Classes B, C, D, and E are typically used for producing herbal tea, animal feed, and organic fertilizer, depending on the purity and leaf condition.
In recent years, exports of dried
Moringa leaves from Indonesia have increased notably [
5]. This growth is mainly driven by global demands and wider applications in the
cosmetic [
6,
7] and
wellness industries [
8,
9]. According to
PT. Bali Agro Investama, a leading industrial producer of dried
Moringa leaves in Bali, Indonesia, the existing quality classification system has been refined to better suit product-specific applications. The previous top grade, labeled
Class A, has now been divided into two groups:
Class A, which is used for pharmaceutical and medicinal purposes, and
Class B, which is mainly intended for cosmetic formulations. The remaining grades,
Class C, D, E, and F, are used for food, tea blends, animal feed, and other commercial products. This class refinement helps improve the product traceability and consistency but also increases the complexity of the classification process.
Currently, the classification of dried
Moringa leaves is carried out manually, relying on human visual inspections to evaluate color and textures [
10,
11]. This manual process is labor-intensive, time-consuming, and prone to subjective errors, especially in distinguishing high-quality leaves between
Class A and
Class B. They often have nearly identical visual features. Therefore, an automated and objective classification approach is needed to support large-scale productions of dried
Moringa leaves while maintaining consistent quality standards.
Previously, several attempts have been conducted to classify the quality of dried
Moringa leaves. They rely solely on the
colour feature of them using
machine learning methods [
12,
13], previous studies relied on a single type of feature—color—so the machine learning models were trained to distinguish leaves only based on color differences. However, several classes have very similar color characteristics (such as Class A and Class B), making this approach less effective for fine-grained quality classification. Unfortunately, the results show that using only color is insufficient to clearly separate leaves between the two high-quality classes. The methods often misclassified good-quality leaves as lower-quality ones, because color alone could not represent the subtle variations in texture and surface uniformity that distinguish quality levels. We have also studied the quality classification of dried
Moringa leaves using color features [
14]. It also lacked reliability in distinguishing leaves between
Class A and
Class B.
In this paper, to address this limitation, we present an improved classification method using multiple image features and a structured two-stage classification framework. This study contributes the following three aspects.
Previous studies have attempted to classify dried Moringa leaves using machine learning techniques; however, most approaches relied primarily on color information. These color-based methods demonstrated limited ability to distinguish high-quality leaves, particularly between Class A and Class B, which often share highly similar visual characteristics. As a result, misclassification frequently occurred when subtle variations in texture or surface uniformity were present. Our earlier work, which also adopted color features, showed similar limitations and indicated the need for a more comprehensive feature representation [
15,
16].
To address these challenges, the present study aims to develop a more robust and reliable image-based classification framework for dried Moringa leaves. The proposed approach emphasizes integrating richer visual information, including color and texture characteristics, and restructuring the classification process to better manage the subtle similarities in premium-grade leaves. By leveraging these enhancements, the study seeks to overcome the limitations reported in prior work and to provide a more accurate foundation for automated quality assessment.
This work offers three main contributions. First, it introduces a new high-resolution image dataset that captures detailed visual properties of dried Moringa leaves. Second, it proposes a refined classification framework designed to improve the separation of closely related quality classes. Finally, we conducted a comprehensive comparison of several machine learning models to identify an effective classifier for the assessment of dried Moringa leaf quality.
Our experimental results show that LightGBM achieved the best performance, reaching an overall accuracy of 91% with efficient processing time. This demonstrates that the proposed two-stage approach successfully improves classification accuracy compared with 82% by the one-stage approach, while maintaining high computational efficiency. The combination of high-resolution data, comprehensive feature extraction, and a hierarchical classification design establishes a reliable framework for large-scale and real-time quality assessment of dried Moringa leaves.
The remainder of this paper is organized as follows.
Section 2 reviews previous studies on image-based quality assessment, feature extraction, and machine learning classification methods.
Section 3 explains the dataset of dried
Moringa leaves, including the image collection process, preprocessing, and feature extraction procedures.
Section 5 describes eight machine learning-based classification algorithms used in this study.
Section 4 presents the two-stage classification approach.
Section 6 shows experimental results for performance evaluations.
Section 7 discusses findings and implications of this study. Finally,
Section 8 concludes this paper with future work.
3. Image Dataset of Dried Moringa Leaves
In this section, we introduce dried Moringa leaves and discuss their image dataset used in this study.
3.1. Moringa Leaf
Moringa (M. oleifera) is a fast-growing tropical tree native to India, and is now cultivated worldwide. Its leaves are widely used as food and in traditional medicine due to their high nutritional content. Dried Moringa leaves contain approximately 25–30% plant protein, along with essential vitamins (A, C, E, and B complex) and minerals such as calcium, potassium, magnesium, and iron.
Figure 1 shows samples of dried
Moringa leaves. During the drying process,
Moringa leaves undergo a significant reduction in weight due to the loss of moisture. Fresh leaves contain about 75–80% water, which decreases drastically upon drying, leading to a noticeable shrinkage in mass.
Dried
Moringa leaves also contain bioactive compounds including
flavonoids,
polyphenols, and
saponins. They act as
antioxidants and exhibit
anti-inflammatory properties. Typically, dried
Moringa leaves are ground into powder and are used in medicines, cosmetics, and dietary supplements. Scientific studies have shown that
Moringa leaf proteins can reduce blood glucose levels in diabetic mice and provide strong antioxidant activity [
29]. Other reviews have reported that its bioactive compounds contribute to the prevention of chronic diseases and inflammation [
30].
3.2. Overview of Dataset Creation
The dataset creation process of dried
Moringa leaves images consisted of two stages for
data collection and
preprocessing. They were designed to ensure the consistent image quality and to extract meaningful features for
machine learning-based classification.
Figure 2 illustrates the overall workflow for creating the dried
Moringa leaves image dataset.
In the data collection stage, high-resolution images of dried Moringa leaves were captured, representing all of the six quality classes (A, B, C, D, E, F) with a total of 600 images, 100 images for each class. The image normalization was performed using histogram equalization to balance brightness and contrast among them, followed by the background removal to isolate the leaf objects.
In the preprocessing stage, two main features were extracted from each image. First, color features were computed using the average RGB values, grayscale histograms, and RGB histograms. Second, texture features were extracted using the Gray-Level Co-occurrence Matrix (GLCM), which calculated four key statistical properties: Contrast (pixel intensity variation), Correlation (pixel linearity), Energy (texture uniformity), and Homogeneity (gray-level smoothness).
All of the extracted features were compiled into a CSV dataset along with the manually assigned class labels for the 600 images. These structured data were then used as the input to the eight machine learning algorithms to identify the most accurate and efficient model for Moringa leaves quality classification.
3.3. Data Collection Stage
In this stage, first, dried Moringa leaves images are collected from the six classes, ensuring consistent lighting and camera angles for each. Next, brightness is normalized using the histogram equalization method to maintain uniform lighting throughout the dataset. Finally, backgrounds are removed, resulting in a set of moringa images suitable for extracting color, texture, and high-resolution features.
3.3.1. Image Data Collection
The dataset images were captured under standardized conditions to ensure uniformity and high visual quality.
Figure 3 shows the image acquisition setup. Each image was taken against a white background using a fixed camera with the distance of 1 m and the consistent illumination provided by a 400 watt studio lamp positioned
m away. The camera was mounted on a tripod to maintain a stable angle and perspective. All images were saved in JPEG format.
To achieve consistent lighting, focus, and color accuracy across all samples, the camera parameters were standardized as shown in
Table 1. These parameters ensured that the visual characteristics of the dried
Moringa leaves were captured clearly and comparably in all images.
Table 1 details the specific settings used during image acquisition.
Using the abovementioned setting, a total of 600 dried Moringa leaves images were collected, 100 images per class. These settings ensured consistent brightness, sharpness, and color representation, reducing variations caused by lighting or camera configuration. The controlled conditions have improved dataset reliability for machine learning-based classification.
3.3.2. Labeling Moringa Image
Next, experts from
PT. Bali Agro Investama labeled the collected dried
Moringa leaves images with six quality classes: A, B, C, D, E, and F. This classification was based on visual features such as color uniformity, stem content, texture, and overall leaf condition.
Figure 4 illustrates example images from each class after preprocessing.
Table 2 summarizes the class labels and their descriptions. The six labels define the visual quality levels used for dataset annotation.
3.3.3. Brightness Normalization Using CLAHE
To ensure the uniform brightness across all
Moringa leaves images before feature extractions, we applied the
Contrast Limited Adaptive Histogram Equalization (CLAHE) method [
31,
32,
33]. This method enhances local contrast while minimizing noise amplification. The brightness normalization process is expressed using the
cumulative distribution function (CDF) shown in Equation (
1).
Here represents the pixel intensity after normalization at coordinates , whereas denotes the original pixel intensity. The parameters and correspond to the minimum and maximum intensity values, respectively, which are typically set to 0 and 255 for 8-bit images.
The
CLAHE method divides the image into small contextual regions called tiles, applies the local histogram equalization to each tile, and limits contrast to prevent over-amplification of noise. This approach produces a balanced intensity distribution and enhances the feature visibility.
Figure 5 illustrates the
CLAHE-based brightness normalization process. After the application, the normalized images achieved consistent brightness and stable feature contrast across all classes, improving the quality of input data for
machine learning-based classifications.
3.3.4. Image Segmentation
Image segmentation is applied to each dried
Moringa leaves image to isolate the leaves region by removing the irrelevant background area. This segmentation process begins with
cropping to focus on the leaves region, followed by
background removal to eliminate the non-leaves regions.
Figure 6 shows the sequence of an image segmentation, including the original image (3936 × 2624 pixels), the cropped image (1117 × 1085 pixels), and the final background-free image.
This cropping and background removal processes did not significantly reduce image resolution. The resulting segmented images retained sufficient details for machine learning feature extractions.
3.4. Feature Extraction Stage
The
feature extraction stage extracts numerical features for
machine learning analysis from the preprocessed dried
Moringa leaves image. Two types of features are extracted: color and texture.
Color features are obtained from
RGB averages,
RGB histograms, and
grayscale histograms.
Texture features are extracted using the
Gray-Level Co-occurrence Matrix (GLCM) method [
34,
35]. These features describe the color distribution, intensity, and surface texture of each image. All extracted values are stored in a CSV file that will be used for classification.
3.5. Texture Feature Extraction Using GLCM
The texture feature extraction stage analyzes the spatial distribution of pixel intensities in the dried Moringa leaves images using the Gray-Level Co-occurrence Matrix (GLCM) method. This method calculates the matrix representing how often pairs of pixels with specific gray-level values occur at a defined spatial distance and direction. This matrix provides valuable information about the image texture, which helps in distinguishing leaf surface patterns across different quality classes.
From the
GLCM method, the following four statistical texture properties are extracted:
Contrast,
Correlation,
Energy, and
Homogeneity. These parameters describe different aspects of image texture and are computed by
Here,
represents the normalized
GLCM value at coordinates
, and
,
,
, and
denote the means and standard deviations of the gray levels in the horizontal and vertical directions, respectively.
Table 4 summarizes the extracted texture features and their descriptions.
3.6. Final Feature Dataset
The final feature dataset consists of 600 rows or images and 50 columns in total: filename, label, 43 color features, and 5 texture features. The color features include three average RGB values of Avg R, Avg G, Avg B, and 40 histogram bins with 10 bins each for Grayscale, Red, Green, and Blue. The texture features are extracted using the Gray-Level Co-occurrence Matrix (GLCM) method, and consist of five statistical measures: Contrast, Correlation, Energy, Homogeneity, and Dissimilarity.
Table 5 shows a representative sample in the final feature dataset, showing one image per class (A–F). Here, only selected features are shown for brevity, where the full CSV includes all 43 color and 5 texture features.
3.7. Software or Hardware Configuration
The experiments in this study were conducted using a Lenovo ThinkPad device with the following hardware specifications: Processor: 11th Gen Intel® Core™ i5-1135G7 @ 2.40 GHz (8 CPUs), Memory (RAM): 8 GB, and Operating System: Windows 11 Pro 64-bit (Build 26200). No GPU acceleration was used in this work; all computations, including image preprocessing, feature extraction, and model training (LightGBM), were performed entirely on CPU resources. This demonstrates that the proposed approach can operate efficiently even on modest computing hardware typical of small-scale industrial environments. Regarding software, the experiments were implemented using Python (for preprocessing, feature extraction, and model training), LightGBM library for classification, OpenCV for image handling, NumPy and SciPy for numerical processing and statistical calculations, and Windows 11 as the operating system. This information will be clearly presented in the revised manuscript to enhance reproducibility and allow other researchers to evaluate the practical computational requirements of the proposed system.
5. Machine Learning-Based Classification Methods
In this section, we describe the machine learning classification methods used in this study. All models were implemented using Python 3.11, and the specific libraries used for each algorithm, such as Support Vector Machine (SVM) use Scikit-learn (sklearn), Decision Tree use Scikit-learn (sklearn), Random Forest use Scikit-learn (sklearn), Gradient Boosting Decision Tree (GBDT) use Scikit-learn (sklearn), XGBoost use XGBoost library (xgboost), LightGBM use LightGBM library (lightgbm), Naive Bayes → Scikit-learn (sklearn), and K-Nearest Neighbor (KNN) use Scikit-learn (sklearn). These libraries were used with their default configurations unless otherwise specified. All preprocessing steps, feature extraction, and evaluation procedures were also executed using Python scientific computing libraries, including NumPy, Pandas, and SciPy.
5.1. Overview of Machine Learning-Based Classification
Eight
machine learning algorithms were selected based on their proven use in agricultural image classifications and quality assessments in [
36,
37,
38]. They include
Support Vector Machine (SVM),
Decision Tree,
Gradient Boosting Machine (GBM),
eXtreme Gradient Boosting (XGBoost),
K-Nearest Neighbors (K-NN),
Naive Bayes,
Random Forest, and
Light Gradient Boosting Machine (LightGBM). The eight machine learning algorithms were selected to provide a representative and comprehensive comparison across different model families commonly used for structured feature datasets. This diversity allows for evaluating which learning paradigm best fits the combined color–texture feature space used in this study. These models are also computationally efficient and practical for industrial deployment without requiring GPU resources. Therefore, the selection of these eight algorithms ensures a fair, lightweight, and application-oriented comparison aligned with real-world constraints.
SVM handles high-dimensional and nonlinear data effectively [
39].
Decision Tree is simple and interpretable.
GBM and
XGBoost improve weak learners through iterative boosting.
K-NN classifies data by distance similarity.
Naive Bayes applies a fast probabilistic approach.
Random Forest reduces overfitting through ensemble learning.
LightGBM is optimized for speed and large datasets. These algorithms were used to compare classification behaviors across linear, probabilistic, distance-based, and ensemble approaches, forming the basis for developing the proposed two-stage method.
5.2. Support Vector Machine (SVM)
Support Vector Machine (SVM) is a supervised learning algorithm commonly applied to classification and regression problems. Its objective is to find the optimal
hyperplane that maximizes the margin between data points of different classes. This geometric principle allows
SVM to generalize classification well, even with limited training data. Several studies confirmed its reliability for image-based classification, showing strong performances across agricultural and visual recognition tasks [
40,
41].
SVM determines the separating hyperplane by maximizing the margin as expressed in Equation (
9) [
42,
43]:
where
is the weight vector,
b is the bias,
is the input feature vector, and
is the class label. By optimizing this margin,
SVM achieves strong generalization and robustness in high-dimensional image feature spaces.
5.3. Decision Tree
Decision Tree is a supervised learning algorithm that classifies data by recursively splitting it based on the most informative features [
44]. It builds a hierarchical tree structure of decision rules that guide the prediction process. When the data distribution among different classes is uniform, the model’s
entropy is high, indicating greater uncertainty [
45]. The prediction function of
Decision Tree can be expressed as Equation (
10):
where
M represents the number of leaf nodes,
does the region associated with leaf
m,
does the predicted value for that region, and
does an indicator function equal to 1 if
lies in region
, and 0 otherwise. This structure allows the model to perform intuitive and interpretable classification based on feature thresholds.
5.4. Random Forest
Random Forest is an ensemble learning algorithm that constructs multiple
Decision Trees using random subsets of data and features and aggregates their predictions to improve accuracy and reduce overfitting [
46,
47]. Each
Decision Tree contributes an independent prediction, and the final result is determined by majority voting for classification or by averaging for regression. The prediction function can be expressed as Equation (
11):
where
B is the total number of trees, and
denotes the prediction of the
b-th tree for input
. For classification tasks, the final class is selected by the most frequent label among all trees, while for regression, the output becomes the average of all predictions. By combining many weak learners,
Random Forest reduces variance, handles large and complex datasets, and identifies important features effectively [
48].
5.5. Gradient Boosting Decision Trees (GBDT)
Gradient Boosting Decision Trees (GBDT) is an ensemble learning algorithm that builds multiple
Decision Trees sequentially, where each tree is learnt to correct the residual errors of the previous one [
49]. The prediction from each new tree is added to the model in small steps, improving accuracy through iterative optimization [
50]. The model update at each iteration is defined in Equation (
12):
where
represents the model after the
m-th iteration,
the previous model,
the new weak learner (tree) trained to predict residuals, and
the learning rate controlling the contribution of each tree.
At each step, minimizes the negative gradient of the loss function, gradually improving the model’s predictive performance. This process continues until a defined stopping criterion is met, producing a robust model with high accuracy and low bias.
5.6. Extreme Gradient Boosting (XGBoost)
Extreme Gradient Boosting (XGBoost) is an advanced implementation of the
Gradient Boosting framework that builds Decision Trees sequentially, where each tree corrects the residual errors of the previous ones [
51,
52].
XGBoost improves the model performance through optimized loss functions, regularization, and shrinkage (learning rate), effectively reducing overfitting while maintaining high accuracy. The objective function is expressed in Equation (
13):
where
represents the differentiable loss function measuring the difference between the predicted value
and the true label
and
the regularization term controlling model complexity. The function
represents the newly added tree at iteration
t, which learns to fit the residuals from the previous prediction
. By combining the gradient optimization and regularization,
XGBoost achieves both computational efficiency and strong generalization performance.
5.7. Light Gradient Boosting Machine (LightGBM)
Light Gradient Boosting Machine (LightGBM) is a fast, efficient, and scalable implementation of
Gradient Boosting Decision Trees (GBDT) developed by Microsoft [
53]. It enhances the traditional
GBDT framework by introducing
histogram-based Decision Tree learning and
leaf-wise tree growth, which significantly reduces training time and memory usage [
54,
55]. The objective function optimized at each iteration is defined in Equation (
14):
where
represents the total objective function combining loss and regularization,
the individual loss function measuring the error between the true label
and the predicted value
,
the newly added Decision Tree trained to fit the residuals, and
the regularization term controlling model complexity.
Unlike the standard GBDT, LightGBM employs histogram binning to accelerate split finding and uses a leaf-wise growth strategy that allows deeper, more accurate trees for complex data patterns. These techniques make LightGBM highly suitable for large-scale and high-dimensional datasets, offering strong performance with lower computational cost.
5.8. Naive Bayes
Naive Bayes is a probabilistic classification algorithm based on
Bayes’ theorem, which assumes that all features are conditionally independent given the class label [
56]. Despite this “naive” assumption, it often performs effectively, especially in text and image classification tasks [
57,
58]. The model predicts the probability that a feature vector
belongs to a class
using Equation (
15):
where
represents the posterior probability of class
given features
,
does the prior probability of class
, and
does the likelihood of observing feature
given that the sample belongs to class
. The denominator
describes the evidence term, constant across all classes and typically omitted during classification.
Naive Bayes selects the class with the highest posterior probability:
Its simplicity, low computational cost, and robustness to small datasets make
Naive Bayes a practical baseline for probabilistic classification tasks [
59].
5.9. K-Nearest Neighbor (K-NN)
K-Nearest Neighbor (K-NN) is a simple, non-parametric algorithm used for both classification and regression tasks [
60,
61]. It classifies a new data point by examining the
k nearest neighbors in the training set based on a distance metric, typically the
Euclidean distance. The predicted class is determined by the majority label among these neighbors [
62]. The distance between a query point
and a training point
is defined in Equation (
16):
where
represents the Euclidean distance between the two data points,
m does the total number of features,
does the
j-th feature value of the query point
, and
does the corresponding feature value of the training point
.
After computing the distances, K-NN identifies the k nearest samples and assigns the class that appears most frequently among them. Despite its simplicity, K-NN performs well on small to moderate datasets and serves as a strong baseline for pattern recognition and image classification.
5.10. Evaluating Model Performance in Classification
Evaluating model performance in classification is essential to know how accurately a
machine learning model can estimate the correct class label [
25]. Several standard metrics are used to quantify classification effectiveness, each focusing on different aspects of prediction quality.
Accuracy is the most common measure, which represents the proportion of correctly predicted samples among all predictions, as defined in Equation (
17):
where
,
,
, and
denote true positives, true negatives, false positives, and false negatives, respectively.
Precision measures how many of the samples predicted as positive are truly positive, as shown in Equation (
18):
Recall, also known as sensitivity, quantifies the ability of the model to identify all positive samples, as expressed in Equation (
19):
F1-Score is the harmonic mean of precision and recall, providing a single metric that balances both, as given in Equation (
20):
Confusion Matrix can visualize model predictions, summarizing correct and incorrect classifications across all classes. The importance of using standard evaluation metrics such as accuracy, precision, recall, and F1-Score in assessing classification performance [
63]. A general form of this matrix is shown below:
The structure of the confusion matrix used for evaluating classification performance is presented in
Table 6. In summary,
Accuracy evaluates overall correctness,
Precision focuses on prediction reliability,
Recall measures detection completeness, and
F1-Score balances both aspects. These metrics collectively provide a comprehensive evaluation of model performance in classification tasks.
7. Discussion
In this section, we discuss our findings from the experiments of classification of dried Moringa leaves using eight machine learning algorithms and the two-stage classification method.
7.1. Baseline vs. Two-Stage Performance
The baseline classification achieved an overall accuracy of 0.82 using LightGBM on six classes (A–F). While the model performed well for most categories, confusion remained between visually similar classes, particularly Class A and Class B, due to their overlapping color and texture patterns. The proposed two-stage classification method addressed this limitation by introducing a hierarchical refinement process. The accuracy was improved to 0.91 in the first stage and 0.90 in the second stage, confirming the effectiveness of this method for fine-grained classification of similar categories.
7.2. Effectiveness of First Stage
In the first stage, Class A and Class B were merged into a single Class AB, forming five classes (AB, C, D, E, F). This restructuring simplified the classification space and reduced inter-class confusion. The LightGBM classifier achieved an accuracy of 0.911 with a mean cross-validation score of 0.92, outperforming all other algorithms tested. The model showed particularly strong results for AB and F, demonstrating that merging highly correlated classes improves initial classification reliability.
7.3. Impact of the Second Stage
The second stage focused on differentiating Class A and Class B from Class AB. Using LightGBM, the classifier achieved 0.90 accuracy, with precision, recall, and F1-Scores all around 0.90. The Confusion Matrix showed only minor misclassification between Class A and Class B with four images, indicating that the refinement successfully captured subtle textural and color differences. This confirms the advantage of the hierarchical approach in improving discrimination between nearly identical samples.
7.4. Comparison Across Algorithms
Among all eight algorithms evaluated, LightGBM and XGBoost showed comparable accuracy (0.82 and 0.82, respectively) in the baseline experiment. However, LightGBM trained 16 times faster (0.64 s versus 10.40 s), owing to its histogram-based Decision Tree and leaf-wise growth strategy. Random Forest also performed well (0.81 accuracy) but required longer training time. These findings align with previous research indicating that LightGBM offers an optimal balance of accuracy and computational efficiency for structured feature datasets.
7.5. Feature Contribution and Image Resolution
The use of 43 color and 5 texture features in this paper contributed significantly to classification performance.
Color features captured hue and intensity differences, while
texture features extracted using
GLCM quantified surface uniformity and contrast. High-resolution images (1117 × 1085 pixels) provided richer feature details, improving the detection of fine visual differences. Compared with prior studies using low-resolution images (128 × 12 pixels) [
14], the higher resolution increased feature diversity and model precision, especially for
Class A and
Class B. Previous related studies did not compare Class A and Class B separately, as these two categories were typically merged into a single group due to their highly similar color and morphological characteristics.
7.6. Manual Feature Extraction over End-to-End Deep Learning
We used manual feature extraction instead of an end-to-end deep learning model because our dataset is relatively small (600 images). Deep learning methods such as CNNs usually require large datasets to avoid overfitting and often do not perform well with limited data [
64,
65]. In contrast, traditional machine learning models with handcrafted features are more stable and reliable in small-data conditions [
66]. The most difficult part of this study is distinguishing Class A and Class B, which look very similar in color and shape. Texture features extracted using GLCM can capture subtle differences—such as stem content and surface smoothness—that deep learning may fail to learn with limited samples [
67,
68].
Finally, the industrial partner requires a lightweight model that can run on standard CPU-based computers without a GPU. Manual feature extraction combined with traditional ML provides fast and practical performance for real-world deployment [
69].
7.7. Practical Implications and Limitations
The two-stage LightGBM-based algorithm demonstrates high reliability and speed, making it suitable for automated grading in agricultural industries where real-time quality assessment is required. This hierarchical design can also be adapted to other agricultural products with overlapping visual features. However, the dataset size of 600 images remains limited. Thus, future studies should incorporate larger datasets under varying lighting and background conditions. Additionally, integrating deep learning feature extraction may further enhance robustness and reduce dependence on handcrafted features. The evaluation was conducted in a controlled research environment. The system has not yet been tested under real production-line conditions where noise, dust, motion, and strict real-time constraints are present.
8. Conclusions
This study presented a two-stage classification method using the LightGBM algorithm to automatically classify the quality of dried Moringa leaves into six categories. The method combines color and texture features to accurately classify them while addressing the difficulty of distinguishing visually similar classes. Experimental results show that this two-stage approach improved classification performance, increasing accuracy from 82% in the baseline model to 91% in the first stage and 90% in the second stage for fine-grained classes. LightGBM provided the best trade-off between accuracy and computational efficiency compared with other algorithms. Future work will focus on expanding the dataset under varied lighting and environmental conditions and integrating deep learning models, such as convolutional neural networks (CNNs), to further enhance robustness and reduce reliance on handcrafted features for real-time industrial applications.
In the other future work, we plan to incorporate additional texture descriptors such as Local Binary Patterns (LBP) to further improve the model’s ability to capture fine morphological differences between closely related classes, this study will incorporate additional color spaces such as HSV and Lab to enrich the feature representation and improve fine-grained class separation, especially for visually similar classes like A and B. This study will incorporate hyperparameter optimization for the LightGBM model—using techniques such as grid search, random search, or Bayesian optimization to tune parameters like learning_rate, num_leaves, n_estimators, feature_fraction, and bagging_fraction—with the aim of improving classification accuracy and reducing processing time. Future work will include larger-scale benchmarking and real-time testing to more accurately assess the model’s suitability for industrial implementation. For a limited dataset, in future research, we expand the dataset with additional samples and also explore data augmentation techniques to increase sample diversity and the dataset based on actual production lines under different environmental settings.