Automatic Fruit Grading System with High Adaptability Using Machine Learning Method
Abstract
1. Introduction
2. Materials and Methods
2.1. Materials
2.2. Methodology
- (i)
- Pretreatment: Since the collected images are susceptible to noise interference, a median filter is used to remove the image noise. The median of the pixel set around the filtered point is taken as the pixel of the point in this approach. The filtered images are converted from RGB to HSI color space. The threshold suitable for target region segmentation is selected for segmentation, which is prepared for subsequent feature extraction. The collected loquat images were decomposed by RGB color, and the red, green, and blue components are shown in Figure 3.

- (ii)
- Feature extraction: Feature extraction is an important process of fruit grading, and the general feature types include texture, shape, size, color, and defects. The corresponding features are extracted according to the features of fruits, which is the most suitable way for the establishment of a grading model. The color, shape, and defect features of loquats can be extracted for loquat grading.
- (iii)
- Fruit grade marking: Firstly, the grades of the fruits are manually labeled with easy-to-distinguish characteristics. For similar fruits, they are graded in detail by referring to the characteristic data and artificial sensation. In the case of unified shooting parameters and height, a square of a known size is put under the lens to obtain its picture information. Then, the pixel size of the square according to the square picture information is calculated. Finally, the ratio of the actual area of the square and the pixel area is taken as the pixel to the actual scale bar under the condition of this parameter. Dual labeling was conducted, and the accuracy of annotations was ensured by combining manual labeling with sensory judgment.
- (iv)
- Model construction: RF is a highly flexible machine learning algorithm [25]. The basic unit of RF is a decision tree. Its basic idea is the inheritance learning approach. Randomness indicates that each decision tree extracts samples randomly, and the forest contains many decision trees. Despite inputting high-dimensional samples, Random Forest maintains strong grading performance without dimensionality reduction. The decision tree consists of three parts, namely the root node, leaf node, and internal node. The closer to the root node, the greater the impact on the grading results. After a large number of sample training runs, the critical parameters of each feature node grading are determined. The grading results are output at the leaf node.
- (v)
- Evaluation: Since RF aims at bi-classification problems, the multi-classification problems need to be transformed into multiple bi-classifications. The actual and predicted grades of each fruit in the prediction set are counted. The confusion matrix is used to show the numerical distribution of various predictions. The evaluation index of the fruit grading model is
- (vi)
- Experimental equipment: The parameters of the camera according to the manufacturer are as follows (Table 2):
3. Experimental Results
4. Discussion and Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Patil, P.U.; Lande, S.B.; Nagalkar, V.J.; Nikam, S.B.; Wakchaure, G. Grading and sorting technique of dragon fruits using machine learning algorithms. J. Agric. Food Res. 2021, 4, 100118. [Google Scholar] [CrossRef]
- Al-Shargabi, B.; Alzyadat, R.; Hamad, F. AEGD: Arabic essay grading dataset for machine learning. J. Theor. Appl. Inf. Technol. 2021, 99, 1329–1338. [Google Scholar]
- Tarbă, N.; Boiangiu, C.-A.; Voncilă, M.-L. State-of-the-Art Document Image Binarization Using a Decision Tree Ensemble Trained on Classic Local Binarization Algorithms and Image Statistics. Appl. Sci. 2025, 15, 8374. [Google Scholar] [CrossRef]
- Bai, X.; Li, Z.; Li, W.; Zhao, Y.; Li, M.; Chen, H.; Wei, S.; Jiang, Y.; Yang, G.; Zhu, X. Comparison of machine-learning and casa models for predicting apple fruit yields from time-series planet imageries. Remote Sens. 2021, 13, 3073. [Google Scholar] [CrossRef]
- Magdas, D.; David, M.; Berghian-Grosan, C. Fruit spirits fingerprint pointed out through artificial intelligence and FT-Raman spectroscopy. Food Control 2022, 133, 108630. [Google Scholar] [CrossRef]
- Worasawate, D.; Sakunasinha, P.; Chiangga, S. Automatic classification of the ripeness stage of mango fruit using a machine learning approach. AgriEngineering 2022, 4, 32–47. [Google Scholar] [CrossRef]
- Bhargava, A.; Bansal, A.; Goyal, V. Machine learning–based detection and sorting of multiple vegetables and fruits. Food Anal. Methods 2022, 15, 228–242. [Google Scholar] [CrossRef]
- Mo, Y.; Bai, S.; Chen, W. ASHM-YOLOv9: A Detection Model for Strawberry in Greenhouses at Multiple Stages. Appl. Sci. 2025, 15, 8244. [Google Scholar] [CrossRef]
- Hu, G.; Zhang, E.; Zhou, J.; Zhao, J.; Gao, Z.; Sugirbay, A.; Jin, H.; Zhang, S.; Chen, J. Infield apple detection and grading based on multi-feature fusion. Horticulturae 2021, 7, 276. [Google Scholar] [CrossRef]
- Bhargava, A.; Bansal, A. Classification and grading of multiple varieties of apple fruit. Food Anal. Methods 2021, 14, 1359–1368. [Google Scholar] [CrossRef]
- Chopra, H.; Singh, H.; Bamrah, M.S.; Mahbubani, F.; Verma, A.; Hooda, N.; Rana, P.S.; Singla, R.K.; Singh, A.K. Efficient fruit grading system using spectrophotometry and machine learning approaches. IEEE Sens. J. 2021, 21, 16162–16169. [Google Scholar] [CrossRef]
- Kumari, N.; Dwivedi, R.K.; Bhatt, A.K.; Belwal, R. Automated fruit grading using optimal feature selection and hybrid classification by self-adaptive chicken swarm optimization: Grading of mango. Neural Comput. Appl. 2022, 34, 1285–1306. [Google Scholar] [CrossRef]
- Chuquimarca, L.E.; Vintimilla, B.X.; Velastin, S.A. A Review of External Quality Inspection for Fruit Grading Using CNN Models. Artif. Intell. Agric. 2024, 14, 1–20. [Google Scholar] [CrossRef]
- Albaaji, G.F.; S.S., V.C.; Sharafudeen, M. An Intelligent Multi-Modal Neural Framework for Accurate Fruit Grading Localization and Yield Estimation. Expert Syst. Appl. 2025, 268, 126366. [Google Scholar] [CrossRef]
- Song, J.-Y.; Qin, Z.-S.; Xue, C.-W.; Bian, L.-F.; Yang, C. Fruit Grading System by Reconstructed 3D Hyperspectral Full-Surface Images. Postharvest Biol. Technol. 2024, 212, 112898. [Google Scholar] [CrossRef]
- Hayat, A.; Morgado-Dias, F.; Choudhury, T.; Singh, T.P.; Kotecha, K. FruitVision: A Deep Learning Based Automatic Fruit Grading System. Open Agric. 2024, 9, 20220276. [Google Scholar] [CrossRef]
- Mon, T.; ZarAung, N. Vision based volume estimation method for automatic mango grading system. Biosyst. Eng. 2020, 198, 338–349. [Google Scholar] [CrossRef]
- Baietto, M.; Wilson, A.D. Electronic-nose applications for fruit identification, ripeness and quality grading. Sensors 2015, 15, 899–931. [Google Scholar] [CrossRef]
- Qu, H.; Xiang, R.; Obsie, E.Y.; Wei, D.; Drummond, F. Parameterization and calibration of wild blueberry machine learning models to predict fruit-set in the northeast china bog blueberry agroecosystem. Agronomy 2021, 11, 1736. [Google Scholar] [CrossRef]
- Das, P.; Yadav, J.K.P.S.; Yadav, A.K. An Automated Tomato Maturity Grading System Using Transfer Learning Based AlexNet. Ingénierie Systèmes D’inf. 2021, 26, 191–200. [Google Scholar] [CrossRef]
- Ismail, N.; Malik, O.A. Real-time visual inspection system for grading fruits using computer vision and deep learning techniques. Inf. Process. Agric. 2022, 9, 24–37. [Google Scholar] [CrossRef]
- Albarrak, K.; Gulzar, Y.; Hamid, Y.; Mehmood, A.; Soomro, A.B. A deep learning-based model for date fruit classification. Sustainability 2022, 14, 6339. [Google Scholar] [CrossRef]
- Barrett, D.M.; Beaulieu, J.C.; Shewfelt, R. Color, flavor, texture, and nutritional quality of fresh-cut fruits and vegetables: Desirable levels, instrumental and sensory measurement, and the effects of processing. Crit. Rev. Food Sci. Nutr. 2010, 50, 369–389. [Google Scholar] [CrossRef] [PubMed]
- Li, J.; Huang, W.; Zhao, C. Machine vision technology for detecting the external defects of fruits—A review. Imaging Sci. J. 2015, 63, 241–251. [Google Scholar] [CrossRef]
- Speiser, J.L.; Miller, M.E.; Tooze, J.; Ip, E. A comparison of random forest variable selection methods for classification prediction modeling. Expert Syst. Appl. 2019, 134, 93–101. [Google Scholar] [CrossRef]
- Anita, C.; Nagarajan, P.; Lakshminarayanan, E.; Sankar, M.N.; Rishikanth, V. Machine Vision and Machine Learning based Fruit Quality Monitoring. Rev. Geintec-Gest. Inov. E Tecnol. 2021, 11, 836–842. [Google Scholar] [CrossRef]
- Pardede, J.; Sitohang, B.; Akbar, S.; Khodra, M.L. Implementation of transfer learning using VGG16 on fruit ripeness detection. Int. J. Intell. Syst. Appl. 2021, 13, 52–61. [Google Scholar] [CrossRef]
- Rismiyati, R.; Luthfiarta, A. Vgg16 transfer learning architecture for salak fruit quality classification. Telematika 2021, 18, 37. [Google Scholar] [CrossRef]
- Alresheedi, K.M.; Aladhadh, S.; Khan, R.U.; Qamar, A.M. Dates Fruit Recognition: From Classical Fusion to Deep Learning. Comput. Syst. Sci. Eng. 2022, 40, 151–166. [Google Scholar] [CrossRef]










