0% found this document useful (0 votes)
151 views4 pages

Egg Weight Prediction and Egg Size Classification Using Image Processing and Machine Learning

This document summarizes a research paper presented at the 2017 14th International Conference on Electrical Engineering/Electronics, Computer, Telecommunications and Information Technology. The paper proposes using image processing and machine learning techniques to predict chicken egg weight and classify egg size from a single egg image. Key steps include segmenting the egg from the image, extracting geometric features, and using linear regression to predict weight and support vector machines to classify size. Experimental results showed high accuracy in predicting weight and classifying egg size number.

Uploaded by

ronniesolomon258
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
151 views4 pages

Egg Weight Prediction and Egg Size Classification Using Image Processing and Machine Learning

This document summarizes a research paper presented at the 2017 14th International Conference on Electrical Engineering/Electronics, Computer, Telecommunications and Information Technology. The paper proposes using image processing and machine learning techniques to predict chicken egg weight and classify egg size from a single egg image. Key steps include segmenting the egg from the image, extracting geometric features, and using linear regression to predict weight and support vector machines to classify size. Experimental results showed high accuracy in predicting weight and classifying egg size number.

Uploaded by

ronniesolomon258
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

2017 14th International Conference on Electrical Engineering/Electronics, Computer, Telecommunications

and Information Technology (ECTI-CON)

Egg Weight Prediction and Egg Size Classification


using Image Processing and Machine Learning

Jeerapa Thipakorn, Rattapoom Waranusast, Panomkhawn Riyamongkol


Department of Electrical and Computer Engineering
Faculty of Engineering, Naresuan University, Phitsanulok, Thailand
[email protected], [email protected], [email protected]

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

1 Extra Large More than 65 to 70 III. THE PROPOSED SYSTEM


2 Large More than 60 to 65
A. System Overview
3 Medium More than 55 to 60
An overview of our system is shown in Fig.1. The input
4 Small More than 50 to 55 image is captured from a candled egg using a digital camera in
a dark room. The first step in the process is to resize the egg
5 Pee Wee More than 45 to 50
image and to segment the image from the background. The
segmented egg image is then rotated to align the major axis of
In this paper, we propose algorithms to determine weight the egg as the x-axis of the image. The major axis of an egg is
and size to grade eggs according to these standards. Image defined by a line drawn from the egg’s centroid to the farthest
processing techniques are applied to extract features from the edge point of the egg. The geometric parameters of the egg
geometric parameters of an egg image. Two machine learning image are calculated and are then used in a linear regression
techniques, one applied to the regression problem and the other equation to predict egg weight and in a Support Vector
to the classification problem, predict egg weight and classify Machine to classify egg size number.
the eggs according to size.

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)

threshold operation is used to segment the egg region from the


background. A binary image is created in which ‘1’s represent
pixels in the egg region and ‘0’s represent pixels of the
background. Median filtering is performed on the binary image
to reduce noise. Finally, the segmented egg region is labeled by
the connected component labeling technique.

(a) (b)

Fig. 1. Overview of the proposed system

Camera stand (c) (d)

Fig. 3. The input egg image; a) input color image, b) R component, c) G


Camera component, d) B component

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)

features directly extracted from the egg region. The following


equations for the 13 features are shown below.
1) The length of the egg perimeter (|P|): The perimeter is
defined as a set of connected pixels. Hence, perimeter length
(6) is computed by accumulating the 1’s for each horizontal and
vertical neighbor, and for diagonal neighbors [9].
2) The area of the egg region (A): The area of the egg
region is defined as

(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)

IV. EXPERIMENTAL RESULTS V. CONCLUSIONS


The image acquisition was started by using the egg The algorithms for predicting egg weight and classifying
candling technique. The light source was a 3.5 watts LED light egg size from an image, using the combination of image
bulb. The egg image was acquired through a mirrorless processing and machine learning techniques, are proposed in
interchangeable lens camera (Sony a5100). The camera was set this paper. Thirteen features are extracted from an egg image
to manual mode with 0.5 sec shutter speed, f/5.6, ISO 500, and are used in prediction and classification using linear
daylight white balance, with manual focus at 33mm. The regression and SVM. The experimental results showed a strong
algorithms were implemented with OpenCV library [12] in correlation between the predicted weight and the real weight,
C++ language on Windows 10 operating system. The machine with r = 0.9915 and egg size classification accuracy of 87.58%.
learning algorithms were tested using Weka [13]. A total With a larger image dataset and more egg geometric features,
number of 314 brown chicken eggs of varying sizes were used this accuracy would be increased.
in this research. Each egg was manually weighed, in grams,
with a digital scale, and height and width measured, in VI. FUTURE WORK
millimeters, with a vernier caliper. To train the predictor and
the classifier, the eggs were manually classified into six egg Since the quality of an egg is not limited to its size, in the
sizes based on the ACF Standards that resulted in 52 Jumbo further study, we plan to develop algorithms to determine the
eggs, 44 Extra-large eggs, 64 Large eggs, 53 Medium eggs, 54 freshness, the shape, and the impurities on the egg shell to
Small eggs, and 47 Pee-wee eggs. Two experiments were estimate an egg’s quality by its image.
conducted to analysis the effectiveness of our egg weight
prediction and egg size classification algorithms. ACKNOWLEDGMENT
Many thanks to Mr. Roy Morien of the Naresuan
A. Eight Weight Prediction University Language Centre for his editing assistance and
This experiment applied the linear regression analysis to advice on English expression in this document.
predict egg weight (in grams). The thirteen geometric attributes
applicable to eggs were used to predict the weight of the test REFERENCES
egg. The 10-fold cross-validation technique was used to train
[1] ACFS, “Thai Agricultural Standard TAS 6702-2010,” 2010.
the model and to test the results. The results showed a strong
[2] M. Soltani, M. Omid, and R. Alimardani, “Egg volume prediction using
correlation between the predicted weight and the real weight machine vision technique based on pappus theorem and artificial neural
with the correlation coefficient r = 0.9915. The linear network,” vol. 52, no. May, pp. 3065–3071, 2015.
regression equation giving the egg weight prediction is: [3] M. H. Raoufat and V. Asadi, “Estimation of Egg Weight By Machine
Vision and Neural,” pp. 1–8, 2010.
Egg Weight = (-158.878) + 85.1316(C)
[4] P. Javadikia, M. . Dehrouyeh, L. Naderloo, H. Rabbani, and A. .
+ 0.1419(P) + (-0.1024)(h) Lorestani, “Measuring the Weight of Egg with Image Processing and
+ 0.2827(w) + (-0.8001)(SI) ANFIS Model,” Lect. Notes Comput. Sci. (including Subser. Lect. Notes
+ (-0.3511)(a) + (-0.0004)(A) Artif. Intell. Lect. Notes Bioinformatics), vol. 7076, no. PART 1, pp.
+ 0.1297(r3) + 0.2331(r4) (12) 618–625, 2011.
[5] M. Rashidi and M. Gholami, “Prediction of egg mass based on
TABLE II. RESULTS OF SIZE CLASSIFICATION EXPERIMENTS. geometrical attributes,” Agric. Biol. J. North Am., vol. 2, no. 4, pp. 638–
644, 2011.
Accuracy [6] R. Waranusast, P. Intayod, and D. Makhod, “Egg Size Classification on
No. Size class Number Correct Incorrect
(%) Android Mobile Devices U sing Image Processing and Machine
0 Jumbo 52 47 5 90.38% Learning,” pp. 0–3, 2016.
1 Extra-large 44 35 9 79.54% [7] M. Rashidi, M. Gholami, and S. Abbassi, “Cantaloupe volume
determination through image processing,” J. Agric. Sci. Technol., vol.
2 Large 64 51 13 79.69% 11, no. 5, pp. 623–631, 2009.
3 Medium 53 47 6 88.68% [8] R. Fellegari and H. Navid, “Determining the orange volume using image
4 Small 54 49 5 90.74% processing,” vol. 9, pp. 180–184, 2011.
[9] L. G. Shapiro and G. C. Stockman, Computer vision. Prentice Hall,
5 Pee wee 47 46 1 97.87%
2001.
Total 314 275 39 87.58% [10] P. C. Panda, “Shape and texture,” in Textbook on Egg and Poultry
Technology, 3rd ed., New Delhi: Vikas Publishing House Pvt. Ltd,
B. Egg Size Classification 1996, p. 57.
The egg size classification used the Support Vector [11] M. Duman, A. Sekeroglu, A. Yildirim, H. Eleroglu, and O. Camci,
Machine algorithm to classify an unknown egg into six sizes “Relation between egg shape index and egg quality characteristics,”
Europ.Poult.Sci, no. February, 2016.
(classes) using 13 features. The grid-search algorithm was used
[12] G. Bradski, “The OpenCV Library,” Dr. Dobb’s J. Softw. Tools, 2000.
to select the optimal model parameters. The 10-fold cross-
[13] E. Frank, M. A. Hall, and I. H. Witten, “The WEKA Workbench. Online
validation technique was used to train the model and to test the Appendix,” in Data Mining: Practical Machine Learning Tools and
results. The results showed average accuracy of 87.58 %, as Techniques, 4th ed., Morgan Kaufmann, 2016.
shown in Table II.

480

You might also like