Classification of Some Fruits Using Imag
Classification of Some Fruits Using Imag
DOI: https://doi.org/10.24925/turjaf.v9i12.2189-2196.4445
Available online, ISSN: 2148-127X │www.agrifoodscience.com │ Turkish Science and Technology Publishing (TURSTEP)
a b [email protected] https://orcid.org/0000-0001-6733-4943
[email protected] https://orcid.org/0000-0002-2705-299X
This work is licensed under Creative Commons Attribution 4.0 International License
Introduction
The external features such as color, size, texture, According to the report of the Fresh Fruit and
different flaws and shape in the products to be offered to Vegetable Workshop published by the General Directorate
the market are important features in classification and of Agricultural Research and Policies in 2019, there was an
grading. One of the most important quality features in fruits increase of 24.03% in total fruit yield, 21.03% in the
and vegetables is their appearance. The appearance not production area and 50.11% in the production amount.
only affects the market value of the products, its However, this increase causes approximately 30-40% of
preferences and the choice of the consumer, but it also product to be wasted in total production due to wrong
affects the interior quality to a certain extent. Problems mechanization applications after harvest. Applications of
arising from processes such as classification, packaging post-harvest technologies can minimize the loss of fresh
and storage of fresh fruits and vegetables before they are fruits and vegetables from harvest to consumption, reduce
placed on the market determine the market price formation quantitative and qualitative losses, as well as maintain
and consequently affect the producer income (Pezikoğlu et product quality, such as nutritional value, physical
al 2004). Manual quality control of the fruit takes time and appearance and sensory properties. Some studies show that
labor intensive. Therefore, computerized vision systems there are large differences between post-harvest losses of
are widely used for automation-based external quality developing and developed countries, with estimated losses
control of food and agricultural products. Today, with between 2% and 23% (Singh et al 2014). Studies on image
advances in machine vision can produce accurate, fast, processing have continued from past to present. For
objective and efficient results in the non-destructive fruit example; some of the researcher were used image
classification due to the availability of low-cost hardware processing techniques for edge detection, feature
and software (Naik and Patel 2017). extraction and color detection of yellow, red and green
apples in their study on yield mapping in peach fruit, using
2189
Koç and Vatandaş / Turkish Journal of Agriculture - Food Science and Technology, 9(12): 2189-2196, 2021
image processing techniques such as histogram was 0.9763, and the root-mean-square error (RMS error)
thresholding and logarithm transformation, color, texture was 1.3243 mm.
and shape of images taken under natural conditions. In this study, apple, quince and orange fruit varieties
Feature extraction method has been used and algorithms were tried to be classified according to the color and size
have been developed. In the event that a fruit comes in front by developing an image processing algorithm.
of the camera, the system processes the image taken from
the camera and provides numerical and visual information Materials and Methods
about the size and color of the fruit examined on the screen
(Tonguç 2007; Kim et al 2009; Kurtulmuş et al 2014). The Biological Materials
researcher stated that some of the algorithms he developed In this study, apple, orange and quince varieties were
have been successful in determining the fruit at the level of used as biological materials. In studies on the classification
85%. Sungur and Özkan (2015) made a quality control of fruits using image processing techniques, the number of
application using MATLAB software to detect pollution in sample sizes taken varies between 43 and 948 (Örnek
chicken eggs and calculate egg volume. The researcher 2014; Yabanova and Yumurtacı 2018). Besides these
used the fuzzy logic algorithm to determine the degree of values, considering the statistical evaluation principles, the
quality. According to the results obtained, the algorithm sample number for each variety was determined as 50
developed works with 98% accuracy. Örnek (2014) fruits.
investigated the grading efficiency of the real-time image
processing system developed with transverse and Software and Measuring Devices
longitudinal roller-type mechanical carrot sorting LabVIEW (Laboratory Virtual Instrument Engineering
machines. The classification of carrots on a belt, which can Workbench) package program was used to develop image
speed adjusted by a geared motor with classification process algorithm. And digital caliper was used to measure
machine is based on the analysis of these images. fruit diameter values. The digital caliper is capable of
According to the results obtained, the ratio of carrots reading with a sensitivity of 1/100 mm. Xrite Ci60 model
falling to the faulty section in a transverse roll, a portable spectrophotometer was used to obtain color data
longitudinal roll and real time classification machine was from fruits. The spectrophotometer is able to determine the
found to be between 0.65% - 99.33%, 18.39% - 88.90% color values in the wavelength range of 400 - 700 nm in
and 5.42% - 9.03. Al-Shekaili et al (2016) classified the more than one color space and in this study, the desired L*
types of dates grown in various regions of Saudi Arabia a* b* color space measurements was made. (Figure 1a).
according to their hardness. Instead of the traditional
expensive and time-consuming methods used to determine Classification Unit
the quality of dried fruits, they used artificial neural In the study, Logitech C930E model web cam was used
network and linear discrimination analysis methods by to obtain images of fruits (Figure 1b). The dimensions of
removing histogram and texture features from 1800 the camera are 29 × 94 × 24 mm and can take up to 1920 ×
images, for example, in the computer vision system they 1080 pixels. The camera used is placed on a tripod so that
developed. Researchers classified dried fruits into soft, the classification device can be seen from the top.
semi-hard and hard. The results were successful for LDA The belt conveyor, which is the most important
and 84% for ANN and 77% for ANN. Jhawar (2016) component of the classification unit, was manufactured
classified taken from 160 orange photographs using the from stainless steel chrome sheet and aluminum material.
pattern recognition method. Designed classification The conveyor belt has a tape of 88 mm width, 2 mm
system; data collection and processing, feature extraction thickness, 650 - 700 mm and is black and can eliminate the
and making decisions. Images were taken at a resolution of electrostatic effect. All of the fasteners of the belt conveyor
640 × 480 pixels with a digital camera from a special box are made of stainless material. The outer diameter of the
illuminated with 430 luxurious lights. According to the drive roller is 32 mm, but there are holes of 25 mm depth
results of the study, 90% and 98% success was achieved in and 8 mm diameter on both ends of the roller. One end of
the classification of oranges. Ishikawa et al (2018), in their the drive roller is 14 mm, the other end is 17 mm in
study, classified the strawberries by using the shape diameter and it is made of aluminum to prevent the
information taken from digital images. Using the SHAPE bearings from rusting (Figure 1c).
software, they used fruit length, width, projection area and The spindle conveyor drive roller of the DC motor
fruit border lines data from 2969 photos for classification. operating the belt conveyor is coupled by direct engagement.
They emphasized that the method of machine learning was The output speed of the DC motor reducer is 90 min-1 and
successful in identifying strawberry fruits of nine different the motor operates with a nominal 24V DC voltage. The
shapes. Li et al (2019) have developed an online optical speed of the band can be adjusted with a DC motor driver
and spectroscopic-based system for the rapid added to the system. The motor driver added to the system
determination of internal and external quality in apples can control the motors in the range of 5 - 30 volts.
after harvest. A new image segmentation method has been In the classification device, two pneumatic double-
developed in order to determine the image of apple acting cylinders, which perform the main separation, are
containing all surface information in the online detection used. NPN type transistors were used to trigger the pistons.
system consisting of the external quality detection It is energized by means of 24 V with a capacity of 0,15 -
mechanism and the internal quality detection mechanism. 0,8 MPa as directional control valve. A pair of solenoid
In the study, the fruit external quality assessment rate was valves that control the pistons and a compressor with a
96.76%, the correlation coefficient in size measurement maximum capacity of 6.8 bar producing the required
compressed air has been added to the system.
2190
Koç and Vatandaş / Turkish Journal of Agriculture - Food Science and Technology, 9(12): 2189-2196, 2021
Arduino development board was used to control the The size and color values read with caliper and
pneumatic pistons on the belt system. Arduino Uno is a spectrophotometer were entered into the developed image
development board that uses Microcontroller processing algorithm and the success of classifying the
(ATmega328), which contains 14 digital input-output pins fruits correctly was determined.
and 6 analog input pins that can be connected with various
boards and other circuits. Machine Learning Algorithms
In the readings performed by the algorithm, a database
Method of three hundred objects with four numerical qualities (fruit
In the first stage of the measurements, the randomly diameter, R color channel, G color channel and B color
selected apple, quince and orange varieties were numbered channel) was created from the size and color values of
with labels affixed to the stem pit, and then the maximum apple, orange and quince. Class assignments (labels) of
distance between the flower pit and the stem pit of the fruits fruits whose qualities are determined in the database have
was measured and recorded. A total of 300 measurements been made. Using the KNIME Analytics Platform
were obtained. In the measurements carried out by the software, the data were introduced with descriptive
algorithm, the size readings were determined by first statistical methods, and then analyzed with the
converting the RGB images taken from the fruits to the classification techniques used in data mining. KNN,
grayscale images and then determining the borders (edge decision tree, Naive Bayes classification, Random Forest
detection). A platform placed under the fruits allows the and MLP are used in the classification where tag values are
widest parts to be measured by the camera. Under the tried to be predicted (Figure 2.). In the decision tree
camera, the fruit is placed so that the flower pit is below. formation, gain information was taken as the basis of
The measurements were made according to the quality and minimum description length (MDL) was used
classification values specified in TSE standards. In Table as pruning method. Decision Tree algorithm evaluates how
1, the minimum diameter values determined by TSI for well each sample separates its attributes according to target
apple, in Table 2. the length characteristics of the orange classes by using information gain and entropy. The
determined by TSE are also given. The algorithm distinguishing feature with the least entropy is selected and
developed for the apples is coarse and normal size, and for used as a test at the root node of the tree. Entropy is a
the oranges, the size number is between 0… 13, which is measure commonly used in information theory that
indicated on the front panel in the height indicators and characterizes the homogeneity of samples. The greater the
classified by opening pistons on the belt. difference of the data, namely the entropy measure, the
Xrite Ci60 spectrophotometer color readings on the more uncertain and unstable the results found with that
three surfaces determined from the vicinity of the stalk pit data. If all objects are in the same class, entropy is zero
of fruits and the average of three-color channels (L, a, b) (Silahtaroğlu 2016; Köse 2018). Entropy is calculated with
were obtained. The imported Lab color values are the following equation:
converted to RGB color space. Delta E is a measure of
c
color difference and is determined using the Euclidean |Ni| |Ni|
distance between two samples in the LAB space. Color Entropy(Nj)= ∑ log2
|Nj| |Nj|
image quality, the camera that captures images, etc. i=1
devices, compression on the image, restoration,
rearrangement, image transmission depends on many Here;
factors such as (Ouni et al. 2008). For this reason, Delta E Nj: Total number of records of N attributes in the
value is also given to indicate the color difference between attribute set,
the color values taken by spectrophotometry and image Ni: Refers to the number of records of the i'th option of
processing. Surfaces with color readings were then placed the attribute N (Köse 2018).
in a position where the camera could see, and the real-time
measurement results of the developed image processing The differences that occur according to this feature in
algorithm on the same surface were recorded in the Excel order to make the correct classification at the stage of
file. The color values are divided into classes only for forming nodes and branches according to the
apples within the standard set by TSE. distinguishing feature of the samples are called Gain
2191
Koç and Vatandaş / Turkish Journal of Agriculture - Food Science and Technology, 9(12): 2189-2196, 2021
Information. Gain Information is obtained by calculating The training and results processing of this method are
the differences between the weighted sums of the entropies very fast, but may be insufficient in solving complex
of each subsection (Silahtaroğlu 2016). The Gain classification problems. Bayes' theorem is calculated by
Information formula is given below: the formula below.
Table 1. Smallest diameter measurements accepted by apples according to classes (Anonymous 2007a)
Extra Class I Class II
Large size (L), mm 65 60 60
Normal size (N), mm 60 55 50
2192
Koç and Vatandaş / Turkish Journal of Agriculture - Food Science and Technology, 9(12): 2189-2196, 2021
2193
Koç and Vatandaş / Turkish Journal of Agriculture - Food Science and Technology, 9(12): 2189-2196, 2021
2195
Koç and Vatandaş / Turkish Journal of Agriculture - Food Science and Technology, 9(12): 2189-2196, 2021
Conclusion
In the study, an image processing algorithm was Papatya Yayıncılık Eğitim, 280 s., İstanbul/Turkey. (In
developed to classify fruits according to their size and color Turkish).
characteristics, and it was integrated into a classification
unit and used in trials. On the other hand, the size and color
values read on fruits by image processing software were Küçükönder H, Vursavuş KK, Üçkardeş F. 2015. Determining
evaluated with the estimator techniques used in data The Effect of Some Mechanical Properties on Color Maturity
mining. Algorithms run with 10-fold cross validation of Tomato With K-Star, Random Forest and Decision Tree
method yielded highly accurate results. Both online and (C4.5) Classification Algorithms. Turkish Journal of
offline classification methods were successful for the fruits Agriculture-Food Science and Technology, 3(5): 300-306,
that were tested. DOI:
Kurtulmuş F, Lee WS, Vardar A. 2014. Immature peach detection
Information in colour images acquired in natural illumination conditions
using statistical classifiers and neural network. Precision
agriculture, 15(1), 57-79. DOI:https://doi.org/ 10.1007/
This study is derived from the master’s thesis entitled s11119-013-9323-8.
“Classification of Some Fruits with Image Processing Li L, Peng, Y., Li, Y., Liu, Y. 2019. A nondestructive on-line
Techniques” (Council of Higher Education: detection system of apple internal and external parameters
https://tez.yok.gov.tr/UlusalTezMerkezi/tezSorguSonucY based on optical technique. An ASABE Meeting
eni.jsp) supervised by Prof. Dr. Mustafa Vatandas. Presentation, DOI: https://doi.org/10.13031/aim.201900783.
Naik S, Patel B (2017). Machine vision based fruit classification
and grading-a review. International Journal of Computer
References Applications, 170(9), 22-34.
Örnek, MN. 2014. Havuç Sınıflandırmada Gerçek Zamanlı
Al-Shekaili NH, Manickavasagan A, Al-Mezeini NK, Rahman Görüntü İşleme Makinası Tasarımı ve Bazı Mekanik
MS, Guizani N. 2016. Computer vision technique to classify Sınıflandırma Makinaları ile Boylama Etkinliklerinin
dates based on hardness. Journal of Agricultural and Marine Karşılaştırılması. Doktora Tezi, Selçuk Üniversitesi, Fen
Sciences Vol. 22 (1): 36-41. Anonymous 2007a. Apple Bilimleri Enstitüsü, Tarım Makinaları Anabilim Dalı, Konya.
Standard. TS 100. Turkish Standards Institution, Ouni S, Zagrouba E, Chambah M, Herbin M. 2008. A New
Ankara/Turkey. Generic Colour Full Reference Metric. ISIVC 2008.
Anonymous 2007b. Citrus Standard. TS 34. Turkish Standards Pezikoglu F, Ergun ME, & Erkal S. 2004. The situation of modern
Institution, Ankara/Turkey. retailers in fresh fruit and vegetable marketing channel.
Anonymous 2007c. Quince Standard. TS 1817. Turkish Journal of Ataturk Central Horticultural Research Institute
Standards Institution, Ankara/Turkey. (Turkey).
Ataş M. 2016. Extraction of robust features from Siirt pistachio Sabancı K, Ünlerşen MF, Dilay Y. 2016. Determination Using
images for pistachio sorting system. Dicle University Journal Image Processing Techniques the Classification Parameters
of Engineering, 7(1): 93-102. of Apple Varieties Grown in the Karaman Region. Journal of
Bul E, Gelen G, Altun H. 2005. Görüntü İşlemeye Dayalı Agricultural Machinery Science, 12 (2), 133-139.
Tarımsal Ürün Sınıflandırma. 11. Ulusal Elektrik- Şeker ŞE, Erdoğan D. 2018. KNIME İle Uçtan Uca Veri Bilimi.
Elektronik- Bilgisayar Mühendisliği Kongresi, 22-25 Eylül 1. Basım, 440 s., Demet Erdoğan Yayınevi. (In Turkish).
2005, Şişli-İstanbul. (In Turkish). Silahtaroğlu G. 2016. Veri Madenciliği Kavram ve Algoritmaları.
Çalış K, Gazdağı O, Yıldız O. 2013. Automatic Detection of 3. Basım, 304 s., Papatya Yayıncılık, İstanbul. (In Turkish).
Advertising Email Using Text Mining. International Journal Singh V, Hedayetullah M, Zaman P, Meher J. 2014. Postharvest
of Informatics Technologies, 6(1): 1-7. technology of fruits and vegetables: An overview. Journal of
Er O, Cetişli B, Sofu MM, Kayacan C. 2013. Real-Time Postharvest Technology, 2(2), 124-135.
Automatic Apple Classification. Süleyman Demirel Solak S, Altınışık U. 2017. Detection and classification of
University Journal of Natural and Applied Science, 17(2), 31- hazelnut fruit by using image processing techniques and
38, 2013. clustering methods. SAKARYA UNIVERSITY JOURNAL
Ishikawa T, Hayashi A, Nagamatsu S, Kyutoku Y, Dan I, Wada OF SCIENCE, Doi: 10.16984/saufenbilder.303850 22 (1),
T, Oku K, Saeki Y, Uto T, Tanabata T, Isobe S, Kochi1 N. 56-65.
2018. Classifıcation of Strawberry Fruit Shape by Machine Sungur C, Özkan H. 2015. A real time quality control application
Learning. International Archives of the Photogrammetry, for animal production by image processing. Journal of the
Remote Sensing & Spatial Information Sciences, 42(2). Science of Food and Agriculture, 95(14), 2850-2857.
Jhawar J. 2016. Orange Sorting by Applying Pattern Recognition Tonguç G. 2007. Fruit Classification Using Image Process
on Colour Image. Procedia Computer Science 78 (2016) 691 Techniques. M.Sc. Thesis, Süleyman Demirel University
– 697. Graduate School of Applied and Natural Sciences Machine
Kim DG, Burks TF, Qin J, Bulanon DM. 2009. Classification of Education Department, Isparta, Turkey.
grapefruit peel diseases using color texture feature analysis. Yabanova İ, Yumurtacı M. 2018. Classification of Dynamic Egg
Int J Agric & Biol Eng, Vol. 2 No.3, 41-50p. Weight Using Support Vector Machine. Journal of the
Koklu, Murat; Ozkan, Ilker A. 2020. Multiclass classification of Faculty of Engineering and Architecture of Gazi University
dry beans using computer vision and machine learning 33:2 (2018) 393-402.
techniques. Computers and Electronics in Agriculture, 174(),
105507–. doi: 10.1016/j.compag.2020.105507.
Köse İ. 2018. Veri Madenciliği Teori Uygulama ve Felsefesi.
2196