نوع مقاله : مقاله پژوهشی
نویسندگان
گروه مهندسی بیوسیستم، دانشکده کشاورزی، دانشگاه بوعلی سینا، همدان، ایران
چکیده
کلیدواژهها
موضوعات
عنوان مقاله [English]
نویسندگان [English]
During chickpea harvesting, various types of impurities are present in the product, which must be identified and removed before market distribution or use as seed. Although pneumatic and mechanical methods can eliminate a substantial portion of these impurities, conventional techniques are insufficient for separating objects such as small stones of similar size to chickpeas or unripe and discolored grains. The objective of this study was to identify the type and determine the location of different chickpea impurities using two intelligent classifiers: Support Vector Machine (SVM) and k-Nearest Neighbors (KNN). For this purpose, 400 RGB images were acquired, encompassing six classes: healthy, green, black, colored, stones, and split chickpeas. After object segmentation and classification into six groups, the total number of samples reached 3,840. Features extracted included mean, median, variance, skewness, histogram, entropy, and texture descriptors derived from the gray-level co-occurrence matrix (GLCM), such as contrast, correlation, energy, and homogeneity. In the SVM model, the RBF kernel exhibited superior performance compared to other kernels. For KNN, the optimal results were obtained with k = 13, the City Block distance metric, and a weighting scheme of 1/(c + D²) with c = 1. Object localization was performed in MATLAB by determining the coordinates of each object's center. Based on the results, the highest classification accuracy for the SVM and KNN models at a resolution of 250×250 pixels were 98.09% and 90.88%, respectively.
کلیدواژهها [English]
Chickpeas are a high-protein legume whose consumption has increased worldwide. Ensuring their quality requires the removal of foreign impurities and uniformity in size, shape, and color. Manual separation is labor-intensive, making automated systems necessary for efficient and accurate impurity detection. Machine vision has shown great potential for identifying impurities and classifying varieties in small-seeded legumes. However, the effective deployment of such systems requires crop-specific algorithms tailored to local cultivars. This study aimed to develop an algorithm for native Iranian chickpea varieties that can accurately detect and classify impurities while determining their spatial locations—a factor largely unaddressed in previous research. The ultimate goal is to reduce reliance on manual labor and enhance the performance of automatic grading machines.
Images were pre-processed to remove background noise and isolate the primary objects. Various color spaces (HSV, Lab, YCbCr) were evaluated, and YCbCr provided the best discrimination between objects and background. Following conversion from RGB to YCbCr, thresholds in the Cr channel were tested, and Cr > 105 was selected for effective segmentation. Small particles were removed using the bwareaopen function, and final binary masks were multiplied with the original images to produce segmented outputs. Each object was assigned to one of six classes: healthy, green, black, colored, stone, and split chickpeas, resulting in 3,840 images (640 per class). Feature extraction combined color, texture, and geometric descriptors. Texture features (correlation, energy, homogeneity, entropy) were derived from grayscale images using the gray-level co-occurrence matrix (GLCM) at four angles (0°, 45°, 90°, 135°) and pixel distances of 1–10, yielding 160 features. Statistical descriptors (kurtosis, skewness, maximum, median, mean, variance) were computed for RGB channels (18 features) and grayscale images (5 features), along with perimeter-to-area ratio and entropy (2 features), totaling 185 features. Seventy percent of the dataset was used for training and 30% for testing. All features were normalized before classification. To identify and classify pea impurities, two well-known machine learning models—Support Vector Machine (SVM) and K-Nearest Neighbors (KNN)—were employed, allowing a comparative evaluation of their performance in distinguishing between the six classes.
The SVM classifier demonstrated high stability and reliability due to its convergence to a global minimum. Analysis of the cost parameter C indicated that the optimal performance was achieved at C = 10. Furthermore, the RBF kernel outperformed both linear and polynomial kernels, yielding approximately 14.9% and 13.8% higher accuracy, respectively. For the KNN classifier, k values from 3 to 21 were examined, and the best performance (90.79% accuracy) was obtained using k = 13, the City Block distance metric, and the weighted scheme 1/(c + D²). Evaluation of distance metrics showed that weighted approaches performed better than simple distance measures. Investigating the effect of image size revealed that increasing the resolution did not significantly improve classification accuracy, and the 250×250 resolution provided the optimal trade-off between speed and accuracy. Confusion matrix results indicated that the black chickpea class exhibited the highest separability, while misclassifications mainly occurred in classes with similar characteristics. Overall comparison demonstrated that SVM achieved superior performance, with an accuracy of 98.09%, outperforming KNN, which achieved 90.88%. In the SVM model, the F1-score for all classes—except the stone class—exceeded 97%. The slightly lower performance for the stone class was attributed to its visual similarity to certain chickpea types. Comparison with previous studies showed that the improved SVM model increased accuracy by approximately 6.8%. Additionally, object localization and bounding box generation were successfully accomplished, with an average processing time of 25.6 ms per image, which can be further reduced using more advanced hardware.
In this study, two well-known classifiers—Support Vector Machine (SVM) and K-Nearest Neighbors (KNN)—were used to identify and differentiate healthy chickpea seeds from various impurities. SVM outperformed KNN, with KNN performance influenced by the number of neighbors, distance metrics, and weighting schemes, while SVM accuracy depended on the kernel function. A key feature of this study is the inclusion of classes with highly similar characteristics, improving discrimination of subtle differences and enabling high-purity chickpea batches. Although common Iranian varieties and typical impurities were used, variations in color, texture, or shape in other cultivars may limit generalizability. Future studies should include a broader range of cultivars and impurities to enhance robustness. With the growing adoption of robotic and automated systems, the algorithm can be integrated into automatic grading machines for detecting both the type and spatial location of impurities. Further testing in laser-based grading systems is recommended to assess industrial performance.
Both authors contributed equally to the research and the preparation of the manuscript, under the guidance and supervision of the corresponding author.
Data available on request from the authors
The authors would like to express their sincere gratitude to Bu-Ali Sina University for providing the facilities and support necessary to conduct this research.
The authors avoided data fabrication, falsification, plagiarism, and misconduct.
The author declares no conflict of interest