Recognition of Pistachio Varieties Based on Machine Vision, Gabor Filters, and Genetic Algorithm

Document Type : Research Paper

Author

Department of Electrical Engineering, Faculty of Electrical and Computer Engineering, Sirjan University of Technology, Sirjan, Iran.

10.22059/ijbse.2025.389674.665585

Abstract

This study proposes an efficient and novel method for recognizing pistachio varieties by leveraging Gabor filters for feature extraction and a genetic algorithm for feature selection, aiming to enhance classification accuracy and speed. Unlike conventional approaches that focus on individual processing of pistachio kernels—which, despite high accuracy, are time-consuming and computationally demanding—the proposed method employs holistic processing of images containing multiple pistachios, thereby significantly accelerating the recognition process. Key textural and shape-based features are initially extracted using Gabor filters. Subsequently, the genetic algorithm is applied to select optimal features and reduce data redundancy. The refined feature set is then classified using the K-Nearest Neighbor (KNN) algorithm. Experiments conducted on a dataset of 1,000 sub-images covering five common pistachio types (Akbari, Ahmad Aghaei, Kaleh Ghouchi, Fandoghi, and Badami) yielded an average classification accuracy of 99.5%. In comparison with deep learning models, the proposed method demonstrates competitive performance while requiring no extensive training phase or high computational resources. This results in a faster and more resource-efficient implementation, making it particularly suitable for industrial applications, especially in automated pistachio processing and packaging systems. The proposed method contributes to the automation of agricultural workflows, reducing both processing time and labor costs, and offers a practical solution for real-time classification in resource-constrained environments.

Keywords

Main Subjects


 

Introduction

Pistachio is one of Iran’s most significant non-oil export products, contributing substantially to the country's economy. Iran ranks among the top global pistachio producers, with several varieties, including Ahmad Aghaei, Fandoghi, Akbari, Badami, and Kalleh Ghouchi, dominating the market. Given the economic and industrial importance of pistachios, accurate classification of different types is crucial for improving quality control, optimizing processing efficiency, and minimizing waste. Traditional classification methods face challenges in identifying pistachio types with high accuracy. Therefore, leveraging advanced image processing, deep learning, and machine vision techniques has become a promising research direction. Among various texture analysis techniques, Gabor filters have proven effective in extracting meaningful patterns from images, offering a computationally efficient alternative to deep learning-based approaches.

Methods

This study proposes a machine vision-based method for pistachio classification using texture analysis. The approach consists of several steps:

  1. Image Acquisition & Preprocessing: High-resolution color images of bulk pistachios (3498 × 2542 pixels) were acquired using a scanner at 300 dpi. Images were converted to grayscale, and sub-images (512 × 512 pixels) were extracted for analysis.
  2. Feature Extraction: A Gabor filter bank with five scales and four orientations (total of 20 filters) was applied to the sub-images. The mean and standard deviation of filtered images were computed, resulting in a 40-dimensional feature vector.
  3. Feature Selection: A genetic algorithm (GA) was employed to optimize feature selection, reducing the initial 40 features to 18 while preserving classification performance.
  4. Classification: The selected features were input to a K-nearest neighbor (KNN) classifier using the χ² distance metric. A dataset comprising 1000 sub-images from five pistachio varieties was used for evaluation.

Results

The proposed method achieved an overall classification accuracy of 99.5%, significantly outperforming a reference method (Shamsi-Goshki et al., 2013) with 94.8% accuracy. The genetic algorithm effectively reduced computational complexity while maintaining classification performance. Performance metrics, including precision, recall, and F1-score, confirmed the superiority of the proposed approach over previous methods. Additionally, the proposed bulk classification approach is more suitable for industrial applications compared to conventional methods that classify individual pistachios.

Conclusions

This study demonstrates the effectiveness of combining Gabor filters, genetic algorithms, and KNN classification for pistachio type recognition. The approach achieves high accuracy with significantly lower computational costs than deep learning models, making it suitable for large-scale industrial applications. Future research can explore integrating deep learning with texture-based methods for further improvements.

Author Contributions

Conceptualization, methodology, software, validation, formal analysis, investigation, resources, data curation, writing—original draft preparation, writing—review and editing, visualization, supervision, and project administration by Asma Shams-Kermani. Author has read and agreed to the published version of the manuscript.

Data Availability Statement

Data available on request from the authors.

Acknowledgments

The authors would like to thank all participants of the present study.

Ethical considerations

Ethical approval was not required for this study as it did not involve human or animal participants, or any sensitive personal data.

Conflict of interest

The author declares no conflict of interest.

 

 

