Classification of defect types for coffee beans using image processing and machine learning
Abstract
Indonesia is one of the world’s major coffee producers, and its greenbeans are exported to many countries.. Greenbean production in Indonesia increased from 2023 to 2025. Export volume also increased during this period, although it slightly declined in 2025 compared with 2024. For 2026, both greenbean production and exports are projected to increase, supported by favorable weather conditions in the South Sumatra and Lampung regions. During greenbean processing, the separation of defective beans is crucial for producing high-quality coffee. In manual sorting, workers become tired and fatigued over time, which may reduce sorting accuracy. This study aims to develop a rapid method for identifying defective beans based on image features analyzed using machine learning. The samples were grouped into five categories: normal, black, broken, black, (damaged by) insect, and undersize beans. The images were processed and some physical features were extracted and used for training and testing machine learning algorithms. The results showed that the model achieved accuracies of more than 90% using only 600 greenbean samples