Introduction

Freshness plays an important role in determining the quality of eggs and egg products1. It is the most relevant index used in the food industries, transportation and consumers use it to assess nutritional value and food products. Methods for measuring the freshness of eggs can be divided into two approaches: destructive and non-destructive measurement methods2. Destructive measurement methods are traditional, time-consuming biochemical methods (sensory indicators, Haugh unit, pH value, Yolk index and total volatile basic nitrogen). However, samples tested in this way cannot be reused. Therefore, only a few samples can be tested. There are several main advantages of non-destructive measurement of egg freshness, such as fast detection speed, no-pretreatment need for stripping eggshell and suitability for on-line detection3. As a result of the above advantages, nondestructive methods of egg freshness measurement have gained widespread attention.

Many non-destructive testing techniques have been proposed for the freshness assessment of eggs; such as assessments based on visible transmission spectroscopy4,5, near infrared (NIR) spectroscopy6,7,8,9, visible-near infrared (VIS–NIR) spectroscopy10,11,12,13,14, Fourier transform near infrared (FT-NIR) spectroscopy15, Raman spectroscopy16,17, dielectric properties18,19, electronic nose (E-nose)20,21,22,23,24,25,26,27, hyperspectral images28,29,30, ultrasound31, and machine vision32,33,34,35. Egg freshness testing techniques based on spectroscopy (visible, NIR, VIS–NIR, FT-NIR and Raman) are fast, efficient and nondestructive approaches, but they cannot evaluate the internal quality of eggs directly and might be affected by the eggshell (color and thickness of the eggshell) or environmental factors (temperature, humidity and stability of illuminating light). Evaluating egg freshness by their dielectric properties is another interesting non-destructive testing technique. However, there are still problems with the variability in egg shapes and mass. As well as the duplication of measurements that cannot be guaranteed. Egg freshness testing techniques based on an electronic nose provide a rapid and non-destructive method, but it is not sensitive enough to acquire the smell information produced by different degrees of freshness from an intact egg. Testing egg freshness using hyperspectral imaging is another non-destructive technique. However, such techniques require a fast computer, sensitive detector and large storage capabilities for analyzing hyperspectral data. Egg freshness testing techniques based on the ultrasound are classified as nonthermal treatments. Nevertheless, this technique produces free radicals, which can negatively impact and damage the product quality due to oxidation and there are difficulties selecting the appropriate parameters to obtain the accuracy and precision in detection. Nowadays, machine vision is one method that can be used to detect egg freshness that has many advantages such as fast, online estimation and non-destructive methodology. Egg freshness determination using machine vision proposed by Cai et al., had the advantage is that it can be measured dynamically32. However, this method also has errors caused by mechanical vibration during measurement. In addition, the system did not evaluate egg grading alongside the freshness measurement. Qinghua et al. proposed the detection of cracked eggs by machine vision which is a simple and intelligent system33 but this study also did not analyze the freshness and grade of eggs in the measurement system. Egg freshness determination using machine vision was proposed by Wang et al.34 and Soltani et al.35. The advantages of both proposed methods are a simple system that can measure freshness in a variety of ways. However, both proposed systems lacked a study of the classification of eggs by the system. We perceive that non-destructive measurements of egg freshness and grade discrimination in the same system based on real-time weight and density measurement principles have not been proposed before. This technique is simple and effective. It can also solve the problem of egg freshness measurement in water displacement and flotation that is not suitable for practical monitoring of products because the eggs absorb water; and this can be considered intrusive or destructive and can affect the test35. In order to easily recognize the quality and freshness of eggs at a lower cost, non-destructive, non-invasive and real—time monitoring is desirable. We therefore present the design, validation and development of the grade and freshness assessment of eggs by weight and density using load cell detection and machine vision techniques in this work.

Materials and methods

Egg samples

The eggs used for the test were 107 fresh eggs from the farm of Mahasarakham University, Mahasarakham province, Thailand. The samples were divided into two subsets consisting of a calibration set and a model set. Calibration sets were used to proposed system calibration, while a model set was used to create mathematical models and test the accuracy of the models. The calibration set contained 20 samples, the remaining 87 samples constituted the model set. The model sets contained 87 samples in which the eggs were divided into 5 groups based on weight and size, size classification number 0, jumbo (70–100 g), size classification number 1, extra-large (65–69.99 g), size classification number 2, large (60–64.99 g), size classification number 3, medium (55–59.99 g) and size classification number 4, small (50–54.99 g).

Density measurement system and calibration

It is well known that the egg freshness can be measured by the floatation method in which eggs are placed in a glass or container of water which is a simple initial test of egg freshness36. But this method requires a long time to prepare the equipment and to test it. It is also inappropriate for testing large numbers of eggs in a short time. In addition, it was observed that the relationship between density and the principle egg freshness from such methods has not been clearly studied and modeled. The relationship between density and egg freshness are investigated in this work. In addition, egg freshness is determined using the float method, which is a destructive measurement and can affect the measurement results. Because the eggs absorb water during the measurement process, this problem can be solved by the techniques presented. The density formula is as follows:

