A nondestructive detection method for egg freshness based on spectral feature fusion
Patent Information
- Application Number
- CN202610820562.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-08
- Publication Date
- 2026-08-28
AI Technical Summary
然而,目前近红外检测鸡蛋新鲜度的方法仍存在一定不足:一是仅在鸡蛋单一部位(如赤道位置)采集光谱数据,未充分考虑赤道与端部在组织结构、透光路径及光谱响应上的差异,导致模型对鸡蛋新鲜度变化的表征不够全面;二是未校正鸡蛋直径大小的影响;鸡蛋直径大小直接影响其光谱信号,因此会对鸡蛋新鲜度的检测产生较大影响;三是光谱采集大多在静态条件下进行,缺乏静态与低速旋转采集条件差异所引入的额外信息
[0056] The beneficial effects of this invention are as follows: This invention utilizes egg diameter data to correct the spectrum, effectively reducing the impact of egg size differences on the detection results and improving the accuracy of egg freshness detection; by collecting near-infrared spectral information from the equatorial and tip positions of the egg under static and low-speed rotation conditions, it obtains spectral difference characteristics between different collection states and positions, and weights and fuses these difference characteristics to more comprehensively characterize changes in egg freshness, further improving the accuracy of egg freshness detection; in addition, by employing a weighted ensemble of partial least squares regression, extreme gradient boosting regression, random forest regression, and support vector regression models, it integrates the advantages of multiple models, improving the accuracy, stability, and robustness of egg freshness prediction results.
Smart Images

