Nondestructive detection method and system for cadmium content of poultry eggs
By analyzing the color characteristics, spectral transmittance and texture characteristics of the eggs to be detected, and constructing and screening predictive sub-models, the complex and destructive problems of traditional chemical methods are solved, and the rapid non-destructive detection of the cadmium content in the egg is achieved, which improves the Inspection accuracy and simplicity.
Patent Information
- Application Number
- CN202411413574.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-11
- Publication Date
- 2025-02-07
AI Technical Summary
In the prior art, the detection of cadmium content in eggs depends on traditional chemical methods, which is complex in operation, high in cost and destructive to samples, making it difficult to meet the rapid non-destructive testing needs of the modern food industry.
The non-destructive detection method is used to randomly select samples from the egg to be detected to obtain their color characteristics, spectral transmittance subsets and texture characteristics at characteristic wavelengths. Several predictive sub-models are constructed using different kernel functions, and the optimal predictive sub-model set is selected. These models are used to predict the characteristic data of the detection poultry eggs to obtain the final predicted value of the cadmium content.
It realizes the measurement of cadmium content without destroying poultry eggs, reduces the detection complexity and improves the detection accuracy, and is suitable for the rapid non-destructive online inspection of the modern food industry.
Smart Images

Figure CN119394927A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of poultry egg detection, and in particular to a method and system for nondestructive detection of cadmium content in poultry eggs. Background Art
[0002] Eggs are rich in nutrients and can provide the human body with essential nutrients such as protein, fat, and amino acids. They are popular in daily diets and have also become one of the important raw materials for many processed foods. Cadmium exposure can damage the human digestive system, nervous system, and reproductive system, and has carcinogenic, teratogenic, and mutagenic effects. During the production process, a large amount of cadmium in laying hens will be transferred to eggs, so the detection of cadmium content in eggs plays an important role in ensuring food safety.
[0003] At present, the detection of cadmium content in eggs relies on traditional chemical detection methods, such as ultraviolet spectrophotometry, atomic absorption spectroscopy, etc. Although these methods can achieve trace detection of heavy metals, they have high operation requirements, high costs and are destructive to the samples to be tested. Therefore, they are only suitable for sampling detection and cannot meet the detection needs of the modern food industry. Therefore, it is necessary to seek a rapid and non-destructive method for detecting cadmium content in eggs. Summary of the invention
[0004] In view of the above-mentioned defects of the prior art, the first aspect of the present invention provides a non-destructive detection method for cadmium content in poultry eggs, comprising:
[0005] S1. Randomly select sample poultry eggs from the poultry eggs to be tested, and obtain the characteristics of the sample poultry eggs and the cadmium content value of the poultry eggs, wherein the characteristics include color characteristics, a spectral transmittance subset at a characteristic wavelength, and texture characteristics;
[0006] S2, taking the color features of sample eggs as input and the cadmium content of the corresponding sample eggs as output, using different kernel functions to construct several prediction sub-models, taking the spectral transmittance subsets at the characteristic wavelengths of the sample eggs as input and the cadmium content of the corresponding sample eggs as output, using different kernel functions to construct several prediction sub-models, taking the texture features of the sample eggs as input and the cadmium content of the corresponding sample eggs as output, using different kernel functions to construct several prediction sub-models;
[0007] S3, selecting excellent prediction sub-models from all sub-models to form an optimal prediction sub-model set;
[0008] S4. Taking the characteristic data of the poultry eggs to be tested as input, the corresponding prediction value is obtained through the prediction sub-model in the optimal prediction sub-model set, and the average of each prediction value is the final prediction value of the final cadmium content of the poultry eggs.
[0009] Furthermore, the color feature is a color feature of a spectral image of poultry eggs, and the color feature includes a set of color features of R, G, B, H, S and V channels.
[0010] Furthermore, the method for acquiring the characteristic wavelength includes:
[0011] S11, collecting spectral data of sample eggs at different wavelengths, constructing a spectral transmittance set, randomly sampling the wavelengths in the spectral transmittance set, the sampling number h1=3×m, and then obtaining h1 spectral transmittance subsets, the number of wavelengths sampled each time is 75% of the total number of wavelengths;
[0012] S12, taking each spectral transmittance subset as input and the cadmium content set as output, a multivariate linear regression sub-model is established, and a total of h1 sub-models are obtained;
[0013] S13, select the top 10% sub-models with the smallest cross-validation root mean square error, use the regression coefficient as the weight of the wavelength, calculate the average weight of each wavelength, and normalize it to [0,1], where the weight of the wavelength not included in the top 10% sub-model is reset to 0;
[0014] S14, setting the sampling times h2=3×m0, where m0 represents the number of wavelengths whose current weight is not 0, and using weighted random sampling to sample the wavelengths of the spectral transmittance set, where the number of wavelengths sampled each time is m0×75%, and a total of h2 new spectral transmittance subsets are obtained;
[0015] S15, taking each new spectral transmittance subset as input and the cadmium content set as output, a multivariate linear regression sub-model is established, and a total of h2 sub-models are obtained;
[0016] S16, repeating steps S13 to S15 in a loop, updating m0, until the number of wavelengths whose weight is not 0 is 1; performing a five-fold cross validation on all sub-models at this time, determining the sub-model with the smallest root mean square error, and its corresponding spectral transmittance constitutes a spectral transmittance subset.
[0017] Furthermore, the texture features include energy, entropy, contrast, inverse variance and correlation of each characteristic wavelength image.
[0018] Further, step S3 includes:
[0019] S31, calculating the root mean square error value of each sample egg in each prediction sub-model, and arranging all prediction sub-models in ascending order according to the root mean square error value and numbering them, and recording them as prediction sub-model 1, prediction sub-model 2, ..., prediction sub-model n, where n is the number of prediction sub-models;
[0020] S32, construct a sub-model set M = [], introduce sub-models in sequence starting from prediction sub-model 1, and calculate the joint root mean square error e of the existing prediction sub-models in the sub-model set M M , calculate the joint root mean square error e between the prediction sub-model to be introduced and the existing prediction sub-models in the sub-model set M N , when e N Less than e M When , the prediction sub-model is retained, otherwise the prediction sub-model is eliminated;
[0021] S33. Repeat step S32 until all prediction sub-models are traversed and the obtained prediction sub-model set is the optimal prediction sub-model set.
[0022] Another aspect of the present invention provides a nondestructive detection system for cadmium content in poultry eggs, comprising:
[0023] A sample acquisition unit, used for randomly selecting sample poultry eggs from the poultry eggs to be tested, and obtaining characteristics of the sample poultry eggs and the cadmium content value of the poultry eggs, wherein the characteristics include color characteristics, a spectral transmittance subset at a characteristic wavelength, and texture characteristics;
[0024] The detection model unit takes the color characteristics of the sample eggs as input, the cadmium content of the corresponding sample eggs as output, and uses different kernel functions to construct several prediction sub-models; takes the spectral transmittance subset of the sample eggs at the characteristic wavelength as input, the cadmium content of the corresponding sample eggs as output, and uses different kernel functions to construct several prediction sub-models; takes the texture characteristics of the sample eggs as input, the cadmium content of the corresponding sample eggs as output, and uses different kernel functions to construct several prediction sub-models;
[0025] A screening unit is used to screen excellent sub-models from all prediction sub-models to form an optimal prediction sub-model set;
[0026] The detection unit is used to take the characteristic data of the poultry eggs to be detected as input, and obtain the corresponding prediction value through the prediction sub-model in the optimal prediction sub-model set, and the average of each prediction value is the final prediction value of the final poultry egg cadmium content.
[0027] Compared with the prior art, the present invention has the following technical effects:
[0028] The detection system of the present invention can measure the cadmium content without destroying the eggs. Compared with the traditional sampling detection method, there is no need to destroy the eggs for sample pretreatment, which reduces the complexity of egg detection and can greatly improve the detection accuracy.
[0029] The invention is simple to operate and can realize rapid and nondestructive online detection of the heavy metal cadmium content of eggs, which has direct practical significance for ensuring the quality safety of eggs and maintaining the health of consumers.
[0030] The concept, specific structure and technical effects of the present invention will be further described below in conjunction with the accompanying drawings to fully understand the purpose, characteristics and effects of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 This is a schematic diagram of the structure of a poultry egg cadmium content detection system according to a specific embodiment of the present invention;
[0032] Figure 2 is an overall flow chart of a detection method according to a specific embodiment of the present invention;
[0033] Figure 3 It is a structural principle diagram of a spectrum collection device according to a specific embodiment of the present invention;
[0034] Figure 4 is a spectrum image of some wavelengths of a specific embodiment of the present invention;
[0035] Figure 5 is a transmittance spectrum curve of an egg sample according to a specific embodiment of the present invention;
[0036] Figure 6 It is a diagram of the detection results of a specific embodiment of the present invention. DETAILED DESCRIPTION
[0037] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0038] It should be noted that the illustrations provided in the following embodiments are only used to illustrate the basic concept of the present invention in a schematic manner, and thus the illustrations only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0039] While some exemplary embodiments of the present invention have been described for the purpose of illustration, it should be understood that the present invention may be implemented in other ways not specifically shown in the drawings.
[0040] In a specific embodiment, a nondestructive detection system for cadmium content in poultry eggs is provided, which obtains cadmium content detection values through a detection model based on extracted features related to poultry eggs, and includes a sample acquisition unit, a detection model unit, a screening unit and a detection unit.
[0041] The sample acquisition unit is used to randomly select sample eggs from the eggs to be tested to obtain the characteristics of the sample eggs and the cadmium content values of the eggs.
[0042] Metal cadmium can affect the internal and external quality of eggs, for example, it can change the eggshell color, the texture of the eggshell surface, the protein content, and the fat content. The eggshell color and the texture of the eggshell surface can reflect the external quality of the egg, and the protein content and the fat content can reflect the internal quality of the egg. The changes in the protein content and the fat content are reflected through the spectrum. Therefore, the egg characteristics used in this embodiment include color characteristics, a subset of spectral transmittance at characteristic wavelengths, and texture characteristics.
[0043] The color feature is the color feature of the spectral image of the sample poultry egg, and the color feature includes a color feature set V={v j ; j = 1, 2, ..., k}, v j Represents the jth color feature.
[0044] The spectral transmittance subset at the characteristic wavelength is a characteristic wavelength data set F={f j ; j = 1, 2, ..., h}, f j represents the transmittance at the jth characteristic wavelength, and h is the number of characteristic wavelengths.
[0045] The texture feature is used to establish a texture feature set T = {t j ; j = 1, 2, ..., 5 × h}, t j Represents the jth texture feature.
[0046] The detection model unit takes the color characteristics of sample poultry eggs as input, the cadmium content of the corresponding sample poultry eggs as output, and uses different kernel functions to construct several prediction sub-models; takes the spectral transmittance subset of the sample poultry eggs at the characteristic wavelength as input, the cadmium content of the corresponding sample poultry eggs as output, and uses different kernel functions to construct several prediction sub-models; takes the texture characteristics of the sample poultry eggs as input, the cadmium content of the corresponding sample poultry eggs as output, and uses different kernel functions to construct several prediction sub-models.
[0047] The screening unit is used to screen excellent sub-models from all prediction sub-models to form an optimal prediction sub-model set.
[0048] The detection unit is used to take the characteristic data of the poultry eggs to be detected as input, and obtain the corresponding prediction value through the prediction sub-model in the optimal prediction sub-model set, and the average of each prediction value is the final prediction value of the final poultry egg cadmium content.
[0049] Based on the nondestructive detection system for cadmium content in poultry eggs described in the above embodiment, in a specific embodiment, a nondestructive detection method for cadmium content in poultry eggs is provided, such as Figure 1 As shown, the following steps are included:
[0050] S1. Randomly select sample eggs from the eggs to be tested, and obtain the characteristics of the sample eggs and the cadmium content value of the eggs, wherein the characteristics include color characteristics, a subset of spectral transmittance at a characteristic wavelength, and texture characteristics; the method for obtaining the characteristics of the sample eggs includes:
[0051] S11, obtaining a color feature set V of the spectral image of the sample poultry eggs, wherein the color features include a color feature set V of R, G, B, H, S and V channels = {v j ; j = 1, 2, ..., k}, v j represents the jth color feature, and the method for obtaining the color feature set V includes:
[0052] S111, obtaining hyperspectral images at different wavelengths, selecting corresponding images in the hyperspectral images according to the wavelength as red, green and blue channels to form an RGB image, and then converting the RGB image into an HSV image;
[0053] S112, respectively calculate the first-order moment, second-order moment and third-order moment of the R channel, G channel, B channel, H channel, S channel and V channel, use the first-order matrix, second-order matrix and third-order matrix of each channel as color features, and establish a color feature data set V={v j ; j=1,2,…,k}.
[0054] S12. Obtain a transmittance set F at a characteristic wavelength.
[0055] Since the spectral resolution of the hyperspectral system is very high, when the difference between the two wavelengths is small, the similarity of the obtained spectral images is also very high, and the information carried in the two images is also very similar. In order to reduce the complexity of the calculation, some redundant information needs to be eliminated. In this embodiment, the method of characteristic wavelength extraction is adopted, which can not only remove repeated information, but also remove irrelevant wavelengths with low correlation with the cadmium content of poultry eggs, and select a small number of wavelengths with the highest correlation with the cadmium content of poultry eggs from all wavelengths, so as to achieve the purpose of dimensionality reduction and removal of redundant information. The method for extracting the characteristic wavelength data set F in this embodiment includes:
[0056] S121. In this embodiment, a spectral image of the poultry egg to be tested at m wavelengths is obtained, and the transmittance corresponding to each wavelength is obtained according to the spectral image to form a spectral transmittance set. The wavelengths of the spectral transmittance set are randomly sampled, and the sampling number is h1=3×m, thereby obtaining h1 spectral transmittance subsets, and the number of wavelengths sampled each time is 75% of the total number of wavelengths;
[0057] S122, using each spectral transmittance subset as input and the cadmium content standard as output, a multivariate linear regression sub-model is established, and a total of h1 sub-models are obtained;
[0058] S123, using a cross-validation method to obtain the root mean square error of each sub-model, taking the top 10% sub-models with the smallest root mean square error, using the regression coefficient as the weight of the wavelength, calculating the average weight of each wavelength, and normalizing it to [0, 1], and setting the weight of the wavelength not included in the top 10% sub-models to 0;
[0059] S124, setting the sampling times h2=3×m0, where m0 represents the number of wavelengths whose current weight is not 0, and using weighted random sampling to sample the wavelengths of the spectral transmittance set S, where the number of wavelengths sampled each time is m0×75%, and a total of h2 new spectral transmittance subsets are obtained;
[0060] S125, taking each new spectral transmittance subset as input and the cadmium content set as output, establishing a multivariate linear regression sub-model, and obtaining a total of h2 sub-models;
[0061] S126, repeating steps S123 to S125 in a loop, updating m0, until the number of wavelengths whose weight is not 0 is 1; performing a five-fold cross validation on all sub-models at this time, determining the sub-model with the smallest root mean square error, the wavelength in the sub-model is the characteristic wavelength, and the spectral transmittance corresponding to each characteristic wavelength constitutes the spectral transmittance subset F = {f ij ; i = 1, 2, 3, ..., n; j = 1, 2, 3, ..., h}, where f ij It represents the transmittance of the i-th sample at the j-th characteristic wavelength, and h is the number of characteristic wavelengths.
[0062] S13, obtain the five texture features of energy, entropy, contrast, inverse variance and correlation of each characteristic wavelength image to establish a texture feature set T = {t j ; j = 1, 2, ..., 5 × h}, t j Represents the jth texture feature.
[0063] The method for constructing the texture feature set T includes:
[0064] The energy, entropy, contrast, inverse variance and correlation of each characteristic wavelength image are calculated by using the gray level co-occurrence matrix algorithm. The energy, entropy, contrast, inverse variance and correlation of all characteristic wavelength images are used as texture features, and then the texture feature set T = {t j ; j = 1, 2,…, 5×h}.
[0065] S2. Taking the color characteristics of sample eggs as input and the cadmium content of the corresponding sample eggs as output, different kernel functions are used to construct several prediction sub-models. Taking the spectral transmittance subset of the sample eggs at the characteristic wavelength as input and the cadmium content of the corresponding sample eggs as output, different kernel functions are used to construct several prediction sub-models. Taking the texture characteristics of sample eggs as input and the cadmium content of the corresponding sample eggs as output, different kernel functions are used to construct several prediction sub-models. The prediction sub-models constitute a detection model set.
[0066] S3. Select excellent prediction sub-models from all sub-models to form the optimal prediction sub-model set.
[0067] In this embodiment, different prediction sub-models are established by using different input variables and different kernel functions, taking into account various characteristics that can reflect the cadmium content of poultry eggs, and using different kernel functions to improve the accuracy of the final prediction result. However, the number of prediction sub-models is still large, which increases the computational burden and complexity. Therefore, step S3 is used to screen the prediction sub-models in the above-mentioned detection model set to find the prediction sub-model that best reflects the characteristics corresponding to the current sample poultry eggs and the kernel function. The method for obtaining the optimal prediction sub-model set includes:
[0068] S31, calculating the root mean square error value of each sample egg in each prediction sub-model, and arranging all prediction sub-models in ascending order according to the root mean square error value and numbering them, and recording them as prediction sub-model 1, prediction sub-model 2, ..., prediction sub-model n, where n is the number of prediction sub-models;
[0069] S32, construct a sub-model set M = [], introduce sub-models in sequence starting from prediction sub-model 1, and calculate the joint root mean square error e of the existing prediction sub-models in the sub-model set M M , calculate the joint root mean square error e between the prediction sub-model to be introduced and the existing prediction sub-models in the sub-model set M N , when e N Less than e M When , the prediction sub-model is retained, otherwise the prediction sub-model is eliminated;
[0070] S33. Repeat step S32 until all prediction sub-models are traversed and the obtained prediction sub-model set is the optimal prediction sub-model set.
[0071] S4. Taking the characteristic data of the poultry eggs to be tested as input, the corresponding prediction value is obtained through the prediction sub-model in the optimal prediction sub-model set, and the mean y of each prediction value is the final prediction value of the cadmium content of the poultry eggs.
[0072] In order to further illustrate the detection method of the above embodiment, in one embodiment, it is verified through the following specific experiments.
[0073] 1. Sample preparation steps:
[0074] Thirty healthy laying hens were evenly divided into six experimental groups for feeding. A corn-soybean meal-based basal diet was prepared according to the Chicken Feeding Standard (NY / T33-2004), and 0 mg / kg, 10 mg / kg, 20 mg / kg, 30 mg / kg, 40 mg / kg and 50 mg / kg of cadmium were added to the diets of the six experimental groups in the form of CdCl2. Fifty egg samples with intact appearance and no defects were selected from each experimental group for subsequent experiments, for a total of 300 samples.
[0075] 2. Data acquisition steps:
[0076] Build as Figure 3 The hyperspectral imaging system shown in the figure can collect hyperspectral images of the target with a spectral range of 435-1002nm. The 300 egg samples were randomly divided into a training set (a total of 225 samples) and a test set (a total of 75 samples) at a ratio of 3:1, where the training set was used to build a prediction model for the heavy metal cadmium content in eggs, and the test set was used as the sample to be tested; the transmission hyperspectral images of the egg samples in the training set were collected using a visible-near infrared hyperspectral imager, where the spectral range was 435-1002nm, with a total of 449 wavelengths. Some spectral images are shown in Figure 1. Figure 4 As shown; referring to the national standard GB 5009.15-2014, the heavy metal cadmium content in the egg samples of the training set was determined by atomic absorption spectrometry, and the egg heavy metal cadmium content set Y = {y i ; i = 1, 2, ..., 225}, where y i Represents the cadmium content of the i-th egg sample.
[0077] The single-wavelength image at one wavelength is adaptively segmented into the region of interest and the background region using the two-dimensional maximum inter-class variance method to obtain a binary image. The binary image is then applied to each single-wavelength image to extract the region of interest and obtain the image data set P = {p ij ; i = 1, 2, 3, ..., 225; j = 1, 2, 3, ..., 449}, where p ij represents the image of the i-th sample at the j-th wavelength; in a wavelength image, the value of each pixel is a transmittance, and the values of all pixels in the egg area, i.e., the area of interest, are averaged to obtain an average transmittance value, which is used to represent the transmittance of the sample at the wavelength. Similarly, the transmittance at all wavelengths can be obtained. These transmittances constitute the spectral curve of the sample, and 225 samples are 225 spectral curves. The transmittance spectral curves of all egg samples in this embodiment are shown in FIG. Figure 5As shown, the spectral transmittance set S0 = {s ij ; i = 1, 2, 3, ..., 225; j = 1, 2, 3, ..., 449}, where s ij Indicates the transmittance of the i-th sample at the j-th wavelength. In this embodiment, in the image around 700nm, the spectral transmittance of the egg is the highest, and the contrast with the background area is the largest at this time. Its value can be directly observed from the spectrum curve, so the wavelength used in this embodiment is 703nm.
[0078] 3. Extract color feature data set V:
[0079] The images with single wavelengths of 650nm, 550nm and 460nm are used as red, green and blue channels to form RGB images, and the RGB color space is converted to the HSV color space to obtain the HSV image. The first-order moment, second-order moment and third-order moment of the R channel, G channel, B channel, H channel, S channel and V channel are calculated respectively, and the first-order matrix, second-order matrix and third-order matrix of the six channels are used as color features to obtain the color feature data set of each test sample. Each color feature data set contains 18 color features. The color feature data set of all test samples V = {v ij ; i = 1, 2, 3, ..., 225; j = 1, 2, 3, ..., 18}, where v ij represents the jth color feature of the i-th sample.
[0080] 4. Characteristic wavelength extraction:
[0081] 4.1. Random sampling is used to sample the wavelengths of the spectral transmittance set S0. The sampling times are set to h1=1347 (3×449), where the number of wavelengths extracted each time is 75% of the total number of wavelengths, that is, 449×75%=337. After h1 random samplings, a spectral transmittance set S1 consisting of 1347 spectral transmittance subsets is obtained, and each spectral transmittance subset contains 225×337 spectral data.
[0082] 4.2. Using each spectral transmittance subset as input and the egg cadmium content set Y as output, a multivariate linear regression submodel is established, and a total of 1347 submodels are obtained. In this embodiment, the first multivariate linear regression submodel is:
[0083] y l =a l1sl1 +a l2sl2 +...+a l,337 s l,337 +b l ;
[0084] where sl1 、s l2、 ...、s l,337 is the transmittance of each wavelength in the lth sub-model, a l1 、a l2 ...a l,337 is the regression coefficient of each wavelength in the lth sub-model, b l is the constant term of the lth sub-model.
[0085] 4.3. Perform five-fold cross validation on all prediction sub-models, and select the top 10% sub-models with the smallest cross-validation root mean square error. The calculation results are rounded off for selection. For example, of the 1347 sub-models initially obtained, the top 135 sub-models can be selected. Use the regression coefficient as the weight of the wavelength, calculate the average weight of each wavelength, and normalize it to [0,1]. Reset the weight of the wavelength not included in the top 10% of the sub-models to 0;
[0086] 4.4. Set the sampling times h2 = 3 × m0, where m0 represents the number of wavelengths whose current weight is not 0. Use weighted random sampling to sample the wavelengths in the spectral transmittance set S1. The larger the weight, the greater the probability that the wavelength will be selected. For wavelengths with a weight of 0, they will not participate in the sampling. The number of wavelengths drawn each time is m0 × 75%, and the multiplication result is also determined by rounding. A total of h2 new spectral transmittance subsets are obtained. The number of rows of each new spectral transmittance subset is 225, and the number of columns is m0 × 75%;
[0087] 4.5. Take each new subset of spectral transmittance as input and the egg cadmium content set Y as output to establish a new multivariate linear regression sub-model, and obtain a total of h2 new sub-models;
[0088] 4.6. Repeat steps 4.3 to 4.5 in a loop, and update m0 until the number of wavelengths whose weight is not 0 is 1, that is, m0 = 1, indicating that only one wavelength is left at this time, and no further sampling is required; perform five-fold cross validation on all sub-models at this time to determine the sub-model with the smallest root mean square error. The number of characteristic wavelengths included in this sub-model is 16, namely 584.1nm, 590.4nm, 597.9nm, 635.6nm, 643.2nm, 655.8nm, 676.1nm, 683.8nm, 840.5nm, 848.3nm, 854.8nm, 859.9nm, 866.4nm, 893.6nm, 900.1nm and 911.7nm; the spectral transmittances corresponding to these 16 characteristic wavelengths constitute the spectral transmittance subset subset F = {f ij ; i = 1, 2, 3, ..., 225; j = 1, 2, 3, ..., 16}, where f ijrepresents the transmittance of the i-th sample at the j-th characteristic wavelength.
[0089] 5. Extract texture feature dataset T:
[0090] The gray-level co-occurrence matrix algorithm is used to calculate the energy, entropy, contrast, inverse variance and correlation of each characteristic wavelength image, a total of 80 (5×16) texture features, and the texture feature data set T = {t ij ; i = 1, 2, 3, ..., 225; j = 1, 2, 3, ..., 80}, where t ij represents the jth texture feature of the i-th sample. The energy of the image is obtained by the following formula:
[0091]
[0092] Where X represents the number of rows of the gray-level co-occurrence matrix, Y represents the number of columns, and g(i,j) is the gray-level co-occurrence matrix.
[0093] 6. Build a detection model:
[0094] 6.1. Taking the color features of sample eggs as input and the cadmium content Y of the corresponding sample eggs as output, different kernel functions are used to construct several prediction sub-models. Taking the spectral transmittance subset F at the characteristic wavelength of the sample eggs as input and the cadmium content Y of the corresponding sample eggs as output, different kernel functions are used to construct several prediction sub-models. Taking the texture feature data set T of the sample eggs as input and the cadmium content of the corresponding sample eggs as output, different kernel functions are used to construct several prediction sub-models. Since different kernel functions are used to produce different prediction results, in this embodiment, each detection model uses a linear kernel function, a polynomial kernel function, a sigmoid kernel function and a radial basis kernel function as kernel functions, and a total of 12 least squares support vector regression sub-models for cadmium content in eggs are established to obtain prediction results Y1-Y 12 , Y i ={y ij ; i = 1, 2, ..., 12; j = 1, 2, 3, ..., 225}, where y ij represents the predicted value of cadmium content of the jth sample in the ith prediction sub-model, and then calculates the root mean square error of the prediction results of each sub-model e = {e1, e2, …, e 12};
[0095] 6.2. Sort the 12 sub-models in ascending order according to the value of the root mean square error, and record them as prediction sub-model 1, prediction sub-model 2, ..., prediction sub-model 12;
[0096] 6.3. Construct a sub-model set M = [], introduce sub-models one by one starting from prediction sub-model 1, and calculate the joint root mean square error e of the existing prediction sub-models in the sub-model set M M , calculate the joint root mean square error e between the prediction sub-model to be introduced and the existing prediction sub-models in the sub-model set M N , when e N Less than e M When , the prediction sub-model is retained, otherwise the prediction sub-model is eliminated, and the above steps are repeated until all prediction sub-models are traversed to obtain the final sub-model set M.
[0097] For example, when there is only prediction sub-model 1 in the sub-model set M, and prediction sub-model 2 is the sub-model to be introduced, the joint root mean square error e of the existing prediction sub-models in the sub-model set M is M =e1, at this time, the joint root mean square error of prediction sub-models 1 and 2 is e N , when e N Less than e M When , the prediction sub-model 2 is retained, otherwise the prediction sub-model 2 is eliminated;
[0098] When prediction sub-model 2 is retained and prediction sub-model 3 is the sub-model to be introduced, the sub-model set M contains prediction sub-model 1 and prediction sub-model 2. At this time, the joint root mean square error of the two prediction sub-models is e M , the joint root mean square error e of prediction sub-model 3, prediction sub-model 1 and prediction sub-model 2 to be introduced N , when e N Less than e M , retain prediction sub-model 3, otherwise remove prediction sub-model 3.
[0099] The calculation method of the combined root mean square error is: the cadmium content prediction value of the i-th prediction sub-model is (y i1 ,y i2 ,...,y i,225 ), calculate the average value of the cadmium content prediction value of each sample obtained by each prediction sub-model, and calculate the root mean square error between the average value and the actual value as the joint root mean square error. For example, when calculating the joint root mean square error of prediction sub-model 1 and prediction sub-model 2, prediction sub-model 1 predicts 225 samples to obtain 225 cadmium content prediction values, which are recorded as (y 11 ,y 12 ,...,y 1,225 ), prediction sub-model 2 predicts 225 samples, and the corresponding 225 cadmium content prediction values are recorded as (y 21 ,y 22 ,...,y2,225), the average value of the 225 prediction values of prediction sub-model 1 and prediction sub-model 2 is calculated as ((y 11+y 21 ) / 2,(y 12 +y 22 ) / 2,...,(y1,225+y2,225) / 2), and the root mean square error of the combination of prediction sub-model 1 and sub-model 2 is calculated based on the 225 average values and the 225 true values of the samples.
[0100] 6.4. Output all sub-models in the set M, and use the average of their prediction results as the prediction result of the cadmium content in eggs to complete the establishment of the prediction model for the cadmium content in eggs.
[0101] The image feature dataset V of 75 samples in the test set, the transmittance F corresponding to the characteristic wavelength determined in the above step and the corresponding texture feature dataset T are obtained, and the features of each sample are input into the prediction sub-model in the sub-model set M to obtain the predicted value of the cadmium content of each sample. The predicted value and the true value of each sample are statistically analyzed to obtain the results as follows: Figure 6 As shown in the figure, each point represents the true value and predicted value of a sample at the same time. The closer the black point is to the diagonal line X=Y, the more accurate the predicted result is. Figure 6 It can be seen that the predicted value of cadmium content is close to the true value, and the determination coefficient R 2 is 0.9342, the root mean square error RMSE is 0.0136, and the relative analysis error RPD is 4.1251. 2 When it is greater than 0.9 and RPD is greater than 3, it indicates that the established model has high prediction accuracy and strong stability.
[0102] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. A nondestructive detection method for cadmium content in poultry eggs, characterized in that: The steps include: S1. Randomly select sample poultry eggs from the poultry eggs to be tested, and obtain the characteristics of the sample poultry eggs and the cadmium content value of the poultry eggs, wherein the characteristics include color characteristics, a spectral transmittance subset at a characteristic wavelength, and texture characteristics; S2, taking the color features of sample eggs as input and the cadmium content of the corresponding sample eggs as output, using different kernel functions to construct several prediction sub-models, taking the spectral transmittance subsets at the characteristic wavelengths of the sample eggs as input and the cadmium content of the corresponding sample eggs as output, using different kernel functions to construct several prediction sub-models, taking the texture features of the sample eggs as input and the cadmium content of the corresponding sample eggs as output, using different kernel functions to construct several prediction sub-models; S3, selecting excellent prediction sub-models from all sub-models to form an optimal prediction sub-model set; S4. Taking the characteristic data of the poultry eggs to be tested as input, the corresponding prediction value is obtained through the prediction sub-model in the optimal prediction sub-model set, and the average of each prediction value is the final prediction value of the final cadmium content of the poultry eggs.
2. The method for nondestructive detection of cadmium content in poultry eggs according to claim 1, characterized in that: The color feature is the color feature of the egg spectral image, and the color feature includes a color feature set of R, G, B, H, S and V channels.
3. The method for nondestructive detection of cadmium content in poultry eggs according to claim 1, characterized in that: The method for obtaining the spectral transmittance subset at the characteristic wavelength comprises: S11, collecting spectral data of sample eggs at different wavelengths, constructing a spectral transmittance set, randomly sampling the wavelengths in the spectral transmittance set, the sampling number h1=3×m, and then obtaining h1 spectral transmittance subsets, the number of wavelengths sampled each time is 75% of the total number of wavelengths; S12, taking each spectral transmittance subset as input and the cadmium content set as output, a multivariate linear regression sub-model is established, and a total of h1 sub-models are obtained; S13, select the top 10% sub-models with the smallest cross-validation root mean square error, use the regression coefficient as the weight of the wavelength, calculate the average weight of each wavelength, and normalize it to [0,1], where the weight of the wavelength not included in the top 10% sub-model is reset to 0; S14, setting the sampling times h2=3×m0, where m0 represents the number of wavelengths whose current weight is not 0, and using weighted random sampling to sample the wavelengths in the spectral transmittance set, where the number of wavelengths sampled each time is m0×75%, and a total of h2 new spectral transmittance subsets are obtained; S15, taking each new spectral transmittance subset as input and the cadmium content set as output, a multivariate linear regression sub-model is established, and a total of h2 sub-models are obtained; S16, repeating steps S13 to S15 in a loop, updating m0, until the number of wavelengths whose weight is not 0 is 1; performing a five-fold cross validation on all sub-models at this time, determining the sub-model with the smallest root mean square error, and its corresponding spectral transmittance constitutes a spectral transmittance subset.
4. The method for nondestructive detection of cadmium content in poultry eggs according to claim 1, characterized in that: The texture features include energy, entropy, contrast, inverse variance and correlation of each characteristic wavelength image.
5. The method for nondestructive detection of cadmium content in poultry eggs according to claim 1, characterized in that: Step S3 includes: S31, calculating the root mean square error value of each sample egg in each prediction sub-model, and arranging all prediction sub-models in ascending order according to the root mean square error value and numbering them, and recording them as prediction sub-model 1, prediction sub-model 2, ..., prediction sub-model n, where n is the number of prediction sub-models; S32, construct a sub-model set M = [], introduce sub-models in sequence starting from prediction sub-model 1, and calculate the joint root mean square error e of the existing prediction sub-models in the sub-model set M M , calculate the joint root mean square error e between the prediction sub-model to be introduced and the existing prediction sub-models in the sub-model set M N , when e N Less than e M When , the prediction sub-model is retained, otherwise the prediction sub-model is eliminated; S33. Repeat step S32 until all prediction sub-models are traversed and the obtained prediction sub-model set is the optimal prediction sub-model set.
6. A nondestructive detection system for cadmium content in poultry eggs, characterized in that: include: A sample acquisition unit, used for randomly selecting sample poultry eggs from the poultry eggs to be tested, and obtaining characteristics of the sample poultry eggs and the cadmium content value of the poultry eggs, wherein the characteristics include color characteristics, a spectral transmittance subset at a characteristic wavelength, and texture characteristics; The detection model unit takes the color characteristics of the sample eggs as input, the cadmium content of the corresponding sample eggs as output, and uses different kernel functions to construct several prediction sub-models; takes the spectral transmittance subset of the sample eggs at the characteristic wavelength as input, the cadmium content of the corresponding sample eggs as output, and uses different kernel functions to construct several prediction sub-models; takes the texture characteristics of the sample eggs as input, the cadmium content of the corresponding sample eggs as output, and uses different kernel functions to construct several prediction sub-models; A screening unit is used to screen excellent sub-models from all prediction sub-models to form an optimal prediction sub-model set; The detection unit is used to take the characteristic data of the poultry eggs to be detected as input, and obtain the corresponding prediction value through the prediction sub-model in the optimal prediction sub-model set, and the average of each prediction value is the final prediction value of the final poultry egg cadmium content.
Citation Information
Cited By
Selenium-rich egg intelligent storage and management method and system
CN119837060A