$$ \rho = \frac{m}{V} $$
(1)

where ρ is density, m is mass and V is volume.

The density measurement system and calibration are shown in Fig. 1. The measurement system was divided into three parts. The first part was the weight determination of load cell and was calibrated with a digital weighing scale. The second part was the volume determination by machine vision (length, breadth and volume) and calibrated by Vernier caliper. The third part was the density determination, the weight from the first part and the volume of the second part were used to calculate egg density based on Eq. (1) and calibrated by Eureka can. The total parameters were measured, analyzed, recorded and displayed by computer as shown in Fig. 2. The schematic display on the computer screen consisted of picture, weight, length, breadth, volume, density, size classification number and percentage of egg freshness.

Figure 1
figure 1

System detection for density assessment of eggs.

Figure 2
figure 2

Measurement of weight and calibration.

Weight measurement

The 20 eggs samples came directly from the chicken farm of Mahasarakham University and were divided into 4 groups based on weight of eggs, size classification number 1 (8 egg), size classification number 2 (2 egg), size classification number 3 (6 egg) and size classification number 4 (4 egg). On the first day, the weight, length, breadth and volume of 20 samples were measured using standard instruments and the proposed method. A load cell sensor was used to detect the weight of the eggs in this system; it was interfaced with as an Arduino board for converting analog signals to digital signals. The digital signals were recorded and analyzed by personal computer. The accuracy of the proposed system was checked by a digital weighing scale. The results obtained by the digital weighing scale and the load cell sensor are compared in Fig. 2. It was determined that both measurement techniques had a reasonable level of agreement with the averaged relative error being 0.12% (accuracy was 99.88%) and the maximum relative error being 0.33% in linear measurements (accuracy was 99.67%). The slope of the regression value for the linear regression of egg weight was 0.9949 and the coefficient of determination (R2) value was 0.9999. A possible contributory source of this measurement error might be difference load cell assembly and load cell resolution. However, the level of error is small and considered to be acceptable.

External physical characteristic measurement

Image processing techniques used to measure the length and width of the eggs are illustrated in Fig. 3a, while Fig. 3b shows the actual generation system. The system was divided into two parts. The first part was the hardware and the second part was the control program. The system’s measuring components were housed in a black box, lamp, camera, load cell and Arduino board. The creation of a uniform light around the sample was important and required carefully design. Accordingly, in order to provide suitable illumination and to eliminate the effects of environmental noises, a black rectangular box of 20 × 20 × 30 cm was fabricated. A 15 W LED lamp was installed at the top of the box. A camera was used and fixed approximately 20 cm above the egg sample. The camera had 680 × 480 pixels in horizontal and vertical directions, respectively. The camera was attached to a personal computer through a LabVIEW program.

Figure 3
figure 3

The proposed system (a) design system and (b) build system.

The image processing system that was used in this study is shown in the block diagram in Fig. 4a. In the first step, the camera detects image sample. In the second step, the noise was removed from the input image. In the third step, the image color was converted to grayscale. In the fourth step, the edge image of eggs was detected and the length (L) and breadth (B) of eggs was determined as shown in Fig. 4b. In the fifth step, the length and breadth of eggs were used to calculate volume and displayed as is shown in Fig. 4c. The length and breadth of the egg were determined using an egg shape measurer and their SI37,38:

$$ SI = \left( \frac{W}{L} \right) \times 100\% $$
(2)
Figure 4
figure 4

Egg parameters for calculate SI and V (a) image processing step, (b) measured parameters and (c) calculated volume and display parameters.

The mathematic model for calculating the volume of an egg based on image processing is as follows39:

$$ V = \frac{{\pi LB^{2} }}{6} $$
(3)

where V is the volume (mm3), length is L (mm), and the maximum breadth is B (mm).

The length and breadth are used to calculate the shape index (SI) and volume of eggs. A Vernier caliper was used to check the accuracy of the proposed method. The results obtained by the image processing and Vernier caliper are compared in Fig. 5. It was determined that the length and breadth of both measurement techniques had a reasonable level of agreement with the averaged relative error being 0.57% (accuracy was 99.43%) and 0.67% (accuracy was 99.33%), respectively. While the maximum relative error being 1.70% (accuracy was 98.30%) and 1.55% (accuracy was 98.45%) in linear measurements, respectively. The slopes of the linear regression obtained from the relationship between length and width were 1.0662 and 1.0928, with determination coefficients (R2) of 0.9599 and 0.9946, respectively. There are several possible sources which might contribute to the measurement errors. The first two are the instrumental error and observation error. The third may be from the perspective effect along the optical path of the camera which could cause small variations of the length and breadth conversion coefficients across an image of the egg. However, the level of error is small and considered acceptable.