| Grade | Defect Rate |
|---|---|
| Premium | ≤0.5% |
| First level | ≤5% |
| Second level | ≤10% |
| Product Model | SHL-500WS |
| Lens Size | 1/2.5 inch (4:3) |
| Cell Size | 2.2 μm |
| Highest Effective Pixel | 2592(H) × 1944(V) |
| Signal-to-Noise Ratio | 38 dB |
| Dynamic Range | 70 dB |
| Sensitivity | 1.4V/lux-sec@550nm |
| Minimum Illumination | 0.1 lux |
| Product Model | ThinkPad E470c |
| Screen Size | 14 inch |
| CPU Model | Intel CORE i56200U |
| CPU Frequency | 2.3 GHz |
| Memory Capacity | 8 GB (8 GB × 1) DDR42400MHz |
| Hard Disk Capacity | 500GB7200turns |
| Graphics Chip | NVIDIAGeforce920MX |
| Operating System | Windows 10 |
| Features | |||||
|---|---|---|---|---|---|
| Texture | Color | Size | Shape | Defect | |
| Apple | √ | √ | √ | ||
| Orange | √ | √ | |||
| Pomegranate | √ | √ | |||
| Loquat | √ | √ | √ | ||
| Apple | Loquat | Pomegranate | Orange | |
|---|---|---|---|---|
| SVM | 0.923 | 0.929 | 0.950 | 0.988 |
| LDA | 0.843 | 0.863 | 0.919 | 0.847 |
| KNN | 0.953 | 0.877 | 0.969 | 0.928 |
| Random Forest | 0.986 | 0.953 | 0.981 | 0.991 |
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. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Zhang, P.; Li, X. Automatic Fruit Grading System with High Adaptability Using Machine Learning Method. Appl. Sci. 2025, 15, 11866. https://doi.org/10.3390/app152211866
Zhang P, Li X. Automatic Fruit Grading System with High Adaptability Using Machine Learning Method. Applied Sciences. 2025; 15(22):11866. https://doi.org/10.3390/app152211866
Chicago/Turabian StyleZhang, Peixian, and Xiuhong Li. 2025. "Automatic Fruit Grading System with High Adaptability Using Machine Learning Method" Applied Sciences 15, no. 22: 11866. https://doi.org/10.3390/app152211866
APA StyleZhang, P., & Li, X. (2025). Automatic Fruit Grading System with High Adaptability Using Machine Learning Method. Applied Sciences, 15(22), 11866. https://doi.org/10.3390/app152211866

