Preliminary Study On Development of Cocoa Beans Fe
Preliminary Study On Development of Cocoa Beans Fe
computer vision and artificial intelligence - Study of Good Handling Practices and
Critical Control Point Determination of
Dried Fermented Cocoa Bean in Gunung
To cite this article: C D Anggraini et al 2021 IOP Conf. Ser.: Earth Environ. Sci. 924 012019 Kidul Regency, Yogyakarta
T F Djaafar, L Elghina, S Widodo et al.
E-mail: [email protected]
Abstract. The fermentation process is an important indicator of cocoa beans' quality. The
standard method used is the Magra test by splitting the cocoa beans and observing the color of
the beans with the naked eye to estimate the degree of fermentation. Although, manual estimation
systems require specific expertise, which can lead to inconsistency in predicting cocoa bean
fermentation rate. This research aims to develop a classification model of two categories of
cocoa, i.e., fermented and unfermented cocoa, using computer vision and a machine learning
model. Image analysis has been carried out, and color features have been used to train and
compare several classification models. After analyzing the data, it was found out that a model
that can quantify the standard and accurate measurement of the degree of fermentation of cocoa
beans using artificial neural network models so that it can segment, calculate, and grade
classification by using color feature extraction, which is the average value of RGB and L*a*b.
The Artificial Neural Network (ANN) Multilayer Perceptron (MLP) has been found to be
superior compared to other models achieving training and validation accuracy of 94%.
1. Introduction
Cocoa is one of the plantation crops that is widely cultivated in tropical areas such as Indonesia. The
high cocoa production capacity makes cocoa a national leading commodity that contributes the third
largest foreign exchange contribution of 1.2 billion USD. The prospect of the world cocoa market is
experiencing an increase in market demand throughout the world, especially in Asia and Africa, by 38%
and 72%, respectively [1]. The quality of cocoa beans is highly dependent on several factors, especially
on post-harvest processing. The post-harvest processing of cocoa includes several processes, especially
the fermentation process, which greatly affects the quality of the final product, such as aroma precursors
and the cocoa flavor[2].
It is unfortunate that the high production of cocoa beans from Indonesia is not balanced with the low
quality of cocoa beans. This is due to the lack of knowledge of farmers in post-harvest processing,
especially in the uncontrolled fermentation process. Generally, cocoa beans of good quality must be
Content from this work may be used under the terms of the Creative Commons Attribution 3.0 licence. Any further distribution
of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI.
Published under licence by IOP Publishing Ltd 1
2021 International Conference on Green Agro-industry and Bioeconomy IOP Publishing
IOP Conf. Series: Earth and Environmental Science 924 (2021) 012019 doi:10.1088/1755-1315/924/1/012019
perfectly fermented with a brownish-red color and have a moisture content of about 7.5% and have gone
through a process of sorting the content of damaged beans. Fermented cocoa beans will experience a
color change due to a decrease in the content of polyphenols (including anthocyanidins) which are
oxidized and polymerized into insoluble high molecular weight compounds (tannins). In addition,
fermented cocoa beans showed a decrease in pH and inactivation of enzymes that produced flavor
precursors [3]. According to Davit M et al.[4], 85% of nationally produced cocoa beans are not
fermented so that it has an impact on the selling price of cocoa beans in the international market. The
application of the fermentation process is an important indicator to determine the quality and price of
cocoa beans from Indonesia in order to compete in the world market [5]. Therefore, it is necessary to
improve the process, both for the fermentation process and for measuring the quality of fermentation
that is effective and efficient and needs to be widely available in Indonesia.
The application of manual and uncontrolled fermentation technology among farmers using wooden
boxes poses a big challenge, especially in the process of measuring the degree of cocoa fermentation.
This is because the environmental conditions of each wooden box are different, and the physical changes
of each sample [6]. Fast and accurate measurement methods are needed in measuring the degree of
fermentation. The standard method for evaluating the degree of fermentation of cocoa beans is to use a
cutting test in the form of a bean cutting device called a Magra, and then an expert observer will assess
the degree of fermentation of cocoa beans visually by observing the color of the flesh on beans that have
been split open. This observation requires experts, and subjectivity can occur because the measurement
of the level of fermentation is carried out qualitatively [7]. Along with technological developments,
methods for measuring cocoa quality have emerged using spectrophotometry, chromatography, Fourier
transforms infrared spectroscopy, and imaging systems. However, this method has several obstacles if
applied on a large scale, such as it is time-consuming, requires a lot of human resources, expensive
equipment prices, and is difficult to apply to practitioners, especially cocoa farmers [2].
Computer vision is a technology that is currently being developed as an effort to measure the quality
of agricultural products, which has the advantage of being cheaper, faster, accurate, and non-destructive
[2]. The use of the image analysis method with multivariate statistics has been successfully applied to
agricultural products such as fruits and vegetables. In addition, the use of computer vision has a high
accuracy rate of > 90% by using several methods such as Support Vector Machines (SVM), C4.5,
AdaBoost (AB), k-Nearest Neighbors (KNN), Logistic Regression (LR), Stochastic Gradient Boosting
Trees (GBDT), Extreme Learning Machines (ELM), Sparse Representation-based Classification (SRC),
and Deep Learning (DL). The use of computer vision aims to produce a fast and accurate measurement
process for classifying and predicting the quality of an agricultural product [3]. Based on this problem,
this article aims to develop an image processing, feature extraction procedure, and a classification model
of two classes of the cocoa bean, i.e., fermented and unfermented cocoa using computer vision and
several machine learning models. This model is used as the first step in making a portable fermentation
index measurement system so that it can be developed into a system that can be widely applied in the
community.
2
2021 International Conference on Green Agro-industry and Bioeconomy IOP Publishing
IOP Conf. Series: Earth and Environmental Science 924 (2021) 012019 doi:10.1088/1755-1315/924/1/012019
3
2021 International Conference on Green Agro-industry and Bioeconomy IOP Publishing
IOP Conf. Series: Earth and Environmental Science 924 (2021) 012019 doi:10.1088/1755-1315/924/1/012019
dividing the histogram image into two different areas. Using a discriminant analysis approach by
determining a variable that can distinguish between two or more groups that appear. The formulation
used is as follows: for example, the threshold value to be searched is with the letter k. The value of k
ranges from 1 to 255 [9]. The Otsu method is a segmentation method that uses a histogram to group the
pixels in the x- and y-axis images. The x-axis in the Otsu method is a different level of intensity, while
the y-axis represents the number of pixels that have that intensity value [8].
Feature extraction is the process of taking the color you want to analyze, including RGB and Lab
colors. The value of each sample of cocoa beans Characteristics from the images was carried out because
it was estimated that they would have different values for each class of cocoa beans fermentation level.
Taking these values is carried out on all image pixels that are included in the segmentation so that only
the value of the fruit image is obtained without the image background [10]. CFs include color mean
value and excess RGB index. Color mean value can be described as follows [11]:
1
Color mean value = 𝑀 ∑𝑀
𝑖=1 𝐶𝑜𝑙𝑜𝑟 𝑣𝑎𝑙𝑢𝑒
(1)
where: color value can be defined as the range of each color space in the pixel such as red, green, blue,
grey, L*, a*, b*. M is the total number of pixels in the masked region of the image. The complete image
analysis step has been shown in Figure 3.
4
2021 International Conference on Green Agro-industry and Bioeconomy IOP Publishing
IOP Conf. Series: Earth and Environmental Science 924 (2021) 012019 doi:10.1088/1755-1315/924/1/012019
The threshold analysis will provide a threshold value for each image between the foreground and the
background. The threshold value uses half the value of the global threshold automatically to reduce
noise from each image category. In addition, in doing image segmentation, it is known that several
different results are known when analyzing images directly from RGB colors and when doing the
grayscale conversion process from each category. From Otsu's method, this determines the threshold
value based on stats image information of cocoa beans from each category by minimizing the number
of weighted group variances, where the weight is the probability of each group[13]. According to Bhahri
and Rachmat [14] in the segmentation process, the first step is to divide the image into several parts to
determine the boundaries and continue with the stage of giving an index to the color of each pixel that
shows the part in a segmentation. Otsu's method works by separating objects with a discriminant analysis
background that will maximize the variables visualized in a histogram. The histogram is used to
determine the number of pixels and the threshold for each gray level.
5
2021 International Conference on Green Agro-industry and Bioeconomy IOP Publishing
IOP Conf. Series: Earth and Environmental Science 924 (2021) 012019 doi:10.1088/1755-1315/924/1/012019
error values obtained [15]. The method which is simple but with high accuracy will be preferable to
avoid model complexity curse. The simple model also mean that it could be executed faster with lower
memory and storage required.
Table 2. Machine learning model.
Training Validation
No. Model Scaling
Accuracy Accuracy
Logistic Regression (with L2
1 None 70.13 76.47
regularization)
Logistic Regression (with L2
2 Standard Scaler 60.52 64.71
regularization)
3 Decision Tree (criterion: entropy) None 100 85.81
4 Decision Tree (criterion: entropy) Standard Scaler 100 85.81
5 Random Forest (n_estimators: 30) None 99.74 86.85
6 Random Forest (n_estimators: 30) Standard Scaler 99.83 85.12
7 SVM (kernel: RBF, gamma=1.7) None 100 59.86
8 SVM (kernel: RBF, gamma=1.7) Standard Scaler 89.35 84.78
From the results, it has been found that the first model which is using 2 hidden layers (16-16) provide
the best results (Figure 4). Interestingly ANN-MLP model which used more than two layers, i.e., three
and four could not achieve accuracy more than the two hidden layers models. From the results of the
preparation of the model using artificial neural network, there are several important points. Factors to
choose the type of activation function, the number of iterations and the number of hidden layers of each
model need to be considered. In addition, the number of hidden layers must also be adjusted to the
learning rate of a model. ANN modeling using these 3 models is very capable of being developed in a
system to classify the level of cocoa bean fermentation with an accuracy value of >90%. Table 3 shows
the results of the accuracy and validation of the best model for each ANN MLP architecture.
Table 3. The results of artificial neural network models (data training=85%, data validation=15%).
No. ANN Hyperparameter Scaling Training Validation Training Validation
Accuracy Accuracy Loss Loss
1 Hidden layer: 16-16 Standard 0.942 0.94 0.145 0.176
Activation: relu-relu-sigmoid Scaler
Learning rate: 0.002
Epoch: 500
Batch size: 15
2 Hidden layer: 16-16-8 Standard 0.936 0.931 0.152 0.184
Activation: relu-relu-sigmoid Scaler
Learning rate: 0.001
Epoch: 500
Batch size: 15
3 Hidden layer: 16-16-8-8 Standard 0.942 0.921 0.127 0.198
Activation: relu-relu-sigmoid Scaler
Learning rate: 0.001
Epoch: 500
Batch size: 15
6
2021 International Conference on Green Agro-industry and Bioeconomy IOP Publishing
IOP Conf. Series: Earth and Environmental Science 924 (2021) 012019 doi:10.1088/1755-1315/924/1/012019
Figure 4. Model accuracy and loss during training and validation for ANN model with 2 hidden layers
and nodes 16-16.
4. Conclusions
From 1143 cocoa beans image data from two categories of fermented and unfermented cocoa beans, it
is obtained if there is a color relationship, especially RGB in determining the correlation value between
parameters. The use of Otsu's method will simplify the image segmentation process for each category
due to the loss of noise in the form of light disturbances and unwanted image objects to be detected.
Image segmentation is the first step in developing a detection system for the degree of fermentation of
cocoa beans through image images by dividing an image into several regions, which in an area have
similar attributes. In making modeling using ANN, it is necessary to pay attention to several factors such
as the number of iterations, the value of learning rate and the number of neurons in a hidden layer. From
the model that has been made to classify the level of fermentation of cocoa beans using an artificial
neural network, it has an accuracy value of >90% from 2 categories of fermentation levels. Especially
in the 1st model with 2 hidden layers at node values (16,16) and 0.002 learning rate value, through the
output activation function in the form of Sigmoid, has the highest validation accuracy value of 94%.
These results show that it is relatively easy to classify the fermented and unfermented cacao beans with
any machine learning model using a few color features. Further challenges are to predict the
fermentation levels in more detail in higher resolution using classification with more classes or a
regression model.
References
[1] Maulana A and Kartiasih F 2017 Analisis ekspor kakao olahan indonesia ke sembilan negara
tujuan tahun 2000 – 2014 (Analysis of indonesian cocoa exports to nine destination countries
2000 – 2014) J. Ekon. Pembang. Indones. 17 2 103-17
[2] Yro A, Edié C N, Kpalma K, Aubain Y, Edié Camille Z and Kidiyo K 2018 Cocoa beans
fermentation degree assessment for quality control using machine vision and multiclass svm
classifier Int. J. In-Novation Appl. Stud. Issr J. 24 4 1711-7
[3] Oliveira M M, Cerqueira B V, Barbon S and Barbin D F 2021 Classification of fermented cocoa
beans (cut test) using computer vision J. Food Compos. Anal. 97 103771
[4] Davit J, Yusuf R P and Yudari D A 2013 Pengaruh cara pengolahan kakao fermentasi dan non
fermentasi terhadap kualitas, harga jual produk pada unit usaha produktif Tunjung Sari,
Kabupaten Tabanan (The influence of fermented and non-fermented cocoa processing
methods on the quality, selling price of products in the productive business unit of Tunjung
Sari, Tabanan Regency) E-Journal Agribisnis dan Agrowisata 44956
[5] Nurhayati N, Utami R R and Yusdianto Y 2019 Teknologi digital sensor warna untuk mengukur
tingkat fermentasi kakao (Ulasan) (Digital color sensor technology to measure cocoa
fermentation rate) J. Ind. Has. Perkeb. 14 2 16-23
7
2021 International Conference on Green Agro-industry and Bioeconomy IOP Publishing
IOP Conf. Series: Earth and Environmental Science 924 (2021) 012019 doi:10.1088/1755-1315/924/1/012019
[6] Yulianti N L and Arda G 2018 Studi kombinasi lama fermentasi, jenis wadah dan suhu
pengeringan terhadap karakteristik kakao kering (Study of combination of fermentation time,
type of container and drying temperature on the characteristics of dry cocoa) J. Ilm. Teknol.
Pertan. Agrotechno 3 1 304-8
[7] Tan J, Balasubramanian B, Sukha D, Ramkissoon S and Umaharan P 2019 Sensing fermentation
degree of cocoa (Theobroma Cocoa L.) beans by machine learning classification models based
electronic nose system J. Food Process Eng. 42 6 e13175
[8] Putra E D and Santosa S 2017 Optimasi kemampuan segmentasi otsu pada identifikasi plat nomor
kendaraan indonesia menggunakan metode gaussian (Optimization of otsu's segmentation
capability on identification of indonesian vehicle number plates using the gaussian method)
Pseudocode 4 1 47-60
[9] Muwakhid I A and Nurdiyah D 2018 Otsu method for image finish segmentation with
components of hue saturation value 15 67-73
[10] Prahudaya T Y and Harjoko A 2017 Metode klasifikasi mutu jambu biji menggunakan knn
berdasarkan fitur warna dan tekstur (Guava quality classification method uses knn based on
color and texture features) J. Teknosains 6 2 113-23
[11] Hendrawan Y and Al Riza D F 2016 Machine vision optimization using nature-inspired
algorithms to model sunagoke moss water status Int. J. Adv. Sci. Eng. Inf. Technol. 6 1 45-57
[12] Agmalaro M A, Kustiyo A and Akbar A R 2013 Identifikasi tanaman buah tropika berdasarkan
tekstur permukaan daun menggunakan jaringan syaraf tiruan (Identification of tropical fruit
plants based on leaf surface texture using artificial neural networks) J. Ilmu Komput. Agri-
Informatika 2 2 73-82
[13] Yousefi J 2015 Image binarization using otsu thresholding algorithm Res. Gate, DOI:
10.13140/RG.2.1.4758.9284
[14] Bhahri S 2018 Transformasi citra biner menggunakan metode thresholding dan otsu thresholding
(Binary image transformation using thresholding and Otsu thresholding method) E-Jurnal
Jusiti (Jurnal Sist. Inf. Dan Teknol. Informasi) Doi: 10.36774/Jusiti.V7i2.254.
[15] Rahman M F, Alamsah D, Darmawidjadja M I and Nurma I 2017 Klasifikasi untuk diagnosa
diabetes menggunakan metode bayesian regularization neural network (Rbnn) (Classification
for diagnosing diabetes using the Bayesian regularization neural network method) J. Inform.
11 1 36