Figure 5
figure 5

Measurement of external physical characteristic and calibration (a) length and (b) breadth.

The volume and density determination based on Archimedes' principle and the imaging processing are compared in Fig. 6a and b, respectively. It was found that the volume and density determined by both measurement techniques had a reasonable level of agreement with the averaged relative error being 1.74% (accuracy was 98.26%) and 0.98% (accuracy was 99.02%), respectively. While the maximum relative error was 3.25% (accuracy was 96.75%) and 2.80% (accuracy was 97.20%) in linear measurements. The slopes of the linear regression obtained from the relationship between length and breadth were 1.0108 and 0.9638 with the coefficient of determination (R2) value being 1.0055 and 0.7715, respectively. There are several possible sources of measurement errors. The first two are instrumental error and observation error. The third may be from the perspective effect along the optical path of the camera which could cause small variations of the length and breadth conversion coefficients across an image of the egg. The fourth may be due to cumulative errors caused by weight measurements and physical features that have occurred in previous processes. The fifth may be due to an error caused by the density determination based on the Archimedes' principle measurement process. However, the level of error was small and considered acceptable.

Figure 6
figure 6

Measurement of volume and density of egg (a) volume and (b) density.

The average relative error, the maximum relative error, accuracy, slope, R2, RMSEC (root mean square error calibration) and RPD (residual prediction deviation) of weight and external physical characteristic measurement are shown in Table 1.

Table 1 The relative error, accuracy, statistical indicator and relationship of weight and external physical characteristic measurement of eggs.

Results and discussion

Weight as function of storage time

The 87 eggs were divided into 5 groups; size classification number 0, 1 egg (weight 76.60 g); size classification number 1, 8 eggs (average weight 66.79); size classification number 2, 32 eggs (average weight 62.33 g); size classification number 3, 41 eggs (average weight 57.75 g) and size classification number 4, 5 eggs (average weight 53.65 g). The weight, length, breadth and volume of the 87 eggs of the model set were measured daily for 30 days. Figure 7a–e shows the relationship between storage time and normalized weight of egg, and the linear regression and average linear regression between weight of eggs in the each size. The results clearly demonstrate that the weight of eggs in all size classes decreased linearly with the storage time. The experiment results clearly showed that eggs that were kept at room temperature for 30 days experienced a reduction in egg weight of 0.0023–0.0031 times the initial weight. The average linear regression between weight and storage time of eggs in the each size classification number and R2 values were calculated, as shown in Table 2. The slope of the regression values for the size classification numbers 0, 1, 2, 3 and 4 are −0.0023, −0.0028, −0.0029, −0.0031 and −0.0028 and the R2 values were 0.9982, 0.9995, 0.9996, 0.9996 and 0.9994 for validation, respectively.

Figure 7
figure 7

Weight as function on storage time (a) size classification number 0, (b) size classification number 1, (c) size classification number 2 (d) size classification number 3, (e) size classification number 4 and (f) all size classification numbers.

Table 2 Linear regression equation between weight of size classification numbers 0, 1, 2, 3 and 4 with storage time.

Figure 7f shows average linear regression of egg in all sizes. The linear regression equation and the R2 of all size classification numbers are shown in Table 2, where Y is normalizing of weight and x is time (day). The results showed that egg size, classification number 3 had the highest rate of weight loss. This may be because it had physical properties that allowed water to evaporate more easily than other egg sizes. Egg size classification number 0 have the lowest weight loss rate compared to other egg sizes. However, the exact cause of this issue has not been proven conclusively in this study, and requires future study.

The relationship between weight and density

Figure 8a–e show the relationship between weight and density with the storage time for egg size, classification numbers 0 to 4. It is clear that the weight and density varies directly with the storage time. The weight and density of eggs decreased with increased storage time. Egg weight and density decreased during storage due to the loss of water evaporating through thousands of pores in the eggshell surface40. Over time, the spongy epidermises of the eggshell begin to dry and shrink. This causes the pores of the eggshell to increase in size and number and his makes it easier for gas and moisture to escape from the egg. As a result, the weight of the eggs decreased with longer storage periods. The environment (temperature and humidity) plays a key role in the loss of moisture from the eggs by evaporation. Carbon dioxide is lost through the pores of the shell while oxygen enters the egg and creates bubbles inside instead of moisture and carbon dioxide. As a result of this, the egg weight and density are reduced41. The relationship between normalized weight and density of eggs of all sizes was linear, as shown in Fig. 8f. The relationship between egg size and the means of weight, length, breadth, shape index, volume and density of eggs at the time of maximum freshness is shown in Fig. 9. The data on egg size and physical properties are shown in Table 3. The results clearly show that weight, length, breadth and volume decreased with increased egg size. On the other hand, it was found that the shape index increased with increasing egg size. This is because the length of the egg has a higher rate of reduction than the width as the egg size increases.