Abbaszadeh, M., Rahimifard, A., Eftekhari, M., Ghayoumi Zadeh, H., Fayazi, A., Dini, A., & Danaeian, M. (2019). Deep learning-based classification of defective pistachios via deep autoencoder neural networks. arXiv preprint, arXiv:1906.11878. https://doi.org/10.48550/arXiv.1906.11878.
Avuçlu, E. (2023). Classification of pistachio images using VGG16 and VGG19 deep learning models. International Scientific and Vocational Studies Journal, 7(2), 79–86. https://doi.org/10.47897/bilmes.1328313.
Avuçlu, E. (2023). Classification of pistachio images with the ResNet deep learning model. Selcuk Journal of Agriculture and Food Sciences, 37(2), 291–300. https://doi.org/10.15316/SJAFS.2023.029.
Farazi, M., Abbas-Zadeh, M. J., & Moradi, H. (2017, November ). A machine vision-based pistachio sorting using transferred mid-level image representation of convolutional neural network. Paper presented at the 10th Iranian Conference on Machine Vision and Image Processing (MVIP) IEEE.  Isfahan, Iran. https://doi.org/10.1109/IRANIANMVIP.2017.8342335. 
Goldberg, D. E. (1989). Genetic algorithms in search, optimization, and machine learning. Addison-Wesley.
Ha, M. H., Tian, X. D., & Zhang, Z. R. (2005, August). Optical font recognition based on Gabor filter. In International Conference on Machine Learning and Cybernetics (ICMLC). Guangzhou, China. https://doi.org/10.1109/ICMLC.2005.1527799.
Heidary-Sharifabad, A., Zarchi, M. S., Emadi, S., & Zarei, G. (2021). An efficient deep learning model for cultivar identification of a pistachio tree. British Food Journal, 123(11), 3592–3609. https://doi.org/10.1108/BFJ-12-2020-1100.
Indra, D., Fadlillah, H. M., Kasman., & Ilmawan, L. B. (2021, December). Rice texture analysis using GLCM features. Paper presented at the 2021 International Conference on Electrical, Computer and Energy Technologies (ICECET), Cape Town, South Africa.
Jain, A. K., & Bhattacharjee, S. K. (1992). Address block location on envelopes using Gabor filters. Pattern Recognition, 25(12), 1459–1477. https://doi.org/10.1016/0031-3203(92)90144-O.
Kumar, S. S., Sigappi, A. N., Thomas, G. A., Robinson, Y. H., & Raja, S. P. (2024). Classification and analysis of pistachio species through neural embedding-based feature extraction and small-scale machine learning techniques. International Journal of Image and Graphics, 24(3), 2450032. https://doi.org/10.1142/s0219467824500323.
Liang, L., Liu, Y., & Wang, M. (2023, July). Gabor-DCTnet: A simple and efficient method for image classification. In 2023 19th International Conference on Natural Computation, Fuzzy Systems and Knowledge Discovery (ICNC-FSKD). Harbin, China. https://doi.org/10.1109/ICNC-FSKD59587.2023.10281063.
Madhavi, D., Mohammed, K. M., Jyothi, N., & Patnaik, M. R. (2019). A hybrid content-based image retrieval system using log-Gabor filter banks. International Journal of Electrical and Computer Engineering, 9(1), 237–244. https://doi.org/10.11591/ijece.v9i1.pp237-244.
Mahdavi-Jafari, S., Salehinejad, H., & Talebi, S. (2008, December). A pistachio nuts classification technique: An ANN-based signal processing scheme. Paper presented at the International Conference on Computational Intelligence for Modelling, Control and Automation (CIMCA), Vienna, Austria. https://doi.org/10.1109/CIMCA.2008.150.
Manjunath, B. S., & Ma, W. Y. (1996). Texture features for browsing and retrieval of image data. IEEE Transactions on Pattern Analysis and Machine Intelligence, 18(8), 837–842. https://doi.org/10.1109/34.531803.
Nouri-Ahmadabadi, H., Omid, M., Mohtasebi, S. S., & Firouz, M. S. (2017). Design, development, and evaluation of an online grading system for peeled pistachios equipped with machine vision technology and support vector machine. Information Processing in Agriculture, 4(4), 333–341. https://doi.org/10.1016/j.inpa.
Omid, M., Mahmoudi, A., & Omid, M. (2009). An intelligent system for sorting pistachio nut varieties. Expert Systems with Applications, 36(9), 11528–11535. https://doi.org/10.1016/j.eswa.2009.03.040.
Patel, F., Mewada, S., Degadwala, S., & Vyas, D. (2023, October). Recognition of pistachio species with transfer learning models. Paper presented at the International Conference on Self Sustainable Artificial Intelligence Systems (ICSSAS), Erode, India. https://doi.org/10.1109/ICSSAS57918.2023.10331907.
Shamsi-Goshki, A., Sariyazdi, S., Nazmabadipour, N., & Shamsi-Goshki, H. (2013). Pistachio varieties recognition based on machine vision and Gabor filters. Iranian Journal of Biosystems Engineering, 43(2), 125–131. https://doi.org/10.22059/ijbse.2013.35214. )In Persian(.
Singh, D., Taspinar, Y. S., Kursun, R., Cinar, I., Koklu, M., Ozkan, I. A., & Lee, H. N. (2022). Classification and analysis of pistachio species with pre-trained deep learning models. Electronics, 11(7), 981. https://doi.org/10.3390/electronics11070981.
Subbarao, M., Ram, G., & Varma, D. (2023, February ). Performance analysis of pistachio species classification using support vector machine and ensemble classifiers. Paper presented at the International Conference on Recent Trends in Electronics and Communication (ICRTEC), Mysore, India. https://doi.org/10.1109/ICRTEC56977.2023.10111889.
Wang, M., Gao, L., Huang, X., Jiang, Y., & Gao, X. (2019). A texture classification approach based on the integrated optimization for parameters and features of Gabor filter via hybrid ant lion optimizer. Applied Sciences, 9(11), 2173. https://doi.org/10.3390/app9112173.