Figure QLYQS_39 
Figure QLYQS_47 
Figure QLYQS_52
Abstract
Description
Technical Field
[0001] This invention belongs to the field of internal quality testing of agricultural products, specifically relating to a non-destructive testing method for egg freshness based on spectral feature fusion. Background Technology
[0002] Eggs are one of the most consumed animal-based foods globally, rich in protein, vitamins, and minerals, and are highly popular among consumers. As people's demands for food safety and quality continue to rise, the freshness of eggs has become a crucial indicator affecting their market value and consumer acceptance. However, during the collection, transportation, storage, and sale of eggs, various factors such as temperature, humidity, and time cause a series of complex physiological and biochemical changes inside the egg, including protein degradation, moisture migration, pH changes, and yolk membrane rupture. These changes lead to decreased freshness, deterioration of internal quality, and even defects such as broken yolks, shell adhesion, and blood spots. These changes not only reduce their edible value but may also pose food safety risks.
[0003] Currently, traditional methods for testing egg freshness mainly rely on destructive testing. This involves breaking the eggshell, measuring the albumen height and weight, and then calculating the Haugh unit value to characterize freshness. A higher Haugh unit value indicates a fresher egg. While accurate, traditional methods are cumbersome, time-consuming, and require sample destruction, making them unsuitable for rapid, batch, and non-destructive testing. This fails to meet the online quality control needs of modern egg processing enterprises and distribution channels.
[0004] Near-infrared spectroscopy (NIR) offers advantages such as rapid detection, non-destructive sampling, and no contamination. It can characterize the overtone and combination frequency absorption characteristics of organic components like moisture, protein, and fat in a sample, making it suitable for the quantitative detection and evaluation of egg freshness. However, current NIR methods for detecting egg freshness have certain limitations: First, they only collect spectral data from a single location on the egg (e.g., the equator), failing to fully consider the differences in tissue structure, light transmission path, and spectral response between the equator and the extremities, resulting in an incomplete representation of changes in egg freshness. Second, they do not correct for the influence of egg diameter; egg diameter directly affects its spectral signal, thus significantly impacting freshness detection. Third, most spectral acquisition is conducted under static conditions, lacking the additional information introduced by the difference between static and low-speed rotation acquisition conditions. Under low-speed rotation conditions, the distribution of internal components such as protein within the eggshell varies depending on the freshness of the egg, thus introducing additional useful information for freshness detection. Therefore, the accuracy of near-infrared spectroscopy for detecting egg freshness is still limited, and there is an urgent need to further improve the accuracy of egg freshness detection. Summary of the Invention
[0005] To address the problems existing in the background technology, this invention proposes a non-destructive testing method for egg freshness based on spectral feature fusion. This method effectively eliminates the influence of egg diameter on freshness through diameter correction. Then, it comprehensively utilizes multi-position near-infrared spectral information from the equatorial and tip positions of the egg, combining low-speed dynamic rotation and static acquisition modes to construct multi-source spectral data. Through differential feature extraction and multi-level fusion modeling strategies, it significantly improves the prediction accuracy and model stability of egg freshness, thereby meeting the needs of egg processing and distribution for rapid, accurate, and online-applicable non-destructive testing technology.
[0006] The technical solution adopted by this invention to solve its technical problem is: a non-destructive method for detecting egg freshness based on spectral feature fusion, characterized in that the method comprises the following steps:
[0007] Step 1: Establishing an egg freshness prediction model;
[0008] Step 1.1: Collect whole egg samples with smooth surfaces and no external defects. indivual;
[0009] Step 1.2, in a static state, respectively... Near-infrared spectra of an egg sample were acquired at its equatorial position using a transmission method to obtain spectral absorbance information at the equatorial location. The spectral matrix is denoted as [formula missing]. ;
[0010] Step 1.3: Under static conditions, near-infrared spectroscopy is performed in transmission mode at a position between the equator and the tip of the egg sample, and at a distance of 3 / 4 from the equator, to obtain spectral absorbance information at the tip of the egg. The spectral matrix of the egg samples is denoted as . ;
[0011] Step 1.4: Rotate the eggs at a low speed. Low-speed rotation will not affect the freshness of the eggs. Then, proceed with... Near-infrared spectra of an egg sample were acquired via transmission at its equatorial position and at a position between the equator and the apex, and at a distance of 3 / 4 from the equator. The spectral matrices are denoted as follows: and ;
[0012] Step 1.5, for Three egg samples were collected, and their diameters were measured at the equator, and at a point three-quarters of the way from the equator between the equator and the apex. The diameter data were recorded as follows: and ;
[0013] Step 1.6, for A sample of eggs was taken, and its weight was measured. The weight data was recorded as follows: Then, each egg sample was cracked, and the egg white and yolk were completely placed into the special measuring tray of the egg freshness measuring instrument, allowing the egg contents to spread naturally. The egg white height was measured using the egg freshness measuring instrument, and the Hough unit value was calculated based on the egg weight. The Hough unit value of each egg sample was used as a freshness reference value, and its freshness Hough unit data was recorded as follows: ;
[0014] Step 1.7: To eliminate the influence of egg size on the near-infrared transmission spectrum, the spectrum is corrected using egg diameter data; the diameter data... and The data are then combined and normalized to convert the diameter data to the range [0,1]. The normalized diameter data are denoted as follows: and ;
[0015] Step 1.8: The larger the diameter of the egg, the more spectral information it absorbs, and the greater its absorbance value; therefore, the spectral matrix... , Divide by the normalized diameter data respectively To correct for the effect of egg diameter on the spectrum, the corrected spectral matrix is denoted as... and ; spectral matrix and Divide by the normalized diameter data respectively To correct for the effect of diameter on the spectrum, the corrected spectral matrix is denoted as... and ;
[0016] Step 1.9: To eliminate baseline drift and reduce the effects of noise and scattering on the spectrum, a combination of baseline drift correction, Savitzky-Golay smoothing, and multivariate scattering correction (MSC) is used to adjust the spectral matrix. , , , Spectral preprocessing was performed, including baseline correction of the spectral matrix, Savitzky-Golay smoothing, and finally multivariate scattering correction (MSC). The preprocessed spectral matrices are as follows: , , , ;
[0017] Step 1.10: To obtain the spectral difference information of the egg under static and low-speed rotation conditions, the difference between the spectra of the egg under static and low-speed rotation conditions at the same acquisition location is calculated to obtain the spectral difference characteristics reflecting the acquisition conditions between static and low-speed rotation; the spectral feature matrix of the acquisition condition difference at the equatorial position is denoted as... The spectral feature matrix of the difference in acquisition conditions at the tip position is denoted as Its calculation expression is as follows:
[0018] ;
[0019] Step 1.11: Calculate the difference between the spectrum at the equator and the spectrum at the tip of the egg to obtain a spectral feature matrix reflecting the difference in sampling location; first, calculate the spectral matrix at the equator. With spectral matrix The average value, i.e. Then calculate the spectral matrix at the tip of the egg. With spectral matrix The average value, i.e. Finally, subtract the two to generate the spectral feature matrix of positional differences, denoted as . Its expression is as follows:
[0020] ;
[0021] Step 1.12, obtain the spectral matrix of the equatorial position. Spectral matrix and spectral feature matrix The features are stitched and fused along the feature dimension to form a fused feature matrix at the equator. Its expression is as follows:
[0022] ;
[0023] Step 1.13, obtain the spectral matrix at the tip position. Spectral matrix and spectral feature matrix The features are stitched and fused along the feature dimension to form a fused feature matrix at the tip position. Its expression is as follows:
[0024] ;
[0025] Step 1.14: Merge the equatorial feature matrix Each feature variable is multiplied by its weight coefficient. The weighted equatorial fusion feature matrix is obtained; the tip fusion feature matrix is then obtained. Each feature variable is multiplied by its weight coefficient. The weighted end-fusion feature matrix is obtained; the position difference spectral feature matrix is then used to obtain the weighted end-fusion feature matrix. Each feature variable is multiplied by its weight coefficient. The weighted positional difference feature matrix is obtained; the three weighted fusion feature matrices are concatenated and fused along the feature dimension to form the final fusion feature matrix, denoted as F, whose expression is as follows:
[0026]
[0027] in , , To integrate the weighting coefficients, the following conditions must be met:
[0028]
[0029] And the range of values for the fusion weight coefficient is:
[0030]
[0031] Preferably, , , ;
[0032] Step 1.15: To improve the prediction accuracy and stability of egg freshness, a weighted ensemble of the prediction outputs from multiple models is used to obtain the final predicted value of egg freshness. Using the final fused feature matrix F as the model input and the Hough unit value Y of egg freshness as the model output, four models—partial least squares regression, extreme gradient boosting regression, random forest regression, and support vector regression—are established for egg freshness. These four models are denoted as follows: , , ,and For partial least squares regression models Its output prediction value is denoted as Y. PLSR For extreme gradient boosting regression models Its output prediction value is denoted as Y. XGB For the random forest regression model Its output prediction value is denoted as Y. RF For support vector regression models Its output prediction value is denoted as Y. SVR The final predicted value Y of egg freshness pred The weighted ensemble of the predicted outputs from the four models is expressed as follows:
[0033] Y pred =a1·Y PLSR +a2·Y XGB +a3·Y RF+a4·Y SVR
[0034] Where a1, a2, a3, and a4 are weighted integration coefficients, satisfying: a1 + a2 + a3 + a4 = 1
[0035] 0.1≤a i ≤0.5, i=1,2,3,4
[0036] Furthermore, a1, a2, a3, and a4 are all non-negative real numbers;
[0037] Preferably, , , , ;
[0038] Step 2: Rapid and non-destructive testing of the freshness of unknown egg samples;
[0039] Step 2.1: Collect intact egg samples with smooth surfaces and no external defects. indivual;
[0040] Step 2.2: Following steps 1.2 and 1.3, collect data under static conditions. The spectral absorbance information of the equatorial and apical positions of an unknown egg sample is denoted as follows: and ;
[0041] Step 2.3: Following step 1.4, collect data while rotating at low speed. The spectral absorbance information of the equatorial and apical positions of an unknown egg sample is denoted as follows: and ;
[0042] Step 2.4, measure as in step 1.5. Diameter data of an unknown egg sample, the egg's equatorial position, and the distance between the equator and the tip of the egg and the equator. The diameter data at the location are denoted as follows: and ;
[0043] Step 2.5, follow the procedure in Step 1.7 to process the diameter data. and Normalization is performed, and then the spectral matrix is adjusted according to step 1.8 using the normalized diameter data. , , , After calibration, the calibrated spectral matrix is preprocessed according to step 1.9. The preprocessed spectral matrices are denoted as follows. , , , ;
[0044] Step 2.6: Following the method described in Step 1.10, calculate the difference between the static spectrum and the spectrum under low-speed rotation at the same collection location of the unknown egg sample to obtain the spectral feature matrix of the collection state difference at the equatorial location. Spectral feature matrix of acquisition state difference at the tip position Its expression is as follows:
[0045] , ;
[0046] Step 2.7: Following the method described in Step 1.11, calculate the difference between the spectra at the equatorial position and the apical position of the unknown egg sample to obtain a positional difference feature matrix reflecting the spectral differences between different sampling positions, denoted as... Its expression is as follows:
[0047] ;
[0048] Step 2.8: Following the method described in Step 1.12, obtain the static spectral matrix of the unknown egg sample at the equatorial position. Spectral matrix of low-speed rotation state and the spectral feature matrix of the difference in acquisition status at the equatorial position The features are stitched and fused along the feature dimension to form the equatorial position fusion feature matrix. Its expression is as follows:
[0049] ;
[0050] Step 2.9: Following the method described in Step 1.13, obtain the static spectral matrix of the tip position of the unknown egg sample. Spectral matrix of low-speed rotation state and the spectral feature matrix of the difference in acquisition state at the tip position The features are stitched and fused along the feature dimension to form a fused feature matrix at the tip position. Its expression is as follows:
[0051] ;
[0052] Step 2.10: Following the method described in Step 1.14, fuse the feature matrices of the equatorial positions respectively. Each feature variable in the equation is multiplied by its weight coefficient. The feature matrix of the tip position is fused. Each feature variable in the equation is multiplied by its weight coefficient. The location difference feature matrix Each feature variable in the equation is multiplied by its weight coefficient. Then, the three weighted feature matrices are concatenated and fused along the feature dimensions to form the final fused feature matrix of the unknown egg sample, denoted as . Its expression is as follows:
[0053]
[0054] in, , and The fusion weighting coefficients are set to the same values as in step 1.14;
[0055] Step 2.11, the final fused feature matrix The inputs are respectively fed into the partial least squares regression model established in step 1.15. Extreme gradient boosting regression model Random forest regression model and support vector regression model The predicted values were obtained respectively. , , and Then, the four predicted values are substituted into the calculation formula Y established in step 1.15. pred =a1·Y PLSR +a2·Y XGB +a3·Y RF +a4·Y SVR This allows us to obtain the predicted Hough unit value for unknown egg samples. This enables rapid and non-destructive testing of egg freshness.
[0056] The beneficial effects of this invention are as follows: This invention utilizes egg diameter data to correct the spectrum, effectively reducing the impact of egg size differences on the detection results and improving the accuracy of egg freshness detection; by collecting near-infrared spectral information from the equatorial and tip positions of the egg under static and low-speed rotation conditions, it obtains spectral difference characteristics between different collection states and positions, and weights and fuses these difference characteristics to more comprehensively characterize changes in egg freshness, further improving the accuracy of egg freshness detection; in addition, by employing a weighted ensemble of partial least squares regression, extreme gradient boosting regression, random forest regression, and support vector regression models, it integrates the advantages of multiple models, improving the accuracy, stability, and robustness of egg freshness prediction results. Detailed Implementation
[0057] To further illustrate the technical means and methods adopted by the present invention to achieve its intended purpose, the technical solutions in the embodiments of the present invention are described clearly and in detail below with reference to specific examples. The described embodiments are only used to explain the present invention and are not intended to limit the present invention.
[0058] In an embodiment of the present invention, the freshness of a batch of egg samples is detected using the above-mentioned non-destructive detection method for egg freshness based on spectral feature fusion, which mainly includes the following steps:
[0059] Step 1: Establishing an egg freshness prediction model;
[0060] Step 1.1: Collect whole egg samples with smooth surfaces and no external defects. indivual;
[0061] Step 1.2, in a static state, respectively... Near-infrared spectra of an egg sample were acquired at its equatorial position using a transmission method to obtain spectral absorbance information at the equatorial location. The spectral matrix is denoted as [formula missing]. ;
[0062] Step 1.3: Under static conditions, near-infrared spectroscopy is performed in transmission mode at a position between the equator and the tip of the egg sample, and at a distance of 3 / 4 from the equator, to obtain spectral absorbance information at the tip of the egg. The spectral matrix of the egg samples is denoted as . ;
[0063] Step 1.4: Rotate the eggs at a low speed. Low-speed rotation will not affect the freshness of the eggs. Then, proceed with... Near-infrared spectra of an egg sample were acquired via transmission at its equatorial position and at a position between the equator and the apex, and at a distance of 3 / 4 from the equator. The spectral matrices are denoted as follows: and ;
[0064] Step 1.5, for Three egg samples were collected, and their diameters were measured at the equator, and at a point three-quarters of the way from the equator between the equator and the apex. The diameter data were recorded as follows: and ;
[0065] Step 1.6, for A sample of eggs was taken, and its weight was measured. The weight data was recorded as follows: Then, each egg sample was cracked, and the egg white and yolk were completely placed into the special measuring tray of the egg freshness measuring instrument, allowing the egg contents to spread naturally. The egg white height was measured using the egg freshness measuring instrument, and the Hough unit value was calculated based on the egg weight. The Hough unit value of each egg sample was used as a freshness reference value, and its freshness Hough unit data was recorded as follows: ;
[0066] Step 1.7: To eliminate the influence of egg size on the near-infrared transmission spectrum, the spectrum is corrected using egg diameter data; the diameter data... and The data are then combined and normalized to convert the diameter data to the range [0,1]. The normalized diameter data are denoted as follows: and ;
[0067] Step 1.8: The larger the diameter of the egg, the more spectral information it absorbs, and the greater its absorbance value; therefore, the spectral matrix... , Divide by the normalized diameter data respectively To correct for the effect of egg diameter on the spectrum, the corrected spectral matrix is denoted as... and ; spectral matrix and Divide by the normalized diameter data respectively To correct for the effect of diameter on the spectrum, the corrected spectral matrix is denoted as... and ;
[0068] Step 1.9: To eliminate baseline drift and reduce the effects of noise and scattering on the spectrum, a combination of baseline drift correction, Savitzky-Golay smoothing, and multivariate scattering correction (MSC) is used to adjust the spectral matrix. , , , Spectral preprocessing was performed, including baseline correction of the spectral matrix, Savitzky-Golay smoothing, and finally multivariate scattering correction (MSC). The preprocessed spectral matrices are as follows: , , , ;
[0069] Step 1.10: To obtain the spectral difference information of the egg under static and low-speed rotation conditions, the difference between the spectra of the egg under static and low-speed rotation conditions at the same acquisition location is calculated to obtain the spectral difference characteristics reflecting the acquisition conditions between static and low-speed rotation; the spectral feature matrix of the acquisition condition difference at the equatorial position is denoted as... The spectral feature matrix of the difference in acquisition conditions at the tip position is denoted as Its calculation expression is as follows:
[0070] ;
[0071] Step 1.11: Calculate the difference between the spectrum at the equator and the spectrum at the tip of the egg to obtain a spectral feature matrix reflecting the difference in sampling location; first, calculate the spectral matrix at the equator. With spectral matrix The average value, i.e. Then calculate the spectral matrix at the tip of the egg. With spectral matrix The average value, i.e. Finally, subtract the two to generate the spectral feature matrix of positional differences, denoted as . Its expression is as follows:
[0072] ;
[0073] Step 1.12, obtain the spectral matrix of the equatorial position. Spectral matrix and spectral feature matrix The features are stitched and fused along the feature dimension to form a fused feature matrix at the equator. Its expression is as follows:
[0074] ;
[0075] Step 1.13, obtain the spectral matrix at the tip position. Spectral matrix and spectral feature matrix The features are stitched and fused along the feature dimension to form a fused feature matrix at the tip position. Its expression is as follows:
[0076] ;
[0077] Step 1.14: Merge the equatorial feature matrix Each feature variable is multiplied by its weight coefficient. The weighted equatorial fusion feature matrix is obtained; the tip fusion feature matrix is then obtained. Each feature variable is multiplied by its weight coefficient. The weighted end-fusion feature matrix is obtained; the position difference spectral feature matrix is then used to obtain the weighted end-fusion feature matrix. Each feature variable is multiplied by its weight coefficient. The weighted positional difference feature matrix is obtained; the three weighted fusion feature matrices are concatenated and fused along the feature dimension to form the final fusion feature matrix, denoted as F, whose expression is as follows:
[0078]
[0079] in , , To integrate the weighting coefficients, the following conditions must be met:
[0080]
[0081] And the range of values for the fusion weight coefficient is:
[0082]
[0083] Preferably, , , ;
[0084] Step 1.15: To improve the prediction accuracy and stability of egg freshness, a weighted ensemble of the prediction outputs from multiple models is used to obtain the final predicted value of egg freshness. Using the final fused feature matrix F as the model input and the Hough unit value Y of egg freshness as the model output, four models—partial least squares regression, extreme gradient boosting regression, random forest regression, and support vector regression—are established for egg freshness. These four models are denoted as follows: , , ,and For partial least squares regression models Its output prediction value is denoted as Y. PLSR For extreme gradient boosting regression models Its output prediction value is denoted as Y. XGB For the random forest regression model Its output prediction value is denoted as Y. RF For support vector regression models Its output prediction value is denoted as Y. SVR The final predicted value Y of egg freshness pred The weighted ensemble of the predicted outputs from the four models is expressed as follows:
[0085] Y pred =a1·Y PLSR +a2·Y XGB +a3·Y RF+a4·Y SVR
[0086] Where a1, a2, a3, and a4 are weighted integration coefficients, satisfying: a1 + a2 + a3 + a4 = 1
[0087] 0.1≤a i ≤0.5, i=1,2,3,4
[0088] Furthermore, a1, a2, a3, and a4 are all non-negative real numbers;
[0089] Preferably, , , , ;
[0090] Step 2: Rapid and non-destructive testing of the freshness of unknown egg samples;
[0091] Step 2.1: Collect intact egg samples with smooth surfaces and no external defects. indivual;
[0092] Step 2.2: Following steps 1.2 and 1.3, collect data under static conditions. The spectral absorbance information of the equatorial and apical positions of an unknown egg sample is denoted as follows: and ;
[0093] Step 2.3: Following step 1.4, collect data while rotating at low speed. The spectral absorbance information of the equatorial and apical positions of an unknown egg sample is denoted as follows: and ;
[0094] Step 2.4, measure as in step 1.5. Diameter data of an unknown egg sample, the egg's equatorial position, and the distance between the equator and the tip of the egg and the equator. The diameter data at the location are denoted as follows: and ;
[0095] Step 2.5, follow the procedure in Step 1.7 to process the diameter data. and Normalization is performed, and then the spectral matrix is adjusted according to step 1.8 using the normalized diameter data. , , , After calibration, the calibrated spectral matrix is preprocessed according to step 1.9. The preprocessed spectral matrices are denoted as follows. , , , ;
[0096] Step 2.6: Following the method described in Step 1.10, calculate the difference between the static spectrum and the spectrum under low-speed rotation at the same collection location of the unknown egg sample to obtain the spectral feature matrix of the collection state difference at the equatorial location. Spectral feature matrix of acquisition state difference at the tip position Its expression is as follows:
[0097] ;
[0098] Step 2.7: Following the method described in Step 1.11, calculate the difference between the spectra at the equatorial position and the apical position of the unknown egg sample to obtain a positional difference feature matrix reflecting the spectral differences between different sampling positions, denoted as... Its expression is as follows:
[0099] ;
[0100] Step 2.8: Following the method described in Step 1.12, obtain the static spectral matrix of the unknown egg sample at the equatorial position. Spectral matrix of low-speed rotation state and the spectral feature matrix of the difference in acquisition status at the equatorial position The features are stitched and fused along the feature dimension to form the equatorial position fusion feature matrix. Its expression is as follows:
[0101] ;
[0102] Step 2.9: Following the method described in Step 1.13, obtain the static spectral matrix of the tip position of the unknown egg sample. Spectral matrix of low-speed rotation state and the spectral feature matrix of the difference in acquisition state at the tip position The features are stitched and fused along the feature dimension to form a fused feature matrix at the tip position. Its expression is as follows:
[0103] ;
[0104] Step 2.10: Following the method described in Step 1.14, fuse the feature matrices of the equatorial positions respectively. Each feature variable in the equation is multiplied by its weight coefficient. The feature matrix of the tip position is fused. Each feature variable in the equation is multiplied by its weight coefficient. The location difference feature matrix Each feature variable in the equation is multiplied by its weight coefficient. Then, the three weighted feature matrices are concatenated and fused along the feature dimensions to form the final fused feature matrix of the unknown egg sample, denoted as . Its expression is as follows:
[0105]
[0106] in, , and The fusion weighting coefficients are set to the same values as in step 1.14;
[0107] Step 2.11, the final fused feature matrix The inputs are respectively fed into the partial least squares regression model established in step 1.15. Extreme gradient boosting regression model Random forest regression model and support vector regression model The predicted values were obtained respectively. , , and Then, the four predicted values are substituted into the calculation formula Y established in step 1.15. pred =a1·Y PLSR +a2·Y XGB +a3·Y RF +a4·Y SVR This allows us to obtain the predicted Hough unit value for unknown egg samples. This enables rapid and non-destructive testing of egg freshness.
[0108] The above specific embodiments are used to explain and illustrate the present invention, but not to limit the present invention. Any modifications and changes made to the present invention within the spirit and scope of the claims shall fall within the protection scope of the present invention.
Claims
1. A non-destructive method for detecting egg freshness based on spectral feature fusion, characterized in that, The steps of this method are as follows: Step 1: Establishing an egg freshness prediction model; Step 1.1: Collect whole egg samples with smooth surfaces and no external defects. indivual; Step 1.2, in a static state, respectively... Near-infrared spectra of an egg sample were acquired at its equatorial position using a transmission method to obtain spectral absorbance information at the equatorial location. The spectral matrix is denoted as [formula missing]. ; Step 1.3: Under static conditions, near-infrared spectroscopy is performed in transmission mode at a position between the equator and the tip of the egg sample, and at a distance of 3 / 4 from the equator, to obtain spectral absorbance information at the tip of the egg. The spectral matrix of the egg samples is denoted as . ; Step 1.4: Rotate the eggs at a low speed. Low-speed rotation will not affect the freshness of the eggs. Then, proceed with... Near-infrared spectra of an egg sample were acquired via transmission at its equatorial position and at a position between the equator and the apex, and at a distance of 3 / 4 from the equator. The spectral matrices are denoted as follows: and ; Step 1.5, for Three egg samples were collected, and their diameters were measured at the equator, and at a point three-quarters of the way from the equator between the equator and the apex. The diameter data were recorded as follows: and ; Step 1.6, for A sample of eggs was taken, and its weight was measured. The weight data was recorded as follows: Then, the egg samples were cracked one by one, and the egg whites and yolks were completely cracked into the special measuring tray of the egg freshness measuring instrument, allowing the egg contents to spread naturally. The Haugh unit (HFU) value was calculated by measuring the albumen height using an egg freshness meter and combining it with the egg weight. The HFU value of each egg sample was used as a freshness reference value, and the freshness HFU data was denoted as [reference value]. ; Step 1.7: To eliminate the influence of egg size on the near-infrared transmission spectrum, the spectrum is corrected using egg diameter data; the diameter data... and The data are then combined and normalized to convert the diameter data to the range [0,1]. The normalized diameter data are denoted as follows: and ; Step 1.8: The larger the diameter of the egg, the more spectral information it absorbs, and the greater its absorbance value; therefore, the spectral matrix... , Divide by the normalized diameter data respectively To correct for the effect of egg diameter on the spectrum, the corrected spectral matrix is denoted as... and ; spectral matrix and Divide by the normalized diameter data respectively To correct for the effect of diameter on the spectrum, the corrected spectral matrix is denoted as... and ; Step 1.9: To eliminate baseline drift and reduce the effects of noise and scattering on the spectrum, a combination of baseline drift correction, Savitzky-Golay smoothing, and multivariate scattering correction (MSC) is used to adjust the spectral matrix. , , , Spectral preprocessing was performed, including baseline correction of the spectral matrix, Savitzky-Golay smoothing, and finally multivariate scattering correction (MSC). The preprocessed spectral matrices are as follows: , , , ; Step 1.10: In order to obtain the spectral difference information of the egg in static and low-speed rotation states, the difference between the spectra of the eggs in static and low-speed rotation states at the same acquisition location is calculated to obtain the spectral difference characteristics reflecting the acquisition conditions between static and low-speed rotation. The spectral feature matrix representing the differences in acquisition conditions at the equatorial location is denoted as... The spectral feature matrix of the difference in acquisition conditions at the tip position is denoted as Its calculation expression is as follows: ; Step 1.11: Calculate the difference between the spectrum at the equator and the spectrum at the tip of the egg to obtain a spectral feature matrix reflecting the difference in sampling location; first, calculate the spectral matrix at the equator. With spectral matrix The average value, i.e. Then calculate the spectral matrix at the tip of the egg. With spectral matrix The average value, i.e. Finally, subtract the two to generate the spectral feature matrix of positional differences, denoted as . Its expression is as follows: ; Step 1.12, obtain the spectral matrix of the equatorial position. Spectral matrix and spectral feature matrix The features are stitched and fused along the feature dimension to form a fused feature matrix at the equator. Its expression is as follows: ; Step 1.13, obtain the spectral matrix at the tip position. Spectral matrix and spectral feature matrix The features are stitched and fused along the feature dimension to form a fused feature matrix at the tip position. Its expression is as follows: ; Step 1.14: Merge the equatorial feature matrix Each feature variable is multiplied by its weight coefficient. The weighted equatorial fusion feature matrix is obtained; fusing the cutting-edge feature matrix Each feature variable is multiplied by its weight coefficient. The weighted end-fusion feature matrix is obtained; The position difference spectral feature matrix Each feature variable is multiplied by its weight coefficient. The weighted positional difference feature matrix is obtained; the three weighted fusion feature matrices are concatenated and fused along the feature dimension to form the final fusion feature matrix, denoted as F, whose expression is as follows: in , , To integrate the weighting coefficients, the following conditions must be met: And the range of values for the fusion weight coefficient is: Preferably, , , ; Step 1.15: In order to improve the prediction accuracy and stability of egg freshness, the prediction outputs of multiple models are weighted and integrated to obtain the final predicted value of egg freshness. Using the final fused feature matrix F as the model input and the Hough unit value Y of egg freshness as the model output, four models for egg freshness are established: partial least squares regression, extreme gradient boosting regression, random forest regression, and support vector regression. These four models are denoted as follows: , , ,and ; For partial least squares regression models Its output prediction value is denoted as Y. PLSR For extreme gradient boosting regression models Its output prediction value is denoted as Y. XGB For the random forest regression model Its output prediction value is denoted as Y. RF For support vector regression models Its output prediction value is denoted as Y. SVR The final predicted value Y of egg freshness pred The weighted ensemble of the predicted outputs from the four models is expressed as follows: Y pred =a1·Y PLSR +a2·Y XGB +a3·Y RF +a4·Y SVR Where a1, a2, a3, and a4 are weighted integration coefficients, satisfying: a1 + a2 + a3 + a4 = 1 0.1≤a i ≤0.5,i=1,2,3,4 Furthermore, a1, a2, a3, and a4 are all non-negative real numbers; Preferably, , , , ; Step 2: Rapid and non-destructive testing of the freshness of unknown egg samples; Step 2.1: Collect intact egg samples with smooth surfaces and no external defects. indivual; Step 2.2: Following steps 1.2 and 1.3, collect data under static conditions. The spectral absorbance information of the equatorial and apical positions of an unknown egg sample is denoted as follows: and ; Step 2.3: Following step 1.4, collect data while rotating at low speed. The spectral absorbance information of the equatorial and apical positions of an unknown egg sample is denoted as follows: and ; Step 2.4, measure as in step 1.
5. Diameter data of an unknown egg sample, the egg's equatorial position, and the distance between the equator and the tip of the egg and the equator. The diameter data at the location are denoted as follows: and ; Step 2.5, follow the procedure in Step 1.7 to process the diameter data. and Normalization is performed, and then the spectral matrix is adjusted according to step 1.8 using the normalized diameter data. , , , After calibration, the calibrated spectral matrix is preprocessed according to step 1.
9. The preprocessed spectral matrices are denoted as follows. , , , ; Step 2.6: Following the method described in Step 1.10, calculate the difference between the static spectrum and the spectrum under low-speed rotation at the same collection location of the unknown egg sample to obtain the spectral feature matrix of the collection state difference at the equatorial location. Spectral feature matrix of acquisition state difference at the tip position Its expression is as follows: , ; Step 2.7: Following the method described in Step 1.11, calculate the difference between the spectra at the equatorial position and the apical position of the unknown egg sample to obtain a positional difference feature matrix reflecting the spectral differences between different sampling positions, denoted as... Its expression is as follows: ; Step 2.8: Following the method described in Step 1.12, obtain the static spectral matrix of the unknown egg sample at the equatorial position. Spectral matrix of low-speed rotation state and the spectral feature matrix of the difference in acquisition status at the equatorial position The features are stitched and fused along the feature dimension to form the equatorial position fusion feature matrix. Its expression is as follows: ; Step 2.9: Following the method described in Step 1.13, obtain the static spectral matrix of the tip position of the unknown egg sample. Spectral matrix of low-speed rotation state and the spectral feature matrix of the difference in acquisition state at the tip position The features are stitched and fused along the feature dimension to form a fused feature matrix at the tip position. Its expression is as follows: ; Step 2.10: Following the method described in Step 1.14, fuse the feature matrices of the equatorial positions respectively. Each feature variable in the equation is multiplied by its weight coefficient. The feature matrix of the tip position is fused. Each feature variable in the equation is multiplied by its weight coefficient. The location difference feature matrix Each feature variable in the equation is multiplied by its weight coefficient. Then, the three weighted feature matrices are concatenated and fused along the feature dimensions to form the final fused feature matrix of the unknown egg sample, denoted as . Its expression is as follows: in, , and The fusion weighting coefficients are set to the same values as in step 1.14; Step 2.11, the final fused feature matrix The inputs are respectively fed into the partial least squares regression model established in step 1.
15. Extreme gradient boosting regression model Random forest regression model and support vector regression model The predicted values were obtained respectively. , , and Then, the four predicted values are substituted into the calculation formula Y established in step 1.
15. pred =a1·Y PLSR +a2·Y XGB +a3·Y RF +a4·Y SVR This allows us to obtain the predicted Hough unit value for unknown egg samples. This enables rapid and non-destructive testing of egg freshness.