Figure 8
figure 8

Weight and density as function of storage time (a) size classification number 0, (b) size classification number 1, (c) size classification number 2 (d) size classification number 3, (e) size classification number 4 and (f) relationship between normalized weight and density of all eggs sizes.

Figure 9
figure 9

Relationship between egg size with the means of weight, length, breadth, shape index, volume and density of the eggs at the time of maximum freshness.

Table 3 The egg size and physical properties of the eggs examined at the highest egg freshness.

The results clearly showed that the eggs of each size class had different moisture loss rates and initial freshness. The results showed that eggs of size classification number 1 had the highest initial density, but had a narrow weight and density range. Eggs of size classification number 4 had the lowest initial density, but had a wide weight and density range. Egg size classification number 0 has the narrowest range of weight and density, while the rate of moisture loss and primary freshness of egg size, classification numbers 0, 2, 3 and 4 were similar.

The relationship between freshness and density

The relationships between density and percentage of egg freshness to the storage time of all egg sizes are shown in Fig. 10a–e. The results clearly showed that the egg density and percentage of freshness were linearly related, the R2 values were as large as 0.9982, 0.9999, 0.9996, 0.9996 and 0.9994 for egg size, classification numbers 0, 1, 2, 3 and 4, respectively. We developed and presented the Egg Freshness Equation in percentage form in this study, as shown in Eq. (4).

$$ Freshness\mathop {}\limits^{{}} (\% ) = \frac{{\rho_{E} }}{{\rho_{HE} }} \times 100\mathop {}\limits^{{}} \% $$
Figure 10
figure 10

Freshness as function of density (a) size classification number 0, (b) size classification number 1, (c) size classification number 2 (d) size classification number 3, (e) size classification number 4 and (f) the range of freshness.

where \(\rho_{{\text{E}}}\) is the density of the eggs tested after they were stored at different times.

\(\rho_{{{\text{HE}}}}\) is the initial density (the highest freshness) of each egg size.

The results showed that the densities of eggs of each size at first laying had a different freshness as shown in Fig. 10f. We averaged the initial densities for each egg size using the sensed changed freshness of eggs in each egg size class as shown in Table 3. It is clear that freshness and density were linearly related in all egg sizes. The results clearly showed that the maximum densities of all egg sizes were in the range of 1061.63 × 10–6 (g/mm3) – 1090.00 × 10–6 (g/mm3) and the mean of maximum density was 1072.60 × 10–6 (g/mm3). The minimum densities of all egg size were in the range of 961.70 × 10–6 (g/mm3) – 1001.40 × 10–6 (g/mm3) and the mean of maximum density was 983.41 × 10–6 (g/mm3). The difference between the mean of maximum density and mean of minimum density was 98.19 × 10–6 (g/mm3). We would like to divide the range of freshness based on density into three grades, high, medium and low freshness as shown in Fig. 10f. Therefore, the difference of mean maximum and minimum divided by three is 29.73 × 10–6 (g/mm3). This value was then used as a criterion for dividing egg freshness into 3 ranges for grading: high freshness (> 1042.87 × 10–6 (g/mm3), medium freshness (1013.14 × 10–6 (g/mm3) – 1042.87 × 10–6 (g/mm3)) and low freshness (< 1013.14 × 10–6 (g/mm3)).

Comparison with other machine vision system

A comparison of grades and freshness assessment of eggs in this work and using other machine vision methods is reported in Table 4. Machine vision reported in Ref.32 and Ref.34 was proposed for determination of egg freshness through the dynamic weighing, area ratio of egg yolk, area ratio of air room and height ratio of air room, which is presented egg freshness sensing same as proposed in this work, but it is not proposed graded method and clearly divided freshness range. The sensing of cracked eggs is based on length, breadth and LFI index as proposed in Ref.33, but freshness was not tested graded of eggs was not reported. Ref.35 proposed egg quality sensing through diameter and volume detection, which is presented as egg freshness sensing based on volume detection. This approach was the same as proposed in this work, but did not propose a grading method and clearly dividing the freshness range based on density and weight.

Table 4 The comparison of difference sensor for egg freshness detection based on machine vision.

Conclusions

A freshness assessment and grading of eggs by weight and density are presented in this work. Egg grading is classified into five grades by using weight as a sorting criterion. The freshness of eggs was divided into 3 periods: high, medium and low freshness, using density as the criterion. The proposed system can be used effectively for non-destructive, non-invasive detection that is low cost, low weight, small size, flexible and easy to operate. Moreover, it can be record data, analyze data, monitor physical characteristics and classify egg freshness in real time. This proposed measuring system is potentially important for the poultry industry and biological research in the future.