Quality and Defect Inspection of Green Coffee Beans Using a Computer Vision System
Abstract
:1. Introduction
- An accurate and efficient machine vision integrated with an Arduino board for automatic quality and defects inspection of green coffee beans.
- A source code programmed in MATLAB to process any amount of green coffee beans present in the images.
- A statistical analysis of the quality and defects of green coffee beans to identify the best coffee beans with different physical characteristics.
2. Background
2.1. Green Coffee Bean Defects
2.2. Machine Vision
2.2.1. Image Acquisition
2.2.2. Image Processing
2.2.3. Statistical Analysis
2.3. The k-Nearest Neighbor Method
2.4. Proposed System
3. Materials and Methods
3.1. Acquisition Stage
3.2. Image Processing Stage
3.2.1. Image Pre-Processing
3.2.2. Segmentation
3.2.3. Segmentation Using Color Spaces
3.2.4. Feature Extraction
- Surface Area: this quantity refers to the total surface area of the coffee beans and it is particularly useful for the distinction of small and immature beans.
- Roundness: The roundness of coffee beans is defined as follows [38]:
- Area Relation or Color Feature: this quantity is simply a ratio between the damaged surface area (A1) and the total surface area (A2) of the coffee beans:This feature is very useful to distinguish coffee beans containing external defects related to their color such as sour or black coffee beans. This quantity value tends to 0 for coffee beans that do not have any external defect on their surface since the damaged surface area tends to 0 by segmenting the image in the color spaces. MATLAB label functions were used to label the individual coffee beans in those images containing more than one coffee bean. Next, the classification algorithm is applied individually.
- Eccentricity: this quantity characterizes the shape of a conic section; it is particularly useful when talking about ellipses. The eccentricity of a circle is 0 and the eccentricity of an ellipse which is not a circle is greater than 0 but less than 1. The eccentricity value is particularly useful for the distinction of very long berry coffee beans and broken beans, which have similar roundness values.
3.3. Classification Development
4. Results and Analysis
4.1. Classification Accuracy of the Machine Vision
4.2. Classification Accuracy of the Machine Vision Using Different k Values
4.3. Standard Deviation of the Accuracy Percentage
5. Conclusions
Author Contributions
Funding
Acknowledgments
Conflicts of Interest
References
- Giacalone, D.; Degn, T.K.; Yang, N.; Liu, C.; Fisk, I.; Münchow, M. Common roasting defects in coffee: Aroma composition, sensory characterization and consumer perception. Food Qual. Prefer. 2019, 71, 463–474. [Google Scholar] [CrossRef] [Green Version]
- Bhumiratana, N.; Adhikari, K.; Chambers, E. Evolution of sensory aroma attributes from coffee beans to brewed coffee. LWT Food Sci. Technol. 2011, 44, 2185–2192. [Google Scholar] [CrossRef] [Green Version]
- Vithu, P.; Moses, J.A. Machine vision system for food grain quality evaluation: A review. Trends Food Sci. Technol. 2016, 56, 13–20. [Google Scholar] [CrossRef]
- Razmjooy, N.; Mousavi, B.S.; Soleymani, F. A real-time mathematical computer method for potato inspection using machine vision. Comput. Math. Appl. 2012, 63, 268–279. [Google Scholar] [CrossRef] [Green Version]
- Baigvand, M.; Banakar, A.; Minaei, S.; Khodaei, J.; Behroozi-Khazaei, N. Machine vision system for grading of dried figs. Comput. Electron. Agric. 2015, 119, 158–165. [Google Scholar] [CrossRef]
- Leme, D.S.; da Silva, S.A.; Barbosa, B.H.G.; Borém, F.M.; Pereira, R.G.F.A. Recognition of coffee roasting degree using a computer vision system. Comput. Electron. Agric. 2019, 156, 312–317. [Google Scholar] [CrossRef]
- Cavallo, D.P.; Cefola, M.; Pace, B.; Logrieco, A.F.; Attolico, G. Non-destructive and contactless quality evaluation of table grapes by a computer vision system. Comput. Electron. Agric. 2019, 156, 558–564. [Google Scholar] [CrossRef]
- Su, Q.; Kondo, N.; Li, M.; Sun, H.; Al Riza, D.F.; Habaragamuwa, H. Potato quality grading based on machine vision and 3D shape analysis. Comput. Electron. Agric. 2018, 152, 261–268. [Google Scholar] [CrossRef]
- Constante, P.; Gordon, A.; Chang, O.; Pruna, E.; Acuna, F.; Escobar, I. Artificial Vision Techniques to Optimize Strawberry’s Industrial Classification. IEEE Lat. Am. Trans. 2016, 14, 2576–2581. [Google Scholar] [CrossRef]
- Momin, M.A.; Yamamoto, K.; Miyamoto, M.; Kondo, N.; Grift, T. Machine vision based soybean quality evaluation. Comput. Electron. Agric. 2017, 140, 452–460. [Google Scholar] [CrossRef]
- Habib, M.T.; Majumder, A.; Jakaria, A.Z.M.; Akter, M.; Uddin, M.S.; Ahmed, F. Machine vision based papaya disease recognition. J. King Saud Univ. Comput. Inf. Sci. 2018. [Google Scholar] [CrossRef]
- Sofu, M.M.; Er, O.; Kayacan, M.C.; Cetişli, B. Design of an automatic apple sorting system using machine vision. Comput. Electron. Agric. 2016, 127, 395–405. [Google Scholar] [CrossRef]
- Kurtulmuş, F.; Alibaş, İ.; Kavdır, I. Classification of pepper seeds using machine vision based on neural network. Int. J. Agric. Biol. Eng. 2016, 9, 51–62. [Google Scholar] [CrossRef]
- Pace, B.; Cefola, M.; Da Pelo, P.; Renna, F.; Attolico, G. Non-destructive evaluation of quality and ammonia content in whole and fresh-cut lettuce by computer vision system. Food Res. Int. 2014, 64, 647–655. [Google Scholar] [CrossRef] [PubMed]
- Zheng, C.; Sun, D.-W.; Zheng, L. Recent developments and applications of image features for food quality evaluation and inspection—A review. Trends Food Sci. Technol. 2006, 17, 642–655. [Google Scholar] [CrossRef]
- Arribas, J.I.; Sánchez-Ferrero, G.V.; Ruiz-Ruiz, G.; Gómez-Gil, J. Leaf classification in sunflower crops by computer vision and neural networks. Comput. Electron. Agric. 2011, 78, 9–18. [Google Scholar] [CrossRef]
- Ali Jan Ghasab, M.; Khamis, S.; Mohammad, F.; Jahani Fariman, H. Feature decision-making ant colony optimization system for an automated recognition of plant species. Expert Syst. Appl. 2015, 42, 2361–2370. [Google Scholar] [CrossRef]
- Tian, Y.; Yang, G.; Wang, Z.; Wang, H.; Li, E.; Liang, Z. Apple detection during different growth stages in orchards using the improved YOLO-V3 model. Comput. Electron. Agric. 2019, 157, 417–426. [Google Scholar] [CrossRef]
- Matiacevich, S.; Silva, P.; Enrione, J.; Osorio, F. Quality assessment of blueberries by computer vision. Procedia Food Sci. 2011, 1, 421–425. [Google Scholar] [CrossRef] [Green Version]
- de Oliveira, E.M.; Leme, D.S.; Barbosa, B.H.G.; Rodarte, M.P. A computer vision system for coffee beans classification based on computational intelligence techniques. J. Food Eng. 2016, 171, 22–27. [Google Scholar] [CrossRef]
- Pérez, H.; Carlos, J.; Ortiz, M.; Manuel, S.; Llano, M.; Enrique, G.; Sáenz, B.; de Jesús, K.; Pérez, J.S.B. Clasificación de los frutos de café según su estado de maduración y detección de la broca mediante técnicas de procesamiento de imágenes. Prospectiva 2016, 14, 15. [Google Scholar] [CrossRef]
- Giraldo, R.; Jimena, P.; Uribe, S.; Rodrigo, J.; Tascón, O.C.E. Identificación y clasificación de frutos de café en tiempo real a través de la medición de color. Cenicafé 2010, 61, 315–326. [Google Scholar]
- Hernández, J.; Prieto, F. Clasificación de Granos de Café usando FPGA. Ing. Compet. 2011, 7, 35–42. [Google Scholar] [CrossRef]
- Pinto, C.; Furukawa, J.; Fukai, H.; Tamura, S. Classification of Green coffee bean images basec on defect types using convolutional neural network (CNN). In Proceedings of the 2017 International Conference on Advanced Informatics, Concepts, Theory, and Applications (ICAICTA), Denpasar, Indonesia, 16–18 August 2017; pp. 1–5. [Google Scholar]
- Arboleda, E.R.; Fajardo, A.C.; Medina, R.P. Classification of coffee bean species using image processing, artificial neural network and k nearest neighbors. In Proceedings of the 2018 IEEE International Conference on Innovative Research and Development (ICIRD), Bangkok, Thailand, 11–12 May 2018; pp. 1–5. [Google Scholar]
- Condori, R.H.M.; Humari, J.H.C.; Portugal-Zambrano, C.E.; Gutierrez-Caceres, J.C.; Beltran-Castanon, C.A. Automatic classification of physical defects in green coffee beans using CGLCM and SVM. In Proceedings of the 2014 XL Latin American Computing Conference (CLEI), Montevideo, Uruguay, 15–19 September 2014; pp. 1–9. [Google Scholar]
- Arboleda, E.R.; Fajardo, A.C.; Medina, R.P. An image processing technique for coffee black beans identification. In Proceedings of the 2018 IEEE International Conference on Innovative Research and Development (ICIRD), Bangkok, Thailand, 11–12 May 2018; pp. 1–5. [Google Scholar]
- Apaza, R.G.; Portugal-Zambrano, C.E.; Gutierrez-Caceres, J.C.; Beltran-Castanon, C.A. An approach for improve the recognition of defects in coffee beans using retinex algorithms. In Proceedings of the 2014 XL Latin American Computing Conference (CLEI), Montevideo, Uruguay, 15–19 September 2014; pp. 1–9. [Google Scholar]
- Franca, A.S.; Mendonça, J.C.F.; Oliveira, S.D. Composition of green and roasted coffees of different cup qualities. LWT Food Sci. Technol. 2005, 38, 709–715. [Google Scholar] [CrossRef]
- Bhargava, A.; Bansal, A. Fruits and vegetables quality evaluation using computer vision: A review. J. King Saud Univ. Comput. Inf. Sci. 2018. [Google Scholar] [CrossRef]
- Patrício, D.I.; Rieder, R. Computer vision and artificial intelligence in precision agriculture for grain crops: A systematic review. Comput. Electron. Agric. 2018, 153, 69–81. [Google Scholar] [CrossRef] [Green Version]
- Hong, H.; Yang, X.; You, Z.; Cheng, F. Visual quality detection of aquatic products using machine vision. Aquac. Eng. 2014, 63, 62–71. [Google Scholar] [CrossRef]
- Blasco, J.; Munera, S.; Aleixos, N.; Cubero, S.; Molto, E. Machine Vision-Based Measurement Systems for Fruit and Vegetable Quality Control in Postharvest. Adv. Biochem. Eng. Biotechnol. 2017, 161, 71–91. [Google Scholar] [CrossRef]
- Rehman, T.U.; Mahmud, M.S.; Chang, Y.K.; Jin, J.; Shin, J. Current and future applications of statistical machine learning algorithms for agricultural machine vision systems. Comput. Electron. Agric. 2019, 156, 585–605. [Google Scholar] [CrossRef]
- Zhang, S.; Li, X.; Zong, M.; Zhu, X.; Wang, R. Efficient kNN Classification With Different Numbers of Nearest Neighbors. IEEE Trans. Neural Netw. Learn. Syst. 2018, 29, 1774–1785. [Google Scholar] [CrossRef]
- Singh, A.; Pandey, B. An euclidean distance based KNN computational method for assessing degree of liver damage. In Proceedings of the 2016 International Conference on Inventive Computation Technologies (ICICT), Coimbatore, India, 26–27 August 2016; pp. 1–4. [Google Scholar]
- Farmer, M.E.; Jain, A.K. A wrapper-based approach to image segmentation and classification. IEEE Trans. Image Process. 2005, 14, 2060–2072. [Google Scholar] [CrossRef] [PubMed]
- Arias, M.; Manuel, A.; Sierra Ruiz, J.A. Procesamiento de imágenes para la clasificación de café verde. Bachelor’s Thesis, Pontificia Universidad Javeriana, Bogotá, Colombia.
Component | Characteristics |
---|---|
Arduino Mega2560 | AT mega 2560 microcontroller, 16 MHz |
Canon PowerShot SX420 camera | 20 megapixels, sensor CCD |
I2C LCD 20 × 4 | 20 × 4 lines, 16 pins |
Button | Normally open |
Resistors, LEDs | Different values |
EEPROM memory 24LC32 | 32 Kbit |
Green coffee beans | 544 grains, Arabica coffee |
Images of coffee beans | 220 images, RGB, 20 megapixels |
Actual Quality | Predicted Quality | ||||
---|---|---|---|---|---|
Very Low | Low | High | Very High | % Accuracy | |
Very low | 234 | 7 | 0 | 0 | 97.10% |
Low | 9 | 181 | 5 | 0 | 92.82% |
High | 0 | 9 | 189 | 7 | 92.20% |
Very high | 0 | 0 | 9 | 296 | 97.05% |
Average accuracy | 94.79% |
Actual Defects | Predicted Defects | ||||||
---|---|---|---|---|---|---|---|
Normal | Black | Sour | Broken | Very Long Berry | Small | Accuracy | |
Normal | 157 | 0 | 0 | 2 | 2 | 0 | 97.52% |
Black | 0 | 164 | 5 | 0 | 0 | 0 | 97.04% |
Sour | 0 | 13 | 152 | 0 | 0 | 0 | 92.12% |
Broken | 9 | 0 | 0 | 157 | 0 | 0 | 94.58% |
Very long berry | 3 | 0 | 0 | 0 | 151 | 0 | 98.05% |
Small | 3 | 0 | 0 | 0 | 3 | 125 | 95.42% |
Average accuracy | 95.78% |
k-Value | Average Accuracy of Quality Evaluation | Average Accuracy of Defect Type Evaluation |
---|---|---|
3 | 90% | 92% |
5 | 92% | 93% |
10 | 94.99% | 95.66% |
20 | 93% | 92% |
Test | Standard Deviation |
---|---|
Quality inspection | 1.87% |
Defect type inspection | 2.03% |
© 2019 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 (http://creativecommons.org/licenses/by/4.0/).
Share and Cite
García, M.; Candelo-Becerra, J.E.; Hoyos, F.E. Quality and Defect Inspection of Green Coffee Beans Using a Computer Vision System. Appl. Sci. 2019, 9, 4195. https://doi.org/10.3390/app9194195
García M, Candelo-Becerra JE, Hoyos FE. Quality and Defect Inspection of Green Coffee Beans Using a Computer Vision System. Applied Sciences. 2019; 9(19):4195. https://doi.org/10.3390/app9194195
Chicago/Turabian StyleGarcía, Mauricio, John E. Candelo-Becerra, and Fredy E. Hoyos. 2019. "Quality and Defect Inspection of Green Coffee Beans Using a Computer Vision System" Applied Sciences 9, no. 19: 4195. https://doi.org/10.3390/app9194195