with the collaboration of Iranian Society of Mechanical Engineers (ISME)

An Integrated Mechatronic Sorting System for Bitter and Sweet Almonds Based on FTIR Spectroscopy of Shells and MLP Neural Network

Document Type : Research Article

Authors

1 Department of Biosystems Mechanical Engineering Shahid Bahonar University of Kerman, Iran

2 Department of Computer Engineering Shahid Bahonar University of Kerman, Iran

3 Department of Chemistry Shahid Bahonar University of Kerman, Iran

Abstract
Introduction
Ensuring the authenticity and safety of almonds is a critical food safety challenge, primarily due to the presence of amygdalin in bitter varieties, a cyanogenic glycoside that can release toxic hydrogen cyanide upon hydrolysis. Traditional detection methods, such as chromatography, are often destructive, time-consuming, and unsuitable for industrial-scale applications. While the current laboratory-scale analysis relies on a sample preparation method (KBr pellet) that is inherently destructive, the ultimate goal of this research is to develop a non-destructive, automated sorting system suitable for industrial implementation. This can be achieved through the use of alternative FTIR techniques, such as Attenuated Total Reflectance (ATR)-FTIR, which allows for direct analysis of the almond shell surface without the need for sample preparation. This study addresses the need for rapid, non-destructive, and automated sorting by developing an integrated framework that combines Fourier-transform infrared (FTIR) spectroscopy of almond shells with machine learning and mechatronic automation. The research specifically focuses on exploiting the rich phenolic content of almond shells as a novel, low-cost substrate for reliable classification.
Materials and Methods
A set of 200 almonds (100 bitter, 100 sweet) was collected. Their shells were separated, vacuum-dried, ground into powder, and pressed into potassium bromide (KBr) pellets for analysis. FTIR spectra were recorded in the range of 400–4000 cm⁻¹. The raw spectral data underwent preprocessing using first and second Savitzky–Golay derivatives, Standard Normal Variate (SNV), and Multiplicative Scatter Correction (MSC). Four supervised learning algorithms, Support Vector Machine (SVM), Random Forest (RF), Multi-Layer Perceptron (MLP), and an Autoencoder-MLP hybrid, were trained and compared, using a 70-30 train-test split with fivefold cross-validation. The best-performing model's output was integrated with a custom-built laboratory-scale mechatronic sorting system. This system featured a conveyor belt, a microcontroller-based control board, and a mechanical deflection mechanism to physically separate the almonds based on the classification decision.
Results and Discussion
Among the tested models, the MLP network achieved the highest classification performance for almond shells, with an accuracy of 95.5% and an Area Under the Curve (AUC) of 0.984. Statistical analysis via the McNemar test confirmed its significant superiority over the best classical model (RF, p < 0.01). This superior performance is attributed to the MLP's ability to model the complex, non-linear relationships within the high-dimensional FTIR spectral data, which traditional linear models like SVM (accuracy 82.5%) failed to capture effectively. Feature importance analysis revealed three key discriminating spectral bands: 1030 cm⁻¹ (associated with phenolic C–O stretching), 1740 cm⁻¹ (related to carbonyl C=O stretching), and 2920 cm⁻¹ (linked to aliphatic C–H stretching). These bands were more pronounced in bitter almond shells, corresponding to their higher phenolic and lipid content, including amygdalin derivatives. Dimensionality reduction visualisations using t-SNE and UMAP on the latent features extracted by the Autoencoder-MLP model further corroborated the superior class separability achieved by deep learning approaches compared to linear methods like PCA. When the MLP model's decisions were deployed on the mechatronic sorter, the system achieved an average physical sorting accuracy of 99.5% across consecutive tests with varying sample compositions. Error analysis indicated that the primary sources of infrequent mis-sorting were related to mechanical synchronisation and sample positioning on the conveyor, rather than errors in the MLP classification algorithm itself. The throughput was measured at 30–35 almonds per minute, demonstrating practical potential for medium-scale processing. This performance aligns with or surpasses the accuracy ranges reported in recent studies utilising HSI or ATR-FTIR for almond discrimination, while uniquely adding the critical step of real-time physical separation.
Conclusion
This study successfully demonstrates the feasibility of a non-destructive, integrated system for almond authentication and sorting. The integration of shell-based FTIR spectroscopy with an MLP classifier yields superior analytical accuracy. Crucially, the direct integration of this classification into an automated mechatronic sorter bridges the gap between laboratory detection and industrial application. The approach offers a scalable, cost-effective, and non-destructive solution for enhancing food safety in almond processing by enabling the real-time removal of toxic bitter almonds from production lines.
Acknowledgement
The authors gratefully acknowledge the staff of the Chemistry Laboratory of Shahid Bahonar University of Kerman for providing access to FTIR equipment and technical support during the spectral acquisition and analysis process.

