A food quality component analysis method and system based on near-infrared spectroscopy technology
By forming an infrared spectral matrix, preprocessing, and constructing a quantitative analysis model, the problem of insufficient accuracy and precision of near-infrared spectroscopy in food analysis is solved, enabling rapid and non-destructive detection of food quality and composition.
Patent Information
- Application Number
- CN202510354445.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2045-03-24
AI Technical Summary
Existing near-infrared spectroscopy technology suffers from insufficient accuracy and precision in food analysis, making it difficult to achieve rapid and non-destructive detection of food quality and components.
By acquiring a food sample set, forming an infrared spectral matrix, preprocessing is performed to eliminate noise interference and baseline drift. A quantitative analysis model for food quality is constructed using a partial least squares regression algorithm. Combined with feature wavelength extraction and model calibration, a food quality component analysis report is generated.
It significantly improves the precision and accuracy of food quality component detection, enabling rapid and non-destructive food quality and component analysis, and reducing detection errors and model calibration time.
Smart Images

Figure CN119915770B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of food ingredient analysis, and in particular to a food quality ingredient analysis method and system based on near-infrared spectroscopy technology. BACKGROUND
[0002] In the food industry, accurate identification of food quality and ingredients is crucial to ensure food safety, improve food quality, and meet consumer demand. Traditional food detection methods, including chemical analysis, sensory evaluation, and microbial detection, can provide relatively accurate results, but are often time-consuming and complex to operate, and may damage the food, which cannot meet the needs of modern food industry for rapid, accurate, and non-destructive detection.
[0003] As a non-destructive detection technology, near-infrared spectroscopy technology has the advantages of fast detection speed, simple operation, and no pollution, and has been widely used in food detection in recent years. Near-infrared spectroscopy technology can reflect the absorption and scattering characteristics of different components in the sample by collecting near-infrared spectral information of the food sample, and thus identify the food quality and ingredients.
[0004] However, although existing near-infrared spectroscopy technology has many advantages in food analysis, it still faces some challenges in practical application, such as how to accurately extract and utilize near-infrared spectral information, and how to improve the analysis accuracy and precision of food quality ingredients, so there is room for improvement. SUMMARY
[0005] In order to realize rapid, non-destructive and accurate detection of food quality and ingredients, and improve the precision and accuracy of detection, the present application provides a food quality ingredient analysis method and system based on near-infrared spectroscopy technology.
[0006] The above-mentioned first invention purpose of the present application is achieved by the following technical scheme:
[0007] A food quality ingredient analysis method based on near-infrared spectroscopy technology, the food quality ingredient analysis method based on near-infrared spectroscopy technology comprising the steps of:
[0008] Obtaining a food sample set, obtaining original near-infrared spectral data based on the food sample set, and combining to form an original infrared spectral matrix according to the original near-infrared spectral data;
[0009] Pretreating the original infrared spectral matrix to generate a processed spectral matrix;
[0010] extract a characteristic wavelength of the near-infrared spectrum information based on the processed spectrum matrix, construct a food quality quantitative analysis model according to the characteristic wavelength and in combination with a partial least squares regression algorithm, and output a component content prediction value according to the food quality quantitative analysis model:
[0011]
[0012] wherein β j is a regression coefficient, and x(λ j ) represents an absorbance value at the characteristic wavelength λ j .
[0013] generate a food quality component analysis report to be detected based on the component content prediction value.
[0014] By using the above technical solution, in the process of analyzing the quality and components of food, representative food samples are collected to form a food sample set, ensuring that the samples cover the main types of target food, processing methods and other factors that may affect the quality and components, thereby facilitating the full reflection of the quality component characteristics of the food when establishing the prediction model, providing a solid foundation for subsequent spectrum collection and model establishment. The food samples in the food sample set are scanned by a near-infrared spectrometer to obtain their original near-infrared spectrum information. The original near-infrared spectrum information is preprocessed, including smoothing filter processing, baseline correction and normalization processing, to reduce noise interference, eliminate the influence of baseline drift on spectrum data, enhance spectrum characteristics and improve data comparability, and improve spectrum data quality. The processed near-infrared spectrum information is subjected to a feature selection method of a continuous projection algorithm to extract the most relevant characteristic wavelengths of food quality and components. According to the extracted characteristic wavelengths, a food quality quantitative analysis model is constructed in combination with a least squares regression algorithm, effectively solving the problem of multicollinearity. The food quality quantitative analysis model is used to output a component content prediction value. According to the output component content prediction value, a food quality component analysis report is generated. Through the systematic data processing and modeling process, the precision, efficiency and reliability of food quality component detection are significantly improved, realizing rapid, non-destructive and accurate detection of food quality and components, and improving the precision and accuracy of detection.
[0015] In a preferred example, the application can be further configured to: the preprocessing of the original infrared spectrum matrix to generate a processed spectrum matrix, specifically comprising:
[0016] performing MSC correction on the original infrared spectrum matrix, performing linear regression on each original infrared spectrum to obtain a corrected infrared spectrum;
[0017] performing first derivative filtering on the corrected infrared spectrum and performing normalization processing to generate a processed spectrum matrix.
[0018] By adopting the technical scheme, after the near-infrared spectrum of the food to be detected is collected, all the near-infrared spectra are integrated to form an original infrared spectrum matrix, the original infrared spectrum matrix is subjected to MSC correction and linear regression to generate a corrected spectrum matrix, the scattering effect caused by the difference in sample granularity is effectively eliminated, the corrected spectrum is subjected to first derivative filtering processing to eliminate baseline drift and sharpen absorption peaks, the signal-to-noise ratio at the characteristic wavelength is improved, the spectrum intensity is compressed to the interval [0, 1] through range normalization to eliminate the influence of the optical path difference and reduce the prediction error of different thickness foods.
[0019] In a preferred example, the application can be further configured to: the preprocessing of the original infrared spectrum matrix to generate a processed spectrum matrix further includes:
[0020] determining the Mahalanobis distance between the to-be-detected spectrum and the standard spectrum based on the original infrared spectrum matrix;
[0021] when the Mahalanobis distance between the to-be-detected spectrum and the standard spectrum is greater than a preset distance threshold, marking the spectrum as an abnormal spectrum;
[0022] performing Gaussian weighted smoothing processing on the abnormal spectrum to obtain repaired spectrum data, judging whether the repaired spectrum data is a normal spectrum, and if so, updating the repaired spectrum data to the spectrum matrix.
[0023] By adopting the technical scheme, in the collected near-infrared spectrum data of the food to be detected, abnormal spectra caused by various reasons are likely to occur, the Mahalanobis distance between each to-be-detected spectrum in the original infrared spectrum matrix and the standard spectrum is compared with a preset distance threshold, when the Mahalanobis distance between the to-be-detected spectrum and the standard spectrum is greater than the preset distance threshold, the spectrum data is marked as an abnormal spectrum, Gaussian weighted smoothing processing is performed on the abnormal spectrum to obtain repaired spectrum data, it is judged whether the repaired spectrum data is a normal spectrum, and if so, the repaired spectrum data is updated to the spectrum matrix, thereby the abnormal spectrum in the spectrum matrix can be repaired, and the accuracy of the food quality component detection result is improved.
[0024] In a preferred example, the application can be further configured to: the feature wavelength of the near-infrared spectrum information is extracted based on the processed spectrum matrix, and specifically includes:
[0025] calculating the comprehensive weight of each spectrum wavelength based on the processed spectrum matrix:
[0026]
[0027] In the formula, ρ(x iy) is a correlation coefficient of wavelength j and the target component, is a variance of absorbance of wavelength j;
[0028] According to the comprehensive weight of each spectrum wavelength, the wavelength is selected in turn, and the selected wavelength is screened according to a preset dynamic termination threshold to obtain a candidate wavelength.
[0029] The candidate wavelength is subjected to orthogonalization processing to form a characteristic wavelength of near-infrared spectrum information.
[0030] By adopting the above technical solution, the correlation coefficient of wavelength and the target component, that is, the absorbance variance, is fused to construct a double-factor comprehensive weight, which is beneficial to improve the screening of the characteristic wavelength. According to the comprehensive weight of the wavelength from high to low, the wavelength is selected in turn. The selected wavelength is compared with the preset dynamic termination threshold. Specifically, when the cross-validation root mean square error change rate caused by the selected wavelength is less than 1%, the screening is terminated, and a candidate wavelength is screened out. The candidate wavelength is subjected to orthogonalization processing to form a characteristic wavelength of near-infrared spectrum information, thereby eliminating the collinearity of the selected wavelength, optimizing the information density by removing redundancy, and improving the screening efficiency of the characteristic wavelength.
[0031] In a preferred example, the application can be further configured to, before outputting the component content prediction value according to the food quality quantitative analysis model, the food quality component analysis method based on near-infrared spectrum technology further comprises:
[0032] Acquiring standard substance spectrum data, and calculating a model drift correction coefficient based on the standard substance spectrum data;
[0033] When the model drift correction coefficient is greater than a preset coefficient threshold, adjusting a model intercept term;
[0034] Updating the regression coefficient matrix of the model based on the adjusted model intercept term, and updating the food quality quantitative analysis model by using the updated regression coefficient matrix.
[0035] By adopting the technical scheme, before a food quality quantitative analysis model outputs a prediction result of a to-be-detected food quality component, standard substance spectrum data is collected regularly, a model drift correction coefficient is calculated, model performance attenuation is quantitatively detected, when the model drift correction coefficient is greater than a preset coefficient threshold 2%, a model intercept term is adjusted in proportion, systematic errors caused by instrument baseline drift or environmental temperature and humidity changes are directly eliminated, a regression coefficient matrix is updated based on the adjusted intercept term, a food quality quantitative analysis model is updated by using the updated regression coefficient matrix, and then a dynamic calibration function of the food quality quantitative analysis model is realized, so that the food quality quantitative analysis model can be automatically calibrated when different batches or different types of food are detected, the accuracy of a detection result is improved, and model calibration time is shortened, thereby improving detection efficiency.
[0036] In a second aspect, the above-mentioned application purpose is achieved by the following technical scheme:
[0037] A food quality component analysis system based on near-infrared spectroscopy technology, the food quality component analysis system based on near-infrared spectroscopy technology comprising:
[0038] A food infrared spectrum acquisition module is configured to acquire a food sample set, acquire original near-infrared spectrum data based on the food sample set, and combine original infrared spectrum matrices based on the original near-infrared spectrum data;
[0039] A spectrum preprocessing module is configured to preprocess the original infrared spectrum matrices to generate processed spectrum matrices;
[0040] A model construction module is configured to extract characteristic wavelengths of the near-infrared spectrum information based on the processed spectrum matrices, construct a food quality quantitative analysis model based on the characteristic wavelengths and a partial least squares regression algorithm, and output component content prediction values based on the food quality quantitative analysis model;
[0041] An analysis report generation module is configured to generate a to-be-detected food quality component analysis report based on the component content prediction values.
[0042] By adopting the technical scheme, in the process of analyzing the quality and ingredients of the food, representative food samples are collected to form a food sample set, so as to ensure that the samples cover the main types of target food and processing methods and other factors that may affect the quality and ingredients, and then facilitate the full reflection of the quality and ingredient characteristics of the food when establishing a prediction model, thereby providing a solid foundation for subsequent spectrum collection and model establishment. The food samples in the food sample set are scanned by a near-infrared spectrometer to obtain original near-infrared spectrum information. The original near-infrared spectrum information is preprocessed, including smoothing filter processing, baseline correction and normalization processing, to reduce noise interference, eliminate the influence of baseline drift on spectrum data, enhance spectrum characteristics and improve data comparability, and improve spectrum data quality. The processed near-infrared spectrum information is processed by a continuous projection algorithm feature selection method to extract the most relevant characteristic wavelengths of the food quality and ingredients. According to the extracted characteristic wavelengths, a food quality quantitative analysis model is constructed by combining a least squares regression algorithm, effectively solving the problem of multicollinearity. The food quality quantitative analysis model is used to output ingredient content prediction values. According to the output ingredient content prediction values, a food quality ingredient analysis report is generated. Through the systematic data processing and modeling process, the precision, efficiency and reliability of food quality ingredient detection are significantly improved, realizing rapid, non-destructive and accurate detection of food quality and ingredients, and improving the precision and accuracy of detection.
[0043] In a third aspect, the above object of the present application is achieved by the following technical scheme:
[0044] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the above food quality ingredient analysis method based on near-infrared spectrum technology when executing the computer program.
[0045] In a fourth aspect, the above object of the present application is achieved by the following technical scheme:
[0046] A computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the above food quality ingredient analysis method based on near-infrared spectrum technology.
[0047] In summary, the present application includes at least one of the following beneficial technical effects:
[0048] 1. Use a near-infrared spectrometer to scan the food samples in the food sample set, obtain the original near-infrared spectral information, and preprocess the original near-infrared spectral information, including smoothing filter processing, baseline correction and normalization processing, etc., to reduce noise interference, eliminate the influence of baseline drift on spectral data, enhance spectral characteristics and improve data comparability, improve spectral data quality, and use the continuous projection algorithm feature selection method to process the near-infrared spectral information. Extract the most relevant characteristic wavelengths of food quality and composition, construct a food quality quantitative analysis model based on the extracted characteristic wavelengths and the least squares regression algorithm, effectively solve the problem of multicollinearity, use the constructed food quality quantitative analysis model to output the component content prediction value, generate a food quality component analysis report according to the output component content prediction value, and through the systematic data processing and modeling process, significantly improve the precision, efficiency and reliability of food quality component detection, realize rapid, non-destructive and accurate detection of food quality and composition, and improve the precision and accuracy of detection;
[0049] 2. After collecting the near-infrared spectrum of the food to be tested, integrate all the near-infrared spectra to form an original infrared spectrum matrix, execute MSC correction and linear regression on the original infrared spectrum matrix to generate a corrected spectrum matrix, effectively eliminate the scattering effect caused by the difference in sample granularity, and then use first derivative filter processing on the corrected spectrum to eliminate baseline drift and sharpen absorption peaks, improve the signal-to-noise ratio at the characteristic wavelength, compress the spectrum intensity to the [0, 1] interval through range normalization, eliminate the influence of optical path difference, and reduce the prediction error of different thickness foods;
[0050] 3. In the collected near-infrared spectrum data of the food to be tested, abnormal spectra caused by various reasons may occur. By comparing the Mahalanobis distance between each test spectrum in the original infrared spectrum matrix and the standard spectrum with the preset distance threshold, when the Mahalanobis distance between the test spectrum and the standard spectrum is greater than the preset distance threshold, the spectrum data is marked as an abnormal spectrum, and the abnormal spectrum is subjected to Gaussian weighted smoothing processing to obtain repaired spectrum data. Determine whether the repaired spectrum data is a normal spectrum, if so, update the repaired spectrum data to the spectrum matrix, and further repair the abnormal spectrum in the spectrum matrix, thereby improving the accuracy of the food quality component detection result;
[0051] 4、In the use of food quality quantitative analysis model output to be measured food quality component prediction results before, through the standard material spectrum data collection regularly, calculate the model drift correction coefficient, can quantitatively detect model performance attenuation, when the model drift correction coefficient is greater than the preset coefficient threshold 2%, adjust the model intercept term in proportion, directly eliminate the systematic error caused by instrument baseline drift or environmental temperature and humidity change, based on the adjusted intercept term, update the regression coefficient matrix, using the updated regression coefficient matrix, update the food quality quantitative analysis model, and then realize the dynamic calibration function of food quality quantitative analysis model, can automatically calibrate food quality quantitative analysis model when detecting different batches or different types of food, and then improve the accuracy of detection results and shorten the model calibration time, thereby improving the detection efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0052] Figure 1 is a flowchart of a food quality component analysis method based on near infrared spectroscopy technology in an embodiment of the present application;
[0053] Figure 2 is an implementation flowchart of step S20 in a food quality component analysis method based on near infrared spectroscopy technology in an embodiment of the present application;
[0054] Figure 3 is an abnormal spectrum processing flowchart of a food quality component analysis method based on near infrared spectroscopy technology in an embodiment of the present application;
[0055] Figure 4 is an implementation flowchart of step S30 in a food quality component analysis method based on near infrared spectroscopy technology in an embodiment of the present application;
[0056] Figure 5 is an implementation flowchart of model updating in a food quality component analysis method based on near infrared spectroscopy technology in an embodiment of the present application;
[0057] Figure 6 is a principle block diagram of a food quality component analysis system based on near infrared spectroscopy technology in an embodiment of the present application;
[0058] Figure 7 is a schematic diagram of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0059] The present application will be further described in detail below with reference to the accompanying drawings.
[0060] In an embodiment, as shown in Figure 1 , the present application discloses a food quality component analysis method based on near infrared spectroscopy technology, specifically including the following steps:
[0061] S10: Obtain a food sample set, obtain original near-infrared spectrum data based on the food sample set, and combine to form an original infrared spectrum matrix according to the original near-infrared spectrum data.
[0062] Specifically, in the process of analyzing the quality and ingredients of food, a food sample set is formed by collecting representative food samples, ensuring that the samples cover the main types of target food and processing methods that may affect the quality and ingredients, thereby facilitating the full reflection of the quality and ingredient characteristics of the food in the establishment of the prediction model, providing a solid foundation for subsequent spectrum acquisition and model establishment. The food samples in the food sample set are scanned by a near-infrared spectrometer, and the spectral coverage wavelength range is 900cm-1 to 2500cm-1, the resolution is set to 8cm-1, and each sample is scanned 32 times to obtain its original near-infrared spectrum information.
[0063] S20: Preprocessing the original infrared spectrum matrix to generate a processed spectrum matrix.
[0064] Specifically, the original near-infrared spectrum information is preprocessed, including smoothing filter processing, baseline correction and normalization processing, etc., to reduce noise interference, eliminate the influence of baseline drift on spectrum data, enhance spectrum characteristics and improve data comparability, and improve spectrum data quality.
[0065] S30: Extracting characteristic wavelengths of the near-infrared spectrum information based on the processed spectrum matrix, constructing a food quality quantitative analysis model according to the characteristic wavelengths combined with a partial least squares regression algorithm, and outputting ingredient content prediction values according to the food quality quantitative analysis model.
[0066] Specifically, the continuous projection algorithm feature selection method is used for the processed near-infrared spectrum information to extract the most relevant characteristic wavelengths of food quality and ingredients, and a food quality quantitative analysis model is constructed according to the extracted characteristic wavelengths combined with a least squares regression algorithm, effectively solving the problem of multicollinearity. Specifically, the construction process of the food quality quantitative analysis model is as follows:
[0067] The ridge regression algorithm is used to correct the regression coefficient, which ensures the stability of the model. The variable importance projection index is calculated based on the corrected coefficient, the wavelength is selected by using the variable importance projection index, and a confidence interval is established. The selected variables reduce redundancy, making the confidence interval more reliable. According to the regression coefficient and the confidence interval, a food quality quantitative analysis model is constructed.
[0068] Further, the food quality quantitative analysis model is used to output ingredient content prediction values, specifically as follows:
[0069]
[0070] wherein βj is a regression coefficient, x(λ j ) represents the absorbance value at characteristic wavelength λj.
[0071] S40: generating a food quality ingredient analysis report based on the ingredient content prediction value.
[0072] Specifically, according to the output ingredient content prediction value, a food quality ingredient analysis report is generated, and through a systematic data processing and modeling process, the accuracy, efficiency and reliability of food quality ingredient detection are significantly improved.
[0073] In this embodiment, in the process of analyzing the quality and ingredients of the food, representative food samples are collected to form a food sample set, ensuring that the samples cover the main types of target food and processing methods that may affect the quality and ingredients, thereby facilitating the full reflection of the quality and ingredient characteristics of the food in the establishment of the prediction model, providing a solid foundation for subsequent spectrum collection and model establishment. The food samples in the food sample set are scanned by a near-infrared spectrometer to obtain their original near-infrared spectrum information. The original near-infrared spectrum information is preprocessed, including smoothing filter processing, baseline correction and normalization processing, etc., to reduce noise interference, eliminate the influence of baseline drift on spectrum data, enhance spectrum characteristics and improve data comparability, and improve spectrum data quality. The processed near-infrared spectrum information is extracted using a continuous projection algorithm feature selection method to extract the most relevant characteristic wavelengths of food quality and ingredients. According to the extracted characteristic wavelengths, a food quality quantitative analysis model is constructed using a least squares regression algorithm, effectively solving the problem of multicollinearity. The food quality quantitative analysis model outputs ingredient content prediction values, and a food quality ingredient analysis report is generated based on the output ingredient content prediction values. Through a systematic data processing and modeling process, the accuracy, efficiency and reliability of food quality ingredient detection are significantly improved, realizing rapid, non-destructive and accurate detection of food quality and ingredients, and improving the accuracy and accuracy of detection.
[0074] In an embodiment, as shown in FIG. 2, in step S20, the original infrared spectrum matrix is preprocessed to generate a processed spectrum matrix, which specifically includes: Figure 2
[0075] S21: performing MSC correction on the original infrared spectrum matrix, performing linear regression on each original infrared spectrum to obtain a corrected infrared spectrum.
[0076] Specifically, after collecting the near-infrared spectrum of the food to be tested, all near-infrared spectra are integrated to form an original infrared spectrum matrix. The original infrared spectrum matrix is subjected to MSC correction:
[0077] Where a represents the baseline offset and b represents the linear scaling factor, which is determined by fitting the linear relationship between the measured spectrum and the reference spectrum using the least squares method.
[0078] A corrected spectral matrix is generated, which effectively eliminates the scattering effect caused by differences in sample particle size.
[0079] S22: Apply first-order derivative filtering to the corrected infrared spectrum and perform normalization to generate the processed spectral matrix.
[0080] Specifically, the corrected material is then processed using first-order derivative filtering, where the polynomial order is set to 3 and the sliding window width is 15 wavenumber points to eliminate baseline drift, sharpen absorption peaks, and improve the signal-to-noise ratio at characteristic wavelengths.
[0081] Furthermore, normalization is performed to compress the spectral intensity to the [0,1] range through range normalization, thereby eliminating the influence of optical path difference and reducing the prediction error of foods of different thicknesses.
[0082] In one embodiment, such as Figure 3 As shown, step S20, which involves preprocessing the original infrared spectral matrix to generate the processed spectral matrix, further includes:
[0083] S23: Determine the Mahalanobis distance between the spectrum to be measured and the standard spectrum based on the original infrared spectral matrix.
[0084] Specifically, in the near-infrared spectral data of the food to be tested, abnormal spectra may easily appear due to various reasons. The Mahalanobis distance between each test spectrum and the standard spectrum within the original infrared spectral matrix is calculated using the following formula:
[0085] μ is the standard spectral mean vector, and Σ is the covariance matrix.
[0086] S24: When the Mahalanobis distance between the spectrum to be measured and the standard spectrum is greater than the preset distance threshold, it is marked as an abnormal spectrum.
[0087] Specifically, the Mahalanobis distance between each measured spectrum and the standard spectrum within the initial infrared spectral matrix is greater than a preset distance threshold. That is... The spectral data is marked as an anomalous spectrum.
[0088] S25: Perform Gaussian weighted smoothing on the abnormal spectrum to obtain the repaired spectral data. Determine whether the repaired spectral data is a normal spectrum. If so, update the spectral matrix with the repaired spectral data.
[0089] Specifically, the abnormal spectrum is subjected to Gaussian weighted smoothing processing to obtain repaired spectrum data, it is judged whether the repaired spectrum data is normal spectrum, if yes, the repaired spectrum data is updated into the spectrum matrix, and then the abnormal spectrum in the spectrum matrix can be repaired, thereby the accuracy of the food quality component detection result is improved.
[0090] In an embodiment, as shown in FIG. 3, in step S30, the characteristic wavelength of the near-infrared spectrum information is extracted based on the processed spectrum matrix, specifically including: Figure 4
[0091] S31: The comprehensive weight of each spectrum wavelength is calculated based on the processed spectrum matrix.
[0092] Specifically, according to the formula: In the formula, p(x i ,y) is the correlation coefficient of wavelength j and the target component, is the absorbance variance of wavelength j, the double-factor comprehensive weight is constructed by fusing the correlation coefficient of wavelength and the food target component, i.e., the absorbance variance, and the two factors are coordinated to improve the selection of the characteristic wavelength.
[0093] S32: The wavelengths are sequentially selected according to the comprehensive weight of each spectrum wavelength, and the selected wavelengths are screened according to a preset dynamic termination threshold to obtain candidate wavelengths.
[0094] Specifically, the wavelengths are sequentially selected from high to low according to the comprehensive weight of the wavelengths, and the selected wavelengths are compared with the preset dynamic termination threshold. Specifically, when the cross-validation root mean square error change rate caused by the selected wavelengths is less than 1%, the screening is terminated, and the candidate wavelengths are screened out, thereby avoiding the complication of the food quality quantitative analysis model due to excessive screening.
[0095] S33: The candidate wavelengths are subjected to orthogonalization processing to form the characteristic wavelength of the near-infrared spectrum information.
[0096] Specifically, the selected candidate wavelengths are subjected to orthogonalization processing to eliminate the redundant wavelengths with an absolute value of the correlation coefficient exceeding 0.9, form the characteristic wavelength of the near-infrared spectrum information, eliminate the collinearity influence of the selected wavelengths, optimize the information density by eliminating the redundancy, and improve the selection efficiency of the characteristic wavelength.
[0097] In an embodiment, as shown in FIG. 4, before the component content prediction value is output according to the food quality quantitative analysis model, the food quality component analysis method based on the near-infrared spectrum technology further includes: Figure 5
[0098] S301: The standard substance spectrum data is collected, and the model drift correction coefficient is calculated based on the standard substance spectrum data.
[0099] Specifically, before outputting the prediction result of the to-be-tested food quality component by using the food quality quantitative analysis model, the model drift correction coefficient is calculated by periodically collecting standard substance spectrum data, so that the performance attenuation of the detection model can be quantitatively detected.
[0100] S302: When the model drift correction coefficient is greater than a preset coefficient threshold, the model intercept term is adjusted.
[0101] Specifically, when the model drift correction coefficient is greater than a preset coefficient threshold 2%, the model intercept term is adjusted in proportion, so as to directly eliminate systematic errors caused by instrument baseline drift or environmental temperature and humidity changes.
[0102] S303: The regression coefficient matrix of the model is updated based on the adjusted model intercept term, and the food quality quantitative analysis model is updated by using the updated regression coefficient matrix.
[0103] Specifically, the regression coefficient matrix is synchronously updated based on the adjusted intercept term, and the food quality quantitative analysis model is updated by using the updated regression coefficient matrix, so as to realize the dynamic calibration function of the food quality quantitative analysis model. When different batches or different types of food are detected, the food quality quantitative analysis model can be automatically calibrated, so as to improve the accuracy of the detection result and shorten the model calibration time, thereby improving the detection efficiency.
[0104] It should be understood that the size of the serial number of each step in the above embodiment does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0105] In an embodiment, a food quality component analysis system based on near-infrared spectroscopy technology is provided, which corresponds to the food quality component analysis method based on near-infrared spectroscopy technology in the above embodiment. As shown in the figure, the food quality component analysis system based on near-infrared spectroscopy technology includes a food infrared spectrum acquisition module, a spectrum preprocessing module, a model construction module and an analysis report generation module. The functions of each functional module are described in detail as follows: Figure 6
[0106] The food infrared spectrum acquisition module is used to obtain a food sample set, obtain original near-infrared spectrum data based on the food sample set, and combine the original near-infrared spectrum data to form an original infrared spectrum matrix.
[0107] The spectrum preprocessing module is used to preprocess the original infrared spectrum matrix to generate a processed spectrum matrix.
[0108] a model construction module, configured to extract characteristic wavelengths of the near-infrared spectrum information based on the processed spectrum matrix, and construct a food quality quantitative analysis model according to the characteristic wavelengths and in combination with a partial least squares regression algorithm, and output a component content prediction value according to the food quality quantitative analysis model;
[0109] an analysis report generation module, configured to generate a food quality component analysis report to be detected based on the component content prediction value.
[0110] Preferably, the spectrum preprocessing module comprises:
[0111] an MSC correction submodule, configured to perform MSC correction on the original infrared spectrum matrix, and perform linear regression on each original infrared spectrum to obtain a corrected infrared spectrum;
[0112] a first derivative filter submodule, configured to perform first derivative filtering on the corrected infrared spectrum, and perform normalization processing to generate a processed spectrum matrix.
[0113] Preferably, the model construction module comprises:
[0114] a spectrum wavelength weight determination submodule, configured to calculate comprehensive weights of each spectrum wavelength based on the processed spectrum matrix;
[0115] a wavelength screening submodule, configured to sequentially select wavelengths according to the comprehensive weights of each spectrum wavelength, and screen out candidate wavelengths according to a preset dynamic termination threshold for the selected wavelengths;
[0116] a characteristic wavelength generation submodule, configured to perform orthogonalization processing on the candidate wavelengths to form characteristic wavelengths of the near-infrared spectrum information.
[0117] For specific limitations of the food quality component analysis system based on the near-infrared spectrum technology, refer to the limitations of the food quality component analysis method based on the near-infrared spectrum technology in the foregoing, which will not be described herein. Each module in the food quality component analysis system based on the near-infrared spectrum technology can be realized by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in an electronic device in a hardware form, or can be stored in a memory in the electronic device in a software form, so as to be called and executed by the processor to perform operations corresponding to each module.
[0118] In one embodiment, an electronic device, which can be a server, is provided, and an internal structure diagram of the electronic device can be as shown in Figure 7An electronic device is shown. The electronic device includes a processor, a memory, a network interface and a database connected through a system bus. The processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The database of the electronic device is configured to store food near-infrared spectrum and food quality quantitative analysis model. The network interface of the electronic device is configured to communicate with an external terminal through a network connection. The computer program is executed by the processor to implement a food quality component analysis method based on near-infrared spectrum technology.
[0119] In one embodiment, an electronic device is provided, including a memory, a processor and a computer program stored in the memory and executable on the processor, the processor executing the computer program to implement the following steps:
[0120] obtaining a food sample set, obtaining original near-infrared spectrum data based on the food sample set, and combining to form an original infrared spectrum matrix according to the original near-infrared spectrum data;
[0121] preprocessing the original infrared spectrum matrix to generate a processed spectrum matrix;
[0122] extracting characteristic wavelengths of the near-infrared spectrum information based on the processed spectrum matrix, constructing a food quality quantitative analysis model according to the characteristic wavelengths combined with a partial least squares regression algorithm, and outputting a component content prediction value according to the food quality quantitative analysis model;
[0123] generating a food quality component analysis report to be detected based on the component content prediction value.
[0124] In one embodiment, a computer readable storage medium is provided, having a computer program stored thereon, the computer program being executed by a processor to implement the following steps:
[0125] obtaining a food sample set, obtaining original near-infrared spectrum data based on the food sample set, and combining to form an original infrared spectrum matrix according to the original near-infrared spectrum data;
[0126] preprocessing the original infrared spectrum matrix to generate a processed spectrum matrix;
[0127] extracting characteristic wavelengths of the near-infrared spectrum information based on the processed spectrum matrix, constructing a food quality quantitative analysis model according to the characteristic wavelengths combined with a partial least squares regression algorithm, and outputting a component content prediction value according to the food quality quantitative analysis model;
[0128] Generate a food quality ingredient analysis report to be detected based on the ingredient content prediction value.
[0129] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiments. Any reference to memory, storage, database or other medium used in the embodiments provided by the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0130] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of functional units and modules is exemplified. In actual application, the above-mentioned functions can be completed by different functional units or modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above.
[0131] The above-mentioned embodiments are only used to illustrate the technical solutions of the present application, and not to limit them. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some technical features. These modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. A method for analyzing food quality components based on near-infrared spectroscopy, characterized in that, The food quality component analysis method based on near-infrared spectroscopy includes the following steps: A food sample set is obtained, and raw near-infrared spectral data is obtained based on the food sample set. A raw infrared spectral matrix is formed by combining the raw near-infrared spectral data. The original infrared spectral matrix is preprocessed to generate a processed spectral matrix; Based on the processed spectral matrix, the characteristic wavelengths of the near-infrared spectral information are extracted, specifically including: Based on the processed spectral matrix, the comprehensive weight of each spectral wavelength is calculated according to a preset formula; the formula is as follows: ,in, Let be the correlation coefficient between wavelength j and the target component. Let be the absorbance variance at wavelength j. By fusing the correlation coefficient between wavelength and target food components, i.e., the absorbance variance, a two-factor comprehensive weighting is constructed. Wavelengths are selected sequentially based on the comprehensive weight of each spectral wavelength, and candidate wavelengths are filtered out based on a preset dynamic termination threshold after the selection. The candidate wavelengths are orthogonalized to form characteristic wavelengths of near-infrared spectral information; Based on the characteristic wavelength, and combined with the partial least squares regression algorithm, a quantitative analysis model for food quality is constructed, and the predicted values of component content are output based on the quantitative analysis model for food quality. A quality component analysis report for the food to be tested is generated based on the predicted component content values.
2. The food quality component analysis method based on near-infrared spectroscopy according to claim 1, characterized in that, The preprocessing of the original infrared spectral matrix to generate the processed spectral matrix specifically includes: Perform MSC correction on the original infrared spectral matrix and perform linear regression on each original infrared spectrum to obtain the corrected infrared spectrum; The corrected infrared spectrum is filtered using the first derivative and then normalized to generate the processed spectral matrix.
3. The food quality component analysis method based on near-infrared spectroscopy according to claim 1, characterized in that, The step of preprocessing the original infrared spectral matrix to generate the processed spectral matrix further includes: The Mahalanobis distance between the measured spectrum and the standard spectrum is determined based on the original infrared spectral matrix. When the Mahalanobis distance between the spectrum to be measured and the standard spectrum is greater than a preset distance threshold, it is marked as an abnormal spectrum; The abnormal spectrum is subjected to Gaussian weighted smoothing to obtain the repaired spectral data. It is then determined whether the repaired spectral data is a normal spectrum. If so, the repaired spectral data is updated in the spectral matrix.
4. The food quality component analysis method based on near-infrared spectroscopy according to claim 1, characterized in that, Before outputting the predicted component content value according to the quantitative analysis model of food quality, the food quality component analysis method based on near-infrared spectroscopy further includes: Collect spectral data of standard substances and calculate the model drift correction coefficient based on the spectral data of the standard substances; When the model drift correction coefficient is greater than the preset coefficient threshold, the model intercept term is adjusted; The regression coefficient matrix of the model is updated based on the adjusted model intercept term, and the updated regression coefficient matrix is used to update the quantitative analysis model of food quality.
5. A food quality component analysis system based on near-infrared spectroscopy, characterized in that, The food quality component analysis system based on near-infrared spectroscopy technology includes: The food infrared spectroscopy acquisition module is used to acquire a food sample set, acquire raw near-infrared spectral data based on the food sample set, and combine the raw near-infrared spectral data to form a raw infrared spectral matrix. The spectral preprocessing module is used to preprocess the original infrared spectral matrix to generate a processed spectral matrix; The model building module is used to extract the characteristic wavelengths of the near-infrared spectral information based on the processed spectral matrix, specifically including: The spectral wavelength weighting determination submodule is used to calculate the comprehensive weight of each spectral wavelength based on the processed spectral matrix according to a preset formula; the formula is as follows: ,in, Let be the correlation coefficient between wavelength j and the target component. Let be the absorbance variance at wavelength j. By fusing the correlation coefficient between wavelength and target food components, i.e., the absorbance variance, a two-factor comprehensive weighting is constructed. The wavelength selection submodule is used to select wavelengths sequentially according to the comprehensive weight of each spectral wavelength, and to filter out candidate wavelengths based on a preset dynamic termination threshold after the selection. The feature wavelength generation submodule is used to orthogonalize the candidate wavelengths to form the feature wavelengths of near-infrared spectral information; based on the feature wavelengths, combined with the partial least squares regression algorithm, a food quality quantitative analysis model is constructed, and the predicted values of component content are output based on the food quality quantitative analysis model. The analysis report generation module is used to generate an analysis report of the quality components of the food to be tested based on the predicted component content values.
6. The food quality component analysis system based on near-infrared spectroscopy technology according to claim 5, characterized in that, The spectral preprocessing module includes: The MSC correction submodule is used to perform MSC correction on the original infrared spectral matrix, and to perform linear regression on each original infrared spectrum to obtain the corrected infrared spectrum. The first-order derivative filtering submodule is used to apply first-order derivative filtering to the corrected infrared spectrum and perform normalization to generate the processed spectral matrix.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the food quality component analysis method based on near-infrared spectroscopy as described in any one of claims 1 to 4.
8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the food quality component analysis method based on near-infrared spectroscopy as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Near infrared spectrum information extraction method based on canonical correlation coefficients
CN105891147A
Method for detecting internal quality of fruits with near infrared spectrum and special detection system
CN106841103A
Near-infrared quantitation system for proteins and fats in coffee milk beverage, and establishment method thereof
CN108572155A