Contribution to the Automatic Detection of Coffee Plant Diseases through Image Processing and Machine Learning: A Study of Infected Leaves in Western Ivory Coast ()
1. Introduction
Ivory Coast, a country in West Africa, has an economy mainly based on agriculture, with the central and western regions largely dedicated to coffee cultivation.
Tonkpi region, located in the west of the country, is one of the key areas for coffee cultivation. The local population has therefore based its hopes and economies on this crop. However, coffee plants can be affected by a range of fungal diseases, insect-related damage, and physiological disorders, which may result in substantial production losses and can be difficult to distinguish visually under field conditions [1] [2]. Faced with this situation, farmers resort to solutions such as visual observation followed by random diagnosis, or by contacting agents from the CNRA (National Center for Agricultural Research) or ANADER (National Agency for Rural Development), whose services are sometimes costly. Furthermore, these approaches have several limitations: they are subjective, require specialized expertise that is difficult to mobilize for all affected plantations, and do not allow for efficient disease diagnosis.
Several research projects have already focused on automating agricultural diagnostics to overcome these limitations. Among others, we can cite the work of [3], which marked a significant advance in coffee disease detection by proposing a hybrid approach combining texture analysis (GLCM) and color analysis (HSV) in Côte d’Ivoire. His contribution demonstrated that automated classification using SVM can achieve robust accuracy in identifying pathological symptoms, paving the way for more effective diagnostic systems. In parallel, the research of [4] [5] took a decisive step towards practical application with the development of the “Coffee Companion” mobile tool in Canada. By leveraging the power of convolutional neural networks (CNNs) such as InceptionV3, this work demonstrated that automated smartphone-based diagnostics can achieve 92.1% accuracy, thus offering an accessible field solution for the early detection of coffee diseases.
Despite these advances, the specific application to coffee culture in the particular geographical context of Tonkpi remains poorly documented, especially with regard to the systematic comparison of multimodal descriptors and lightweight Deep Learning models.
Therefore, a central question arises: how to design a technological tool that is accessible, precise and automated, capable of providing a reliable diagnosis of coffee pathologies under the real growing conditions of the Tonkpi region?
Our study therefore proposes a system based on digital image processing to automatically detect and characterize coffee leaf diseases. The system combines image segmentation techniques, multimodal descriptor extraction, and machine learning and deep learning classification, thus offering a comprehensive and efficient solution.
The overall objective of this work is to design and validate an intelligent system to assist in the automatic detection of coffee foliar diseases by analyzing and processing digital images acquired in the Tonkpi region.
To achieve this goal, we have defined the following specific objectives:
To create a database of images of healthy and diseased leaves representative of the actual growing conditions in the Tonkpi region;
Implement and compare two methods of automatic segmentation of infected areas: Otsu thresholding and segmentation by K-means;
Extract and analyze quantitative descriptors characterizing infected areas of leaves;
Compare the performance of three classification approaches: k-NN, Random Forest and CNN by Transfer Learning (SqueezeNet);
To propose the most efficient classification technique for future integration into a decision support tool for farmers and field agents;
Our work will be structured around four parts, namely: a literature review, the materials and methods used to design our model, the results and discussion of the results obtained, and finally the conclusion of all the work carried out.
1.1. Coffee Plant Diseases and Visible Leaf Disorders
Coffee leaves can exhibit symptoms associated with fungal diseases, insect damage, and non-infectious physiological disorders. Because several of these symptoms may overlap visually, the present study treats the six classes as image-based symptom categories rather than as laboratory-confirmed pathogen diagnoses. Coffee leaf rust is caused by the obligate biotrophic fungus Hemileia vastatrix. Typical symptoms include yellow to orange lesions on the leaf surface and orange-yellow sporulation, particularly on the abaxial surface. It also caused devastating epidemics in Latin America between 2012 and 2015, destroying more than 50% of crops in some countries [6] [7]. In Côte d’Ivoire, it represents the main phytosanitary threat to coffee plantations. Symptoms include pale yellow spots appearing on the upper surface of leaves, corresponding to orange sporulating pustules on the underside. At maturity, the lesions turn brown and cause premature defoliation of the trees.
Figure 1 shows the symptoms of coffee leaves affected by coffee leaf rust.
Figure 1. (a) Orange sporulating lesions on a coffee branch with all leaves infected; (b) First symptoms of infection manifesting as small yellowish lesions on the underside of a coffee leaf [8] [9].
Coffee berry anthracnose (CBD – Coffee Berry Disease), caused by Colletotrichum kahawae is one of the most destructive fungal diseases in East and Central Africa. It affects developing berries, causing blackening and mummification, but can also produce leaf lesions under epidemic conditions. On coffee leaves, symptoms appear as circular to elliptical necrotic spots with a chlorotic halo, resembling cercospora leaf spot.
Cercospora leaf spot of coffee trees, caused by Cercospora Coffee leaf miner disease (Coffeicola Berk) is a foliar and fruit disease endemic to African coffee-growing areas. It produces circular spots with a grayish center surrounded by a reddish-brown halo, very characteristic but which can be confused with rust lesions in their early stages. The coffee leaf miner (Leucoptera Coffeella) is a pest insect that burrows winding galleries in the leaf mesophyll, creating irregular translucent spots visible through the paper.
1.2. Agricultural Context of the Tonkpi Region
Tonkpi region is located in the far west of Côte d’Ivoire, between latitudes 7˚ and 8˚ North and longitudes 7˚ and 8˚ West. It is bordered to the west by Guinea and Liberia, to the north by the Bafing region, to the east by the Cavally region, and to the south by the Guémon region. The landscape is dominated by mountain ranges, including Mount Nimba (1752 m), the highest point in Côte d’Ivoire, and Mount Dent de Man (881 m). The region has a monomodal climate with two seasons: a rainy season from April to October and a dry season from November to March. Average annual rainfall is 1632 mm, with an average temperature of around 25˚C [10]-[13]. This microclimate, combined with deep ferrallitic soils rich in organic matter, creates conditions particularly favorable to tropical perennial crops, especially coffee.
1.3. Economic Importance of Coffee
Coffee is one of the main export crops, accounting for 60% of the country’s export earnings [14]-[16]. In the Tonkpi region, it dominates cultivated agricultural land [17] [18].
In the Tonkpi region, foliar diseases are a significant cause of production losses, the impact of which is often underestimated by those working in the field. Indeed, many farmers are unaware of the very existence of these infections. Among those who do notice the signs, many attribute the observed symptoms to a natural process related to the leaf life cycle, without recognizing them as a sign of disease. Furthermore, producers pay more attention to the damage caused by termites, which also represent one of the limiting factors for coffee yields in the region [19]-[21].
1.4. Digital Image Processing Applied to Agriculture
Digital image processing is a set of techniques used to extract, analyze, and interpret information from images acquired by electronic sensors. A standard processing approach generally includes the following steps: acquisition, preprocessing (noise reduction, normalization), segmentation (isolation of regions of interest), feature extraction (descriptors), and classification or interpretation. Applied to plant pathology, this approach allows for the automatic detection of damaged areas on leaves, the quantification of their extent, and the identification of the corresponding disease. Since the pioneering work of [22] [23] on crop segmentation using vegetation indices, the field has seen continuous progress, driven by the widespread adoption of high-resolution smartphones and advances in machine learning [24] [25].
A digital image is represented by a three-dimensional matrix of pixels, each pixel being described by its values in a given color space. The RGB (Red-Green-Blue) color space is a color representation model widely used in digital imaging. It is based on the combination of three primary spectral components: red (700.0 nm), green (546.1 nm), and blue (435.8 nm), whose superposition in varying proportions allows for the reproduction of the entire visible color spectrum [26] [27]. The HSV (Hue, Saturation, Value) color space offers a representation closer to human color perception and exhibits better invariance to variations in lighting. Hue
(H) encodes pure color independently of brightness, making it particularly well-suited for characterizing leaf lesions, where color is diagnostic.
1.4.1. Comparison of Segmentation Approaches
Numerous comparative studies have shown that the choice of segmentation method has a decisive impact on the performance of the processing chain [28] [29]. They evaluated 40 thresholding methods on images of various types and concluded that no universal method systematically outperforms the others: the optimal choice depends on the characteristics of the image corpus (contrast, noise, colorimetric distribution). In the specific context of phytopathology, [30] [31] showed that K-means segmentation Multispectral generally produces more accurate masks than greyscale thresholding for lesions with diffuse edges (chlorosis, deficiencies), while Otsu remains competitive for sharp necrosis with high contrast.
1.4.2. Color and Chrominance Descriptors
The color descriptors quantify the colorimetric distribution of infected areas in the RGB and HSV spaces. There are seven of them, but the four most discriminating descriptors in this family are: pct_necrose_R, the necrosis rate detected via the red channel, which quantifies the surface of the leaf exhibiting spectral characteristics of dead tissue; r_moy, the average value of the red channel in the masked area; r_std, the standard deviation of the red channel, measuring the dispersion of red colors; and deseq_RG, the red-green chromatic imbalance, the more the leaf loses its green in favor of brown/red, the more pronounced this imbalance is.
1.4.3. Advantages and Limitations of Existing Approaches
Analysis of the literature provides a nuanced overview of existing approaches to automated detection of foliar diseases.
Classical methods with manual characteristics (colorimetric, textural, and geometric descriptors coupled with k-NN, SVM, or Random Forest classifiers) have the advantage of being interpretable, data-efficient, and deployable on resource-constrained embedded systems. [32]-[34] Their relevance is illustrated by achieving 93.75% accuracy in detecting coffee tree rust using a simple fuzzy inference system based on the GCC index. However, their main limitations lie in their dependence on the quality of prior segmentation, their sensitivity to acquisition conditions, and their generally lower performance compared to CNNs on large databases.
Deep learning approaches (CNN, Transfer Learning) outperform classical methods under controlled conditions, with classification rates exceeding 95% on PlantVillage for many architectures identified by [35] [36]. However, they require large volumes of annotated data, significant computing resources, and offer limited interpretability, hindering their adoption in the field. Furthermore, their performance degrades considerably outside the controlled training environment, as public reference datasets are mostly composed of images from controlled environments, which are not very representative of tropical African crops [37]-[40].
2. Materials and Methods
Tonkpi region, located in western Côte d’Ivoire, formed the geographical framework for our data collection. To ensure the diversity and representativeness of our image databases, we photographed infected and healthy coffee leaves in four distinct locations within the region between January 9th and 28th, 2026. The first location was the village of Kassiapleu, in the sub-prefecture of Man, the regional capital. The second was the village of Bloleu, located in the sub-prefecture of Songouiné, northwest of Man. The third was the village of Mangouin-Yrongouin, in the sub-prefecture of Biankouma, to the north. Finally, the fourth was the village of Douèlé, in the sub-prefecture of Logoualé, southeast of Man.
Figure 2 shows the four sub-prefectures as well as the sampling points of our images.
Figure 2. Sampling map of the four sub-prefectures of the Tonkpi region where we collected our data.
To ensure consistent image quality, a rigorous protocol was established and followed throughout our collections. The leaves were photographed directly on the plants, without detachment, to preserve their natural state. A uniform white background was placed behind each leaf to minimize background noise, and the camera was positioned perpendicular to the leaf surface at a fixed distance of 20 cm. It’s also worth noting that the images were captured in natural light and without flash to preserve the colors of both damaged and healthy tissue.
The images were acquired using a Tecno Spark 20C smartphone equipped with a 50 MP AI Camera. This high-resolution sensor incorporates embedded artificial intelligence algorithms that enable automatic optimization of exposure, white balance, and digital noise reduction. We chose a smartphone to demonstrate that the system we intend to develop can be deployed with equipment accessible to field agents and farmers without requiring significant investment.
2.1. Field Data Collection and Healthy/Sick Classification Criteria
We collected leaf images without prior knowledge of the specific diseases that can affect coffee leaves. Distinguishing between healthy and diseased leaves was based on a simple and objective visual criterion: the color of the leaf blade. A healthy coffee leaf logically displays a uniform green hue. Consequently, any leaf exhibiting a color other than green (yellowing, browning, blackening, orange) or a visible structural abnormality (spots, galleries, pustules, necrosis, deformations) was considered diseased. This approach allowed us to collect a comprehensive and unbiased collection of leaves displaying symptoms of disease.
Once the raw image database had been compiled, the images initially classified as diseased were assigned to symptom-based categories using predefined visual criteria derived from the phytopathological literature. The initial categorization was assisted by a conversational artificial intelligence system (Claude, Anthropic) configured to provide phytopathological descriptions of the observed symptoms. The resulting suggestions were not considered laboratory-confirmed diagnoses. The categories were subsequently compared with descriptions available in established coffee-disease references and image datasets, including JMuBEN/JMuBEN2 [41] [42], with particular attention to the characteristic visual features of rust, Cercospora, anthracnose-like symptoms, leaf miner damage, and healthy leaves. The final labels used in the present machine-learning experiments therefore represent image-based symptom categories. No claim of laboratory confirmation of the causal pathogen is made from the photographs alone.
2.1.1. Dataset Characteristics
The coffee database contained 1461 original images distributed among six image-based classes: 153 anthracnose images, 144 nutritional-deficiency images, 201 Cercospora leaf spot images, 63 leaf-miner images, 447 coffee leaf rust images, and 453 healthy-leaf images. The six categories represent different types of visible leaf conditions: fungal diseases (rust, anthracnose, and Cercospora leaf spot), insect-related damage (leaf miner), a non-infectious physiological category (nutritional deficiency), and healthy leaves. Because the labels were established from photographic symptoms rather than laboratory pathogen assays, the classes should be interpreted as image-based symptom categories (Figure 3).
Figure 3. Coffee diseases: (g) coffee anthracnose; (h) coffee nutritional deficiency; (i) coffee cercospora leaf spot; (j) coffee leafminer; (k) coffee orange rust; (l) healthy coffee.
For our classification models, our dataset will be divided as shown in Table 1 below:
Table 1. Distribution of the coffee image dataset used in the experimental protocol.
Culture |
Dataset (100%) |
Training |
Validation |
Test |
Coffee |
1461 |
876 |
292 |
293 |
This allocation was carried out according to a standard ratio of 60% training, 20% validation and 20% testing, in order to ensure that our model is tested on data completely independent of that used during its training.
2.1.2. Image Preprocessing and Normalization
Before performing segmentations and classifications, all images in the database, in JPG format and with a resolution of 3048 × 4064 pixels, underwent a standardized preprocessing phase using MATLAB R2023b and the imageDatastore and augmentedImageDatastore functions of Image Processing Toolbox. This allowed each image to be resized to the fixed resolution of 227 × 227 pixels, imposed by the CNN SqueezeNet architecture, and the automatic conversion of any grayscale images to the RGB color space, ensuring consistency in the input format.
Figure 4 shows the interface of the MATLAB R2023b software.
Figure 4. MATLAB development interface illustrating automated preprocessing and resizing of leaf images.
2.2. Methods
In our MATLAB implementation, each RGB image was first converted to gray-scale using the rgb2gray function. The resulting image was normalized using mat2gray code, and the graythresh code function was then used to determine the Otsu threshold. Otsu’s method selects a threshold according to an inter-class separability criterion based on the gray-level histogram [43]. The imbinarize code function was subsequently used to generate the binary mask. Pixels above the selected threshold were assigned to the foreground according to the resulting binary segmentation. The resulting mask was then used to calculate the image descriptors. For K-means segmentation, each pixel was represented by its three-dimensional RGB vector. The number of clusters was fixed at K = 3 to obtain three image regions corresponding approximately to background, leaf tissue, and visually distinct tissue regions. The code imsegk-Means code function from MATLAB’s Image Processing Toolbox was used to generate the cluster-label map. The resulting clusters were subsequently ordered according to their mean brightness for consistency of descriptor extraction. Because the clusters were determined from RGB information rather than from grayscale intensity alone, the resulting segmentation could preserve color differences that may be lost during grayscale thresholding. Feature matrices of coffee images.
For each coffee image, 53 numerical descriptors were initially calculated from the region defined by either the Otsu or K-means segmentation mask. The descriptors were organized into five families: color/chrominance, texture, shape, intensity/contrast, and statistics/signal. These descriptors formed an N × 53 feature matrix X, where N denotes the number of images. The class label (healthy = 0; diseased = 1) was stored separately from the feature matrix. ANOVA was subsequently used to evaluate the discriminative power of the descriptors. Therefore, the term “53 descriptors” refers to the complete initial feature set and should not be interpreted as meaning that all 53 descriptors were statistically significant. For the classification experiments, Z-score standardization was applied to the numerical descriptors. For each training partition, the mean μ and standard deviation σ of each descriptor were estimated using only the corresponding training data. The normalized value was calculated as:
Customized CNN Transfer Learning
SqueezeNet was implemented using transfer learning with ImageNet-pretrained weights. The final classification layer was replaced with a layer producing six outputs corresponding to the six coffee image classes. The development portion of the dataset was used for network training, while the independent test partition was reserved for final evaluation. The training procedure used stochastic gradient descent with momentum for 45 epochs. During training, the evolution of training and validation accuracy and loss was monitored. The final performance reported in this study was calculated on the independent test set and not on the training images (Figure 5).
Figure 5. Customized SqueezeNet CNN architecture using transfer learning for multiclass classification of leaf diseases.
The system is based on a five-step sequential architecture, implemented in MATLAB R2023b with the Image Processing Toolbox and Statistics and Machine Learning Toolbox. Figure 6 below illustrates the overall sequence. Raw images acquired in the Tonkpi region constitute the system’s input and simultaneously feed two parallel processing chains. The first applies two distinct segmentations, Otsu thresholding and K-means (K = 3), producing binary masks from which 53 quantitative descriptors are extracted, distributed across five categories: color, texture, shape, intensity, and statistics. This feature matrix then feeds two supervised classifiers, k-NN and Random Forest, evaluated by five-fold cross-validation. In parallel, the raw images are resized to 227 × 227 pixels and fed into the SqueezeNet CNN, pre-trained on ImageNet and fine-tuned (45 epochs) across six classes per crop. Finally, the predictions of the three classifiers converge towards a common evaluation step, based on overall accuracy, F1 score confusion matrices, precision and recall in order to validate the effectiveness of the system.
![]()
Figure 6. Overall system processing architecture.
The confusion matrix is the primary visualization tool used to analyze classification errors in detail. For binary classification, it presents the four cells: VP, VN, FP, and FN. For multiclass classification (CNN SqueezeNet, 6 classes), the 6 × 6 confusion matrix allows for the precise identification of the most frequent interclass confusions.
Figure 7 illustrates the structure of a confusion matrix for a 6 × 6 classification problem.
Figure 7. Anatomy of a 6 × 6 confusion matrix.
3. Results and Discussion
3.1. Segmentation
3.1.1. Segmentation Using the Otsu Method
K-means required approximately 0.11 - 0.12 s per image on the coffee dataset, compared with approximately 0.02 s per image for Otsu thresholding. With K = 3, the algorithm generated three RGB-based clusters that provided visually differentiated regions corresponding approximately to the background, leaf tissue, and visually distinct tissue regions (Figure 8).
Figure 8. Binary segmentation by the Otsu method applied to foliar pathologies of coffee (m-x): comparison between the original images and the segmentation masks obtained.
These results on our two databases can be explained by Otsu’s principle: Otsu’s thresholding is particularly effective when diseased areas are significantly darker or lighter than the rest of the leaf. [43] [44] confirmed this effectiveness on well-defined dark lesions in the context of maize disease detection. Otsu’s weakness on vascular streaks is explained by the fact that this method only sees the image in grayscale and therefore loses all color information, making it difficult to detect fine patterns with low contrast.
Despite some limitations with fine patterns, Otsu’s method offers a good balance of speed and efficiency on both cultures. It is a simple, fast, and sufficiently precise tool for preparing images for analysis.
3.1.2. Segmentation Using the K-Means Method
The K-means masks appeared visually more detailed than the Otsu masks in several examples because K-means uses the three RGB channels simultaneously. However, visual appearance alone does not establish segmentation accuracy. Since no manually annotated lesion masks were available in this study, segmentation quality could not be evaluated using standard overlap metrics such as Dice or Intersection over Union (IoU) (Figure 9).
Figure 9. K-means segmentation applied to coffee plant pathologies (d-f, j-l): comparison between original images and color clusters.
Using all three color channels gives K-means a clear visual advantage. Our results align with those of researchers such as [45]-[47] who have shown that K-means visually outperforms thresholding methods on images of tomato and potato diseases. However, a mask that is pleasing to the eye is not always the most useful for a machine.
K-means produces the most visually pleasing images, but its visual superiority does not necessarily translate into its analytical superiority.
Table 2 summarizes the main technical characteristics of the two segmentation approaches.
Table 2. Comparison of the technical and computational characteristics of Otsu and K-means segmentation.
Criteria |
Otsu |
K-means |
Processing principle |
Global grayscale thresholding |
RGB clustering |
Number of channels used |
1 grayscale channel |
3 RGB channels |
Number of clusters/regions |
Binary threshold |
K = 3 |
Continued
Processing time |
≈ 0.02 s/image |
≈ 0.11 - 0.12 s/image |
Visual appearance of masks |
Simpler |
More differentiated |
Direct segmentation ground truth available |
No |
No |
The results highlight a clear contrast between the two methods: Otsu is significantly faster at 0.02 s/image on coffee, compared to 0.12 s and 0.11 s for K-means, representing a speed ratio of 6 to 7 in favor of Otsu. However, K-means produces visually superior masks thanks to its simultaneous analysis of all three RGB color channels, while Otsu is limited to a single grayscale channel. Regarding noise sensitivity, K-means is more moderate, while light reflections and shadows disrupt Otsu masks more. Otsu’s segmentation is fast, but K-means allows for good visual differentiation between healthy and infected coffee tissue.
3.2. Results and Discussion of Descriptor Extraction
We will present the effects of the 53 descriptors on the coffee images according to the values of the ANOVA test we performed. This test assigns each descriptor an F-score: the higher the F-score, the better that descriptor is able to separate the different classes of diseases.
The Otsu method produces highly discriminating masks. Indeed, 52 of the 53 descriptors show a strictly positive and statistically significant F-ANOVA.
Table 3 shows the ranking of the 10 most effective descriptors on the coffee images.
Table 3. Top 10 most discriminating descriptors on coffee obtained by the Otsu segmentation method according to F-ANOVA.
Rank |
Descriptor |
F-ANOVA |
Family |
1 |
pct_necrose_R |
112.83 |
Color/chrominance |
2 |
r_moy |
109.98 |
Color/chrominance |
3 |
r_std |
40.78 |
Color/chrominance |
4 |
CNR |
40.13 |
Statistics/signal |
5 |
d_prime |
40.13 |
Statistics/signal |
6 |
deseq_RG |
39.09 |
Color/chrominance |
7 |
BI_moy |
39.09 |
Intensity/contrast |
8 |
H_moy |
38.20 |
Intensity/contrast |
9 |
G_ratio_bord_int |
37.27 |
Statistics/signal |
10 |
IDM_moy |
33.17 |
Texture |
The results in the table show that the pct_necrose_R descriptor, which measures the percentage of red pixels in the infected area, is by far the most important with an F-score of 112.83, followed by r_moy, the average value of the red channel, with an F-score of 109.98. These two descriptors clearly dominate this ranking. We also note that some descriptors have exactly the same score; this is the case for CNR and d_prime, which have an F-score of 40.13, but also for deseq_RG and BI_moy, which have an F-score of 39.09, meaning they capture similar information and are therefore redundant.
Color and chrominance descriptors dominate because coffee diseases produce highly colored lesions: rust creates orange spots, anthracnose brown necrosis, and cercospora leaf spot reddish-brown rings. All these colors are strongly displayed in the red channel of the image. Our results are supported by [48] [49], which showed that redness indices are the best discriminators for foliar diseases causing necrosis or chlorosis. We obtained a high F-value of 112.83, a result confirmed by those of [50] [51], which show that the more different the colors of the diseases, the higher the F-ANOVA in foliar disease detection contexts. The redundancy of CNR/d_prime is expected because these two metrics measure signal-to-noise contrast using mathematically similar formulations.
On the coffee corpus, the color/chrominance descriptors, and in particular pct_necrose_R, are the most powerful in our entire agricultural disease detection support system: no other descriptor, on either corpus or with either segmentation method, achieves such a high F-ANOVA score.
Table 4 presents the first 10 descriptors exhibiting statistically significant discriminatory power (p < 0.001) according to F-ANOVA values and their family of belonging.
Table 4. F-ANOVA.
Rank |
Descriptor |
F-ANOVA |
Family |
1 |
sigma_infecte |
27.00 |
Statistics/signal |
2 |
kurt_infecte |
16.33 |
Statistics/signal |
3 |
infected CV |
15.97 |
Statistics/signal |
4 |
ExG_moy |
14.68 |
Color/chrominance |
5 |
pct_necrose_ExG |
14.68 |
Color/chrominance |
6 |
GLI_moy |
14.68 |
Color/chrominance |
7 |
skew_infecte |
14.52 |
Statistics/signal |
8 |
H_std |
12.44 |
Intensity/contrast |
9 |
BI_std |
12.35 |
Intensity/contrast |
10 |
deseq_RG |
11.38 |
Color/chrominance |
Here, we observe that only 33 descriptors remain effective, but their F-values are significantly lower. The 18 non-discriminating descriptors come from the shape and intensity/contrast families and are constant across all images. The maximum F-value is 27.00, attributed to sigma_infecte from the statistical/signal family, representing a 76% reduction compared to the Otsu method, which has an F-value of 112.83 for its most discriminating descriptor, pct_necrose_R.
Means masks have blurred boundaries between zones. When a shape or intensity descriptor is calculated on a poorly defined area, the result is noisy and varies little from one class to another, hence very low or zero F-scores. This is what [52] calls the dependence between segmentation quality and descriptor usability.
The 18 insignificant descriptors and the 76% reduction in maximum F-ANOVA on the coffee corpus confirm that using K-means as a preprocessing for k-NN and RF classifiers would drastically reduce their performance.
3.3. Classification Results and Discussion
We have three classifiers: Random Forest (RF) and k-NN for binary healthy/disease detection on Otsu descriptors, and the SqueezeNet network using Transfer Learning for multiclass identification on raw images. The results are presented from best to worst performing.
Table 5 shows the performance of the RF classifier for each number of trees tested.
Table 5. Evaluation of performance metrics of the RF model applied to detection on coffee images.
Number of Trees |
Accuracy_CV (%) |
Accuracy_Test (%) |
Precision |
Reminder |
Score F1 |
10 |
96.07 |
99.32 |
0.989 |
0.995 |
0.995 |
50 |
96.66 |
100.00 |
1 |
1 |
1 |
100 |
96.49 |
100.00 |
1 |
1 |
1 |
200 |
97.52 |
100.00 |
1 |
1 |
1 |
500 |
97.26 |
100.00 |
1 |
1 |
1 |
Figure 10. Visualization of RF model predictions (classes 0 and 1) for 10, 50, 100, 200, and 500 trees on coffee images.
The RF results on the coffee images show that for 10 trees, the test accuracy reaches 99.32% and an F1 score of 0.992, with only 2 false negatives and 0 false positives. From 50 trees onwards, the classification is perfect, i.e., 100% accuracy and an F1 score of 1 for all configurations. Cross-validation ranges from 96.07% to 97.52%, with a distinction of 97.52% for 200 trees.
Figure 10 presents the RF confusion matrices for our ten tree values for the coffee images segmented by the Otsu method.
The performance of RF on coffee is also due to the quality of the Otsu descriptors and the majority voting bagging mechanism. For the coffee corpus, the 200-tree configuration is the optimal choice.
With 100% accuracy on the test set for both crops and cross-validation greater than 97%, Random Forest represents the optimal and deployable solution for binary foliar disease detection in our intelligent detection support system.
3.4. CNN SqueezeNet Result and Discussion
Figure 11 highlights the training progress of the SqueezeNet model on 80% of our coffee images. The training accuracy curve starts around 25% in the first iteration. It progresses rapidly to reach approximately 80% within the first 200 iterations, then continues to grow, stabilizing between 95% and 100% at the end of training after 1215 iterations.
The validation curve shown in black dotted lines follows a progression parallel to that of the training. Here, validation reaches 85% to 90% around iteration 400, before stabilizing around 90% to 95% at the end of the training.
The loss curve decreases monotonically from an initial value of 3.2 to values close to 0.1 at the end of training. The validation loss curve follows the same downward trajectory and converges to 0.3 to 0.4 at interaction 1215.
Figure 11. SqueezeNet model learning curves showing the evolution of accuracy and Loss on coffee images.
The confusion matrix for the 293 test images shown in Figure 12 reveals an overall accuracy of 94.54%. Class-by-class analysis highlights the following: Healthy Coffee: perfect recall, accuracy, and F1 (100%, 100%, 1); 91 out of 91 images correctly classified, without any errors.
Rust: perfect recall (100%), accuracy of 90.8% and F1 equal to 0.952; 89 out of 89 images correctly identified, but 9 false positives (9.2%) from other classes wrongly predicted as rust.
Anthracnose: recall of 96.8%, accuracy of 90.9% and F1 equal to 0.937; 30 out of 31 images correct, the only error being classified as cercospora due to the resemblance of the small necrotic lesions.
Cercospora: recall of 85.0%, high accuracy of 97.1% and F1 equal to 0.906; 34 out of 40 images correct, the 6 errors being equally distributed between nutritional deficiency (3) and rust (3), classes with leaf spots with similar circular outlines.
Nutritional deficiency: recall of 79.3%, accuracy of 88.5% and F1 equal to 0.837; 23 out of 29 images correct, the second most difficult class, with 6 errors shared between anthracnose (3) and rust (3) due to the symptomatic versatility of deficiencies.
Miner: the most difficult class, with a recall of 76.9% but a perfect accuracy of 100% and an F1 of 0.869; 10 out of 13 images correct, the remaining 3 errors predicted as rust.
Figure 12. Confusion matrix of the SqueezeNet model on the test set for the classification of coffee leaf pathologies.
The coffee images are more or less difficult to classify than (94.54%) for three reasons: some diseases have similar colors, the number of images is very unequal between classes (89 rust images versus only 13 leaf miner images), and the network required 45 training epochs instead of 30 to find its decision boundaries, indicating that the problem is more complex. Also, our two training corpora are of modest size, but we nevertheless obtained remarkable results on both crops, which corroborates the work of [53] [54] who demonstrated that transfer learning yields good results even with a small training corpus. Finally, the fact that the training and validation curves converge on both corpora confirms that the model learned effectively without memorizing the data.
SqueezeNet using Transfer Learning reliably identifies coffee-related diseases, with excellent results (99.38%). A few classes remain indistinguishable from each other and could be improved by enriching the corpus.
Table 6 highlights the performance of the k-NN classifier for each value of k tested.
Table 6. Performance of the k-NN classifier on coffee images as a function of different values of the parameter k.
k |
Accuracy_CV (%) |
Accuracy_Test (%) |
Precision |
Reminder |
Score F1 |
1 |
96.07 |
98.97 |
0.993 |
0.983 |
0.988 |
3 |
85.11 |
90.75 |
0.894 |
0.887 |
0.891 |
5 |
82.21 |
76.71 |
0.727 |
0.712 |
0.718 |
7 |
82.04 |
83.22 |
0.809 |
0.786 |
0.796 |
9 |
79.98 |
80.48 |
0.782 |
0.739 |
0.754 |
11 |
80.15 |
77.40 |
0.740 |
0.701 |
0.714 |
13 |
78.87 |
79.79 |
0.771 |
0.734 |
0.747 |
15 |
77.76 |
78.08 |
0.746 |
0.718 |
0.729 |
17 |
77.07 |
76.03 |
0.718 |
0.700 |
0.708 |
21 |
76.99 |
77.74 |
0.740 |
0.719 |
0.727 |
Analysis of the table shows that the k-NN classifier also performs best for small k values on the coffee images. For k equal to 1, the test accuracy reaches 98.97% and the F1 score is 0.988, with only 3 false positives and 0 false negatives. For k equal to 3, performance remains very satisfactory (90.75% accuracy and an F1 score of 0.891), with 12 false negatives. A non-monotonic phenomenon is observed; the accuracy for k equal to 7 surpasses that for k equal to 5 (83.22% versus 76.71%). From k equal to 9 onward, performance stabilizes between 76% and 81%. The image imbalance (90 healthy versus 202 diseased images) mechanically favors the predominantly infected class for large k values.
A k-value of 3 remains the best compromise between performance and robustness.
Figure 13 presents the k-NN confusion matrices for our ten k-values for the coffee images.
The performance degradation as k increases is intuitively explained: with large k, we consider neighbors that are increasingly distant and less similar to the image to be classified. In our space of 53 descriptors, the notion of a near neighbor becomes blurred when k is large; this is similar to the work of [55] [56], who calls this situation the “curse of dimensionality.” The non-monotonic phenomenon (k = 7 is better than k = 5) for coffee is characteristic of high-dimensional spaces where certain odd values of k better capture the local structure of the data. The imbalance in the coffee corpus (90 healthy leaves versus 202 diseased ones) mechanically favors the majority class for large k values, progressively degrading recall of healthy leaves. k-NN with k equal to 3 constitutes an interpretable but suboptimal alternative to Random Forest. The difference of 9.25 points of accuracy on coffee, i.e., RF 100% versus k-NN 90.75%, confirms the superiority of the ensemble approach for our intelligent system.
![]()
Figure 13. Evolution of the confusion matrices of the k-NN classifier for different values of k (from 1 to 21) on the coffee images.
Table 7 groups together the best results that we have identified throughout this results and discussion section.
Table 7. Summary of best configurations and performance achieved.
Component |
Optimal configuration |
Coffee |
Segmentation |
Otsu |
0.02 s/image |
Best descriptor |
Pct_necrose_R |
F = 112.83 |
Binary-RF Detection |
200 coffee trees |
100% tested 97.52% CV |
Binary-k-NN detection |
K = 3 (Euclidean) |
90.75% test F1 = 0.891 |
Multi-class identification - SqueezeNet |
45 coffee eras |
94.54% (6 classes) |
Cross-analysis of the results reveals a clear hierarchy. For binary healthy/sick detection, RF dominates with 100% accuracy across the corpus, followed by k-NN. For multiclass identification, SqueezeNet achieves 94.54% accuracy without prior segmentation.
The best overall combination is Otsu segmentation, extraction of the 53 descriptors plus RF for binary detection, complemented by SqueezeNet in Transfer Learning for the identification of the specific pathology.
This hybrid architecture of our intelligent coffee disease detection system offers a dual level of operational security: RF ensures that no diseased leaves are classified as healthy, while SqueezeNet identifies the specific pathology to guide the appropriate phytosanitary treatment. This design is particularly relevant to the Tonkpi region, where access to computing resources is limited and diagnostic reliability is critical.
4. Conclusions and Outlook
This study investigated an image-based approach for the detection and symptom-based classification of coffee leaf disorders using a dataset collected in four locations in the Tonkpi region of western Côte d’Ivoire. A total of 1461 coffee leaf images were acquired using a smartphone under a standardized image-acquisition protocol.
Two segmentation approaches, Otsu thresholding and K-means clustering, were evaluated. Otsu required approximately 0.02 s per image, whereas K-means required approximately 0.11 - 0.12 s per image. The Otsu-derived feature representation also produced higher downstream F-ANOVA values, with pct_necrose_R reaching 112.83. The corresponding maximum reported value for the K-means-derived representation was 27.00 for sigma_infecte. Because manually annotated lesion masks were not available, these results demonstrate greater discriminative usefulness of the Otsu-derived features for the subsequent classification task rather than objectively superior segmentation accuracy.
For binary healthy/diseased classification, Random Forest achieved 100% accuracy on the reported test set, with a maximum cross-validation accuracy of 97.52% for the 200-tree configuration. k-NN achieved 90.75% test accuracy at k = 3, while k = 1 produced the highest test accuracy among the tested k values, at 98.97%. For six-class image-based classification, SqueezeNet achieved an overall test accuracy of 94.54%.
The study therefore demonstrates the feasibility of combining classical image descriptors and lightweight transfer learning for the analysis of coffee leaf symptoms in the Tonkpi dataset. Nevertheless, the results should not be interpreted as laboratory-confirmed disease diagnoses or as definitive evidence of field-level generalization. The labels used in this study were based on visible symptoms, and no laboratory pathogen identification was performed. In addition, the current experimental partitioning did not explicitly implement group-level separation by leaf, plant, or farm, which may allow correlations between related images to influence the reported performance.
Future work should therefore focus on four main directions: (i) independent expert verification of the image labels; (ii) group-level data splitting based on biological and sampling units; (iii) manual annotation of lesion masks to enable objective segmentation metrics such as IoU and Dice; and (iv) laboratory confirmation of causal pathogens for representative samples. Expanding the dataset to additional coffee-producing regions and increasing the representation of underrepresented symptom categories will also be necessary before considering operational deployment as a decision-support system for farmers and field agents.
Author Contributions
All authors contributed to the conduct of this study and the preparation of the manuscript. All have approved the final version of the article.