Keywords

Subjects

Authors retain the copyright. This is an open access article distributed under Creative Commons Attribution 4.0 International License (CC BY 4.0)

  1. Al-Awadhi, M. A., & Deshmukh, R. R. (2025). Detection of Adulteration in Coconut Milk using Infrared Spectroscopy and Machine Learning. IEEE MTICTI 2021. https://doi.org/10.1109/mticti53925.2021.9664764
  2. Arabizadeh, N., Mahmoudi, M., Mokhtar Gandomani, L., & Eizadi-Mood, N. (2024). Cyanide poisoning after bitter almond ingestion: A rare case report. Case Reports in Emergency Medicine, 2024, Article ID 123456. https://doi.org/10.1002/ccr3.8418
  3. Arboleda, E. R., Fajardo, A. C., & Medina, R. P. (2018). Classification of coffee bean species using image processing, artificial neural network and K nearest neighbors. In 2018 IEEE International Conference on Innovative Research and Development (ICIRD) (pp. 1–5). IEEE. https://doi.org/10.1109/icird.2018.8376326
  4. Balakrishnan, P., Anny Leema, A., Jothiaruna, N., Assudani, P. J., Sankar, K., Kulkarni, M. B., & Bhaiyya, M. (2025). Artificial intelligence for food safety: From predictive models to real-world safeguards. Trends in Food Science & Technology, 163, 105153. https://doi.org/10.1016/j.tifs.2025.105153
  5. Béjar-Grimalt, J., Pérez-Guaita, D., Sánchez-Illana, Á., García-Contreras, R., Kataria, R., Bureau, S., de la Guardia, M., & Cadet, F. (2025). Classification of Apricot Varieties by Infrared Spectroscopy and Machine Learning. ACS Agricultural Science & Technology, 5(7), 1373-1381. https://doi.org/10.26434/chemrxiv-2025-f76xt
  6. Borràs, E., Amigo, J. M., van den Berg, F., Boqué, R., & Busto, O. (2014). Fast and robust discrimination of almonds (Prunus amygdalus) with respect to their bitterness by using near infrared and partial least squares-discriminant analysis. In Food Chemistry (Vol. 153, pp. 15–19). Elsevier BV. https://doi.org/10.1016/j.foodchem.2013.12.032
  7. Breiman, L. (2001). Random Forests. Machine Learning, 45(1), 5-32. https://doi.org/10.1023/a:1010933404324
  8. Chu, C., Wang, H., Luo, X., Fan, Y., Nan, L., Du, C., Gao, D., Wen, P., Wang, D., Yang, Z., Yang, G., Liu, L., Li, Y., Hu, B., Zunongjiang, A., & Zhang, S. (2024). Rapid detection and quantification of melamine, urea, sucrose, water, and milk powder adulteration in pasteurized milk using Fourier transform infrared (FTIR) spectroscopy coupled with modern statistical machine learning algorithms. Heliyon, 10(12), e32720. https://doi.org/10.1016/j.heliyon.2024.e32720
  9. Cochran, W. G. (1977). Sampling Techniques (3rd ed.). John Wiley & Sons.
  10. Cortés, V., Talens, P., Barat, J. M., & Lerma-García, M. J. (2019). Discrimination of intact almonds according to their bitterness and prediction of amygdalin concentration by Fourier transform infrared spectroscopy. Postharvest Biology and Technology, 148, 236-241. https://doi.org/10.1016/j.postharvbio.2018.05.006
  11. Das, M., Yeo, W. S., & Saptoro, A. (2025). A review of machine learning in hyperspectral imaging for food safety. Vibrational Spectroscopy, 139, 103828. https://doi.org/10.1016/j.vibspec.2025.103828
  12. Deng, Z., Wang, T., Zheng, Y., Zhang, W., & Yun, Y. H. (2024). Deep learning in food authenticity: Recent advances and future trends. Trends in Food Science & Technology, 144, 104344. https://doi.org/10.1016/j.tifs.2024.104344
  13. Dimakopoulou-Papazoglou, D., Serrano, S., Rodríguez, I., Ploskas, N., Koutsoumanis, K., & Katsanidis, E. (2025). FTIR spectroscopy combined with machine learning for the classification of Mediterranean honey based on origin. Journal of Food Composition and Analysis, 144, 107778. https://doi.org/10.1016/j.jfca.2025.107778
  14. Dong, J. E., Li, J., Liu, H., & Wang, Y. Z. (2023). Machine learning and deep learning based on the small FT-MIR dataset for fine-grained sampling site recognition of boletus tomentipes. Food Research International, 167, 112679. https://doi.org/10.1016/j.foodres.2023.112679
  15. Durak, T., & Depciuch, J. (2020). Effect of plant sample preparation and measuring methods on ATR-FTIR spectra results. Environmental and Experimental Botany, 169, 103915. https://doi.org/10.1016/j.envexpbot.2019.103915
  16. Ezenarro, J., Riu, J., Ahmed, H. J., Busto, O., Giussani, B., & Boqué, R. (2024). Measurement errors and implications for preprocessing in miniaturised near-infrared spectrometers: Classification of sweet and bitter almonds as a case of study. Talanta, 276, 126271. https://doi.org/10.1016/j.talanta.2024.126271
  17. Ganaie, M. A., Tanveer, M., Suganthan, P. N., & Snasel, V. (2022). Oblique and rotation double random forest. Neural Networks, 153, 496-517. https://doi.org/10.1016/j.neunet.2022.06.012
  18. Gökalp, Ç., & Mübarek Mazhar, Ç. (2024). An improved pistachio detection approach using YOLO-v8 Deep Learning Models. BIO Web of Conferences, 85, 01013. https://doi.org/10.1051/bioconf/20248501013
  19. Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep learning. MIT Press.
  20. Hong, Y., Birse, N., Quinn, B., Li, Y., Jia, W., McCarron, P., Wu, D., da Silva, G. R., Vanhaecke, L., van Ruth, S., & Elliott, C. T. (2023). Data fusion and multivariate analysis for food authenticity analysis. Nature Communications, 14(1), 7738. https://doi.org/10.1038/s41467-023-38382-z
  21. Hou, L., Liu, Z., You, J., Liu, Y., Xiang, J., Zhou, J., & Pan, Y. (2024). Tomato Sorting System Based on Machine Vision. Electronics, 13(11), 2114. https://doi.org/10.3390/electronics13112114
  22. International Organization for Standardization. (2002). Sensory analysis Methodology General guidance for measuring odour, flavour and taste detection thresholds by a 3-AFC procedure (ISO 13301:2002). Retrieved from: https://www.iso.org/standard/36791.html
  23. Jahnke, S., Roussel, J., Hombach, T., Kochs, J., Fischbach, A., Huber, G., & Scharr, H. (2016). phenoSeeder - A Robot System for Automated Handling and Phenotyping of Individual Seeds. Plant Physiology, 172(3), 1358-1370. https://doi.org/10.1104/pp.16.01122
  24. Lacerda, M., Franca, T., Calvani, C., Marangoni, B., Teodoro, P., Campos, C. N. S., Baio, F. H. R., Azevedo, G. B., & Cena, C. (2024). A simple method for Eucalyptus species discrimination: FTIR spectroscopy and machine learning. Results in Chemistry, 7, 101233. https://doi.org/10.1016/j.rechem.2023.101233
  25. Lawless, H. T., & Heymann, H. (1999). Principles of Good Practice. In Food science text series (pp. 83-115). Springer US. https://doi.org/10.1007/978-1-4419-7452-5_3
  26. LeCun, Y., Bengio, Y., & Hinton, G. (2015). Deep learning. Nature, 521(7553), 436-444. https://doi.org/10.1038/nature14539
  27. Lin, S., Liu, Z., Qin, H., Jiang, L., Zhao, D., Li, Q., & Ou, Q. (2025). Developing a fast Fourier transform infrared spectroscopy system for precise and reliable grade differentiation of Gastrodia elata. Vibrational Spectroscopy, 136, 103769. https://doi.org/10.1016/j.vibspec.2025.103769
  28. Mekonnen, K. D. (2023). Fourier transform infrared spectroscopy as a tool for identifying the unique characteristic bands of lipid in oilseed components: Confirmed via Ethiopian indigenous desert date fruit. Heliyon, 9(4), e14699. https://doi.org/10.1016/j.heliyon.2023.e14699
  29. Mustafa, G., Wang, H., Liu, Y., Wang, L., Ali, M., Yao, Z., Quan, H., & He, K. (2025). Recent Advances in Spectroscopy and Machine Learning for Non-Destructive and Real-Time Detection of Mycotoxins in Cereals. Trends in Food Science & Technology, 157, 105246. https://doi.org/10.1016/j.tifs.2025.105246
  30. Naes, T., Isaksson, T., Fearn, T., & Davies, T. (2002). A user-friendly guide to multivariate calibration and classification. NIR Publications.
  31. Nasirahmadi, A., & Miraei Ashtiani, S. H. (2017). Bag-of-Feature model for sweet and bitter almond classification. Biosystems Engineering, 156, 51-60. https://doi.org/10.1016/j.biosystemseng.2017.01.008
  32. Park, H., Chung, H., Choi, S., Bahn, Y. S., & Son, J. (2024). Evaluation of exposure to cyanogenic glycosides and potential hydrogen cyanide release in commercially available foods among the Korean population. Food Chemistry, 456, 139872. https://doi.org/10.1016/j.foodchem.2024.139872
  33. Prata, J. C., & da Costa, P. M. (2024). Fourier Transform Infrared Spectroscopy Use in Honey Characterization and Authentication: A systematic review. ACS Food Science & Technology, 4(8), 1817-1828. https://doi.org/10.1021/acsfoodscitech.4c00377
  34. Rahimzadeh, M., & Attar, A. (2020). Detecting and Counting Pistachios based on Deep Learning. arXiv. https://doi.org/10.48550/ARXIV.2005.03990
  35. Romano, R., Vestergaard, J. S., Kompany-Zareh, M., & Bredie, W. L. P. (2010). Monitoring Panel Performance Within and Between Sensory Experiments by Multi-Way Analysis. In Studies in Classification, Data Analysis, and Knowledge Organization (pp. 335–342). Springer Berlin Heidelberg. https://doi.org/10.1007/978-3-642-13312-1_35
  36. Rong, D., Wang, H., Ying, Y., Zhang, Z., & Zhang, Y. (2020). Peach variety detection using VIS-NIR spectroscopy and deep learning. Computers and Electronics in Agriculture, 175, 105553. https://doi.org/10.1016/j.compag.2020.105553
  37. Salamah, N., Cantika, C. D., Nurani, L. H., & Guntarti, A. (2024). Authentication of citrus peel oils from different species and commercial products using FTIR Spectroscopy combined with chemometrics. Pharmacia, 71, 1-7. https://doi.org/10.3897/pharmacia.71.e118789
  38. Sheahata, D., ElGamal, R., Radwan, S., & Elmasry, G. (2025). Detection of impurities on faba bean (Vicia faba) by NIR spectroscopy. Journal of Plant Production Sciences, 14(1), 43-53. https://doi.org/10.21608/jpps.2025.390691.1013
  39. Shen, C., Wang, R., Nawazish, H., Wang, B., Cai, K., & Xu, B. (2024). Machine vision combined with deep learning–based approaches for food authentication: An integrative review and new insights. Comprehensive Reviews in Food Science and Food Safety, 23(6), e13785. https://doi.org/10.1111/1541-4337.70054
  40. Sipos, L., Nyitrai, Á., Hitka, G., Friedrich, L. F., & Kókai, Z. (2021). Sensory Panel Performance Evaluation Comprehensive Review of Practical Approaches. Applied Sciences, 11(24), 11977. https://doi.org/10.3390/app112411977
  41. Sluijterman, L., Cator, E., & Heskes, T. (2025). Likelihood-ratio-based confidence intervals for neural networks. Machine Learning, 114(4), 2319-2347. https://doi.org/10.1007/s10994-024-06639-3
  42. Syafri, S., Jaswir, I., Yusof, F., Rohman, A., & Hamidi, D. (2022). The use of GC-MS and FTIR spectroscopy coupled with multivariate analysis for the detection of red ginger oil adulteration. Rasayan Journal of Chemistry, 15(4), 2231-2236. https://doi.org/10.31788/rjc.2022.1547039
  43. Tachie, C. Y. E., Obiri-Ananey, D., Alfaro-Cordoba, M., Tawiah, N. A., & Aryee, A. N. A. (2024). Classification of oils and margarines by FTIR spectroscopy in tandem with machine learning. Food Chemistry, 431, 137077. https://doi.org/10.1016/j.foodchem.2023.137077
  44. Taş, N. G., & Gökmen, V. (2017). Phenolic compounds in natural and roasted nuts and their skins: a brief review. Current Opinion in Food Science, 14, 103-109. https://doi.org/10.1016/j.cofs.2017.03.001
  45. Torres-Rodríguez, I., Sánchez, M. T., Entrenas, J. A., Vega-Castellote, M., Garrido-Varo, A., & Pérez-Marín, D. (2022). Hyperspectral Imaging for the Detection of Bitter Almonds in Sweet Almond Batches. Applied Sciences, 12(10), 4842. https://doi.org/10.3390/app12104842
  46. Unuvar, A., Boyaci, I. H., & Koksel, H. (2021). A novel approach for rapid discrimination of common and durum wheat flours using spectroscopic analyses combined with chemometrics. Journal of Cereal Science, 100, 103269. https://doi.org/10.1016/j.jcs.2021.103269
  47. Uzer, M. S. (2025). Deep Learning-Based Classification Consisting of Pre-Trained Models and Proposed Model Using K-Fold Cross-Validation for Pistachio Species. Applied Sciences, 15(8), 4516. https://doi.org/10.3390/app15084516
  48. Yuan, Y., Ji, Z., Fan, Y., Xu, Q., Shi, C., Lyu, J., & Ertbjerg, P. (2025). Deep learning-assisted fluorescence spectroscopy for food quality and safety analysis. Trends in Food Science & Technology, 156, 104821. https://doi.org/10.1016/j.tifs.2024.104821
  49. Zahedi, A., Shafei, A. M., & Shamsi, M. (2023). Application of hybrid robotic systems in crop harvesting: Kinematic and dynamic analysis. Computers and Electronics in Agriculture, 107724. https://doi.org/10.1016/j.compag.2023.107724
  50. Zhang, L., Boom, R. M., & Ma, Y. (2025). Machine Learning in Automated Food Processing: A Mini Review. Annual Review of Food Science and Technology, 16(1), 25-37. https://doi.org/10.1146/annurev-food-111523-122039
  51. Ziani, I., Bouakline, H., El Guerraf, A., El Bachiri, A., Marie-Laure Fauconnier, & Sher, F. (2025). Integrating AI and advanced spectroscopic techniques for precision food safety and quality control. Trends in Food Science & Technology, 156, 104850. https://doi.org/10.1016/j.tifs.2024.104850
Send comment about this article
Enter Name.
Enter a valid email address.
Enter a vaid affiliation.
Enter comments (At leaset 10 words)
CAPTCHA Image
Enter Security Code Correctly.

Articles in Press, Accepted Manuscript
Available Online from 30 May 2026

  • Receive Date 09 February 2026
  • Revise Date 12 March 2026
  • Accept Date 13 April 2026
  • First Publish Date 30 May 2026