Egg Weight Prediction and Egg Size Classification Using Image Processing and Machine Learning
Egg Weight Prediction and Egg Size Classification Using Image Processing and Machine Learning
Abstract— Measuring the weight and judging the size of eggs This paper is organized as follows: First, in Section II,
are important in egg grading. This paper presents image literature related to egg inspection is reviewed. Next, in Section
processing and machine learning techniques for predicting III, the proposed algorithms are described in detail. In Section
chicken egg weight and classifying egg size number from a single IV, performance comparison experiments and results are
egg image. A brown chicken egg is candled and its image is taken presented to evaluate the efficiency of the proposed algorithm,
as an input to the algorithm. The egg image region is segmented and Section V provides the conclusions from this study.
from the background. Thirteen features are computed from
geometric parameters acquired from the egg region. The weight
of the egg is predicted and the size number is classified using the II. RELATED WORK
13 features. The experiment shows that using the linear Research related to determining an object’s weight and
regression technique to predict the weight yielded the correlation volume by using image processing and machine learning
coefficient of 0.9915, and the experiment using the Support techniques has been available for many years. Soltani et al. [2]
Vector Machine (SVM) technique for classifying the size number presented a method to estimate egg volume using image
yielded 87.58% accuracy. processing by calculating the major and the minor diameters of
an egg image. They proposed a mathematical model based on
Keywords— egg weight; egg size; image processing; machine
learning Pappus’ Theorem and an Artificial Neural Network (ANN) to
estimate egg volume. Raoufat and Asadi [3] proposed a method
to measure the weight of an egg using machine vision using
I. INTRODUCTION ANN techniques. Javadikia et al. [4] applied the ANFIS model
Grading eggs according to weight and sizing eggs is an as a real-time method to measure the width and the length of an
essential activity to prepare the eggs for marketing. In egg image using image analysis. Rashidi and Gholami [5]
Thailand, the National Bureau of Agricultural Commodity and studied nine linear regression models for egg mass prediction
Food Standards (ACFS) categorizes egg sizes by per-egg using geometrical attributes. Waranusast et al. [6] proposed an
weight as shown in Table 1 [1]. algorithm to classify egg size on an Android mobile device by
comparing an egg image with a coin image in order to compute
features, and to apply the Support Vector Machine (SVM)
TABLE I. THAI ACFS FOR EGG SIZE
technique. Rashidi et al. [7] and Fellegari and Navid [8]
Size No. Size Class Weight (g) presented an image processing method for measuring object
size and volume, but with cantaloupes and oranges.
0 Jumbo More than 70
978-1-5386-0449-6/17/$31.00 ©2017
477
2017 14th International Conference on Electrical Engineering/Electronics, Computer, Telecommunications
and Information Technology (ECTI-CON)
(a) (b)
Egg The egg region is then rotated to make the major (longer)
axis of the egg region parallel to the x-axis of the image. This
Light hole step is done in order to make the rest of the process more
Light bulb convenient. To complete this process, the centroid of the egg
region, denoted c in Fig 4, is calculated using (1).
Candling box
, (1)
Fig. 2. Image acquisition component
where xc and yc are the x and the y coordinates of the centroid
and N is the total number of pixels in the egg region. After the
B. Egg Candling and Image Acquisition centroid is found, distances from the centroid to every edge
The image acquisition system applies an egg candling point of the egg region can be calculated using (2).
technique with a light source placed behind the egg in order to
show the egg details through the eggshell. This technique is
(2)
used extensively in the egg industry to assess the quality of
eggs. We applied this technique because it gives a high contrast
between foreground and background, clearly revealing the where c is the centroid, pi is the ith edge point, and (xp,i , yp,i) is
egg’s inner structure. The egg is placed over a hole that allows the coordinate of the ith edge point. The major axis of the egg
light out from the light source box. The egg image is acquired region is the line that passes the centroid c of the egg region to
with a digital camera located above the candling box. This the edge point pmax, which is the pi with maximum Distancei.
activity occurs in a dark room in order to diminish the effects After the major axis is obtained, the angle (θ) between the
of the ambient light. Fig. 2 shows the setup of the image major axis and the x-axis of the image is calculated using (3).
acquisition apparatus.
(3)
C. Preprocessing and Egg Image Segmentation where
The input image from the acquisition system is an RGB
color image, as shown in Fig 3a. To segment the egg image (4)
from the background, the input image is separated into R, G, and
and B channels, as shown in Figs 3b, 3c, and 3d. From our
observation, the R component of the image provides better (5)
contrast and is brighter than the other components. Hence, the
R channel is used as a grayscale image input. A simple and
478
2017 14th International Conference on Electrical Engineering/Electronics, Computer, Telecommunications
and Information Technology (ECTI-CON)
(8)
Finally, the image is rotated using the rotation matrix as in
(7). Where (x’, y’) are the rotated coordinates of the original
coordinates (x, y). Fig. 4 shows the process of egg image where R is the set of pixels in the egg region.
rotation. 3) The compactness (C): The compactness is the ratio of
the area of a region to the area of a circle with the same
perimeter. The compacness, C, is defined as
(7)
(9)
4) The height of the egg (h): The height of the egg is the
length of the major axis of the egg region as shown in Fig. 5.
5) The width of the egg (w): The width of the egg is the
length of the minor axis of the egg region. The minor axis is
an axis which passes the centroid and is perpendicular to the
major axis. Fig. 5 shows the width of the egg denoted w.
(a) (b)
6) The egg shape index (SI): The egg shape index was
proposed by Panda [10] and has been used extensively in
measuring egg shapes [11]. The shape index is the ratio
between the width and the height of an egg multiplied by 100
as in (10).
(10)
(c) (d) 7) The longer semi major axis (a): This feature is the
longer part of the major axis when the axis is divided by the
Fig. 4. Egg image rotation a) an egg image before rotation, where c is the centroid. This feature is denoted a in Fig. 5.
centroid, pmax is the farthest edge point from the centroid, and θ is the angle 8) The shorter semi major axis (b): This feature is the
between the egg major axis and the x-axis of the image, b) the egg image after shorter part of the major axis when the axis is divided by the
rotation c) the real input image before rotation, d) the real image after rotation.
centroid. This feature is denoted b in Fig. 5.
9) The semi major axis ratio (R): This feature is the ratio
between the shorter semi major axis and the longer semi major
axis as defined in (11).
(11)
10) to 13) The lengths of the diagonal lines (d1- d4): The
egg region is divided into 4 quadrants by its major and minor
axes. The lengths of the diagonal lines 1 to 4 are the lengths of
the diagonal lines of the 1st to 4th quadrants as illustrated in
Fig. 5
Fig. 5. Geometric parameter of egg image.
E. Machine Learning
The next process is first to determine the weight of the egg
D. Geometric features extraction in question and then to determine the size of the egg from the
Once the pre-processing is finished, the geometric features extracted by the previous steps. A linear regression
parameters of the egg region are computed. Thirteen geometric predictor is used for the first task, while a SVM classifier is
features are computed from the egg region. Fig. 5 shows some used for the second task using the 13 features computed from
the previous processes.
479
2017 14th International Conference on Electrical Engineering/Electronics, Computer, Telecommunications
and Information Technology (ECTI-CON)
480