Egg Freshness Detection Based On Digital Image Technology: Full Length Research Paper
Egg Freshness Detection Based On Digital Image Technology: Full Length Research Paper
Yolk index and air room height, two main measures for egg freshness detection, are very difficult to
be accurately measured in practices. This paper investigated an image-based egg freshness
detection method. The perspective image of egg was obtained by computer vision device. The
characteristic regions, including the yolk region and air room region were separated from the
obtained egg picture by image processing. The pixel areas and lengths of the above characteristic
regions were respectively calculated and analyzed. The relative ratios of the pixel area and length
of characteristic regions to that of the whole egg region were selected as characteristic parameters.
It was shown that the above relative ratios increased while egg freshness reduced according to a
detailed analysis. Three detection models of egg freshness were set up based on the correlations
between the characteristic parameters and freshness. The test results showed that the accuracy
rates of these models were 93, 94 and 92% respectively. The egg freshness detection based on
image characteristic of yolk and air room was efficient and feasible.
Key words: Egg yolk, air room, freshness, digital image, computer vision.
INTRODUCTION
Egg freshness detection is an interesting and important and penetrates into yolk. This process continues until the
topic in the food safety researches, mainly due to the fact yolk membrane is completely broken up because of the
that egg is closely related to the everyday lives of com- reduction of membrane elasticity (Zhu, 1985; Geng,
mon people and egg content changes easily during 1998). There is no air room in the newborn egg. When
storage. Many researches have focused on egg fresh- the egg cools down, the egg content will shrink, which
ness detection over the last decade. leads to the formation of air room. The size of air room
Egg content mainly consists of yolk, albumen and air can increase due to water evaporation, the CO2 dissi-
room. There is a layer of yolk membrane between yolk pation and the drying shrinkage of egg contents. At the
and albumen. With the extension of storage time, mois- same temperature and humidity, the longer the storage
ture of albumen gradually evaporates from the shell pores time, the larger the air room size is (Zhang, 1998). So
yolk index and air room height can be viewed as main
measures of egg freshness.
Yolk index is the ratio of egg yolk’s height to its dia-
*Corresponding author. E-mail: [email protected]. Tel: meter, which can only be measured by breaking the egg,
+86-027-87285346. Fax: +86-027-87285346. whereas the height of air room is usually accessed by
1074 Sci. Res. Essays
Egg samples
Clean and fresh eggs, four hundred in total were collected from
Hatchery in Huazhong Agricultural University. All of the eggs were
numbered and stored in biochemical incubator at 25°C.
Experimental system
b
a b c d
Figure 5. Image processing of egg yolk (a-Binary image of G
component, b-Median filtering, c-Dislodge small points in
foreground, d-Fill egg yolk region).
c
a b c
Figure 6. Gray scale image of HIS (a-H, b-S, c-I).
Figure 4. Gray scale image and it histogram image, so a filter could be selected for image denoising.
equalization of G-component. Medium filtering is a non-linear method of noise reduction.
Figure 5-b was the result of medium filtering for the egg
yolk image using a 5 x 5 template.
There were still some stray points around the yolk in
for all the histograms of R-, G- and B- component, in which image. Dislodge those small points in foreground through
the pixel values centralize in several ranges. Thus the opening operation (Figure 5-c). Some pores still existed
gray scale image of the G-component was selected to in yolk region after filtering, which would bring large error
separate the yolk region from the whole egg image. when calculating yolk’s area. Thus, it was necessary to fill
However, its most gray levers were lower than 100, and egg yolk region to obtain the full yolk image (Figure 5-d).
the image contrast was not strong. To enhance image
contrast, the data mapping was used to extend the gray Separation of air room: RGB and HSI are two
levers to the range of [0, 255]. According to the gray commonly used color models in image processing. In this
lever changes, the histogram equalization was adopted to research the HSI model was selected to deal with the air
enhance the gray scale image and its histogram was room according to the former experimental experience.
shown in Figure 4. As a result, the region of egg yolk Figure 6 was the gray scale image of H, S, I.
could be clearly viewed in Figure 4. It could be viewed from Figures 6-c and 7-a that the air
However, it was still very difficult to calculate the yolk room of I-component was more obvious than others (H-
area from Figure 4. For segmenting the yolk region, the and S-component), so the gray scale image of I-compo-
binary image of egg was obtained with the binary proce- nent was chosen for subsequent processing in this
dure controlled by a threshold. The threshold was selec- research. The feature of air room was more obvious after
ted based on the histogram of gray scale image. The adaptive contrast enhancement (Figure 7-b) and image
result was shown in Figure 5-a. binarization (Figure 7-c).
Various kinds of noises existed in the obtained digital It is required to extract the characteristic parameters:
1076 Sci. Res. Essays
a b c
Figure 7. Image processing of I (a-Gray scale image, b-
Adaptive contrast enhancement, c- Binary image). Figure 9. Edge detection by Newton's Dichotomy.
points. In this research, Newton's Dichotomy was used to A= dxdy = ( ptiR .x − ptiL .x + 1)
detect the edge between backgrounds and objects rapidly, ( x , y∈object ) i = pt0 . y
(1)
Wang et al. 1077
0. 8 0. 16 0. 3
0. 7 0. 14
0. 4 0. 08 0. 15
0. 3 0. 06
0. 1
0. 2 y = - 0. 0094x + 1. 0549 0. 04
2
R = 0. 9884 0. 05 y = - 0. 0037x + 0. 3989
0. 1 0. 02 2
R = 0. 9745
0 0 0
30 50 70 90 110 30 50 70 90 110 30 50 70 90 110
haugh uni t haugh uni t haugh uni t
a b c
Figure 10. Relationship between ratio and Haugh unit (a-Area ratio of egg yolk and Haugh unit, b-Area ratio of air room and
Haugh unit, c-Height ratio of air room and Haugh unit).
Where PtiL and PtiR , is the left and right edge point of vertical axis. Then scan the long axis from bottom to top
using Newton's Dichotomy, from which the longitudinal
the ith line of feature region respectively,
coordinate values of top and bottom points were obtained.
PtiR x − PtiL x + 1 is the sum of pixels of the ith line, Pt0 The difference of the above two values is the length of
and Pt1 are the highest and lowest point of the feature the whole egg.
The height of air room could be calculated by the same
region respectively. Yolk area and air room area can be method. Finally, the obtained data are shown in Table1.
calculated by the same method.
Calculation of pixel length: Air room is located in the Data analysis and modeling
blunt end of egg, whose height is the length in long axis
direction when the image is put upright. The specific In this section, three correction equations between Haugh
algorithm is presented as follows: unit and characteristic parameters were established by
classical statistical analysis method.
Step 1: Calculate the image centroid according to the The relationship between the area ratio of egg yolk and
formula (2): Haugh unit is shown in Figure 10-a. The obtained
equation is as follows:
x[ f ( x) − g ( x)]dx
b
M
X= Y = a
y1 = −0.0094 x + 1.0549,R 2 = 0.9884 ,
[ f(x) − g(x)]dx
b
M
a (2)
Where x is Haugh unit, y1 is the area ratio of egg yolk;
The calculation procedures are as follows:
The relationship between the area ratio of air room and
(1) The x-value was got after scanning any point in a Haugh unit is shown in Figure 10-b. The obtained
image, then the pixel integral xdA was obtained; equation is as follows:
(2) The surface density of plane image is regarded as unit y 2 = 0.5517e −0.0359 x , R 2 = 0.993 ,
1 and the image mass is calculated by integration which
is equal to image area in value; Where x is Haugh unit, y2 is the area ratio of air room;
(3) The quotient of the two values was obtained;
(4) Scan and calculate all pixel points, then sum the feed- The relationship between the height ratio of air room and
back results to calculate the abscissas value of centroid. Haugh unit is shown in Figure 10-c. The equation is as
Step 2: The long axis passing centroid was defined as the follows:
1078 Sci. Res. Essays
y3 = −0.0037 x + 0.3989, R 2 = 0.9745 were randomly selected from different batch samples with
, the same variety and experimental procedure. After the
egg images were acquired, Haugh unit representing
Where x is Haugh unit, y3 is the height ratio of air room. freshness was obtained through experiment. Then the
It can be concluded from the equations that: the single characteristic parameters were calculated and put into
variable linear regression equation with high correlation the corresponding model. The results of calculation
coefficient can be established for the area ratio of egg based on model equations were compared with the mea-
yolk and Haugh unit, which is the same to the area ratio sured results, which indicated that the accuracy rate of
of air room and Haugh unit. However, the height ratio of the three models of the area ratio of egg yolk, the area
air room has high exponential correlation with Haugh unit. ratio of air room and the height ratio of air room was 93,
94 and 92% respectively.
(1) The egg yolk and air room were not obvious in the
original transmitted light images, but which can be clearly
viewed by the image processing method proposed in this