A method and system for rapid detection of tea quality
By using baseline correction and smoothing filtering, combined with a tea quality scoring model, the quality influencing factors and spectral intensity distribution within the neighborhood of the spectral peak are quantitatively evaluated. Influence coefficients are constructed, and spectral weights are dynamically allocated. This solves the problem of noise interference in near-infrared spectral data acquisition and improves the accuracy of tea quality detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- YUNNAN AGRICULTURAL UNIVERSITY
- Filing Date
- 2025-10-14
- Publication Date
- 2026-07-07
AI Technical Summary
In existing tea quality testing methods, traditional near-infrared spectroscopy data acquisition suffers from high signal-to-noise ratios due to environmental noise interference, and the simple averaging method cannot accurately reflect the true characteristics of tea, thus reducing the accuracy of the test results.
After baseline correction and smoothing filtering, combined with the tea quality scoring model, the quality influencing factors and spectral intensity distribution in the neighborhood of the spectral peak are quantitatively evaluated, the first and second influence coefficients are constructed, the spectral weights are dynamically allocated, and the spectral fusion is optimized.
It effectively reduces the impact of noise interference and background drift on tea quality testing, and improves the accuracy and reliability of the test results.
Smart Images

Figure CN121384867B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of near-infrared spectroscopy detection technology, specifically to a rapid detection method and system for tea quality. Background Technology
[0002] Near-infrared spectroscopy is a commonly used method for tea quality testing. It can quickly and easily detect the internal quality of tea. When using near-infrared spectroscopy for rapid tea quality testing, existing methods usually involve repeatedly collecting spectra and taking the average value to generate spectra for subsequent analysis. This method aims to suppress the unavoidable random noise during data acquisition, thereby reducing its impact on the accuracy of the final quality test results.
[0003] However, due to the dynamic changes in the internal and external environment of the acquisition equipment, the degree of noise interference varies among different near-infrared spectral data. The traditional simple averaging method fails to distinguish between the quality of spectral data, resulting in high-quality spectra with high signal-to-noise ratios not receiving the appropriate weight in the averaging process. Consequently, the synthesized spectrum cannot accurately reflect the true characteristics of tea, ultimately reducing the accuracy of tea quality testing results. Summary of the Invention
[0004] To address the aforementioned technical problems, the purpose of this application is to provide a rapid method and system for detecting tea quality, the specific technical solution of which is as follows:
[0005] In a first aspect, embodiments of this application provide a rapid method for detecting tea quality, the method comprising the following steps:
[0006] The tea quality scoring model and the initial spectra of the tea sample under all measurements were obtained, and each initial spectrum was subjected to baseline correction and smoothing filtering to obtain each preprocessed spectrum of the tea sample.
[0007] Based on the tea quality scoring model, the quality influence factor of each wavelength in each preprocessed spectrum is obtained; based on the average distribution of the quality influence factor and the average distribution of the spectral intensity at all wavelengths in the neighborhood of each spectral peak in each preprocessed spectrum, the first influence coefficient of each preprocessed spectrum is determined.
[0008] Based on the differences in spectral intensities between the neighborhood of each spectral peak in each preprocessed spectrum and its corresponding band in the initial spectrum, the smoothing characteristic value of each spectral peak in each preprocessed spectrum is determined. Combined with the fitting error when fitting the spectral intensities at all wavelengths within the neighborhood of each spectral peak, the loss characteristic value of each spectral peak in each preprocessed spectrum is determined. Based on the average distribution of quality influence factors at all wavelengths within the neighborhood of each spectral peak in each preprocessed spectrum, and the loss characteristic value, the second influence coefficient of each preprocessed spectrum is determined. Combined with the first influence coefficient, the weighting coefficient of each preprocessed spectrum is determined.
[0009] Based on all preprocessed spectra of the tea sample to be tested and their weighting coefficients, the target spectrum of the tea sample to be tested is determined, and the quality of the tea sample to be tested is evaluated by combining the tea quality scoring model.
[0010] Preferably, the method for obtaining the quality influence factor of each wavelength in each preprocessed spectrum is as follows:
[0011] The independent variable in the tea quality scoring model is the spectral intensity at each wavelength, and the dependent variable is the tea quality score. The coefficients before all independent variables in the tea quality scoring model are used as the quality influence factors for the corresponding wavelengths. The quality influence factors for each wavelength in each preprocessed spectrum in the tea quality scoring model are obtained.
[0012] Preferably, the method for determining the first influence coefficient of each preprocessed spectrum is as follows:
[0013] Calculate the mean value of the quality influence factor and the mean value of the spectral intensity at all wavelengths in the neighborhood of each spectral peak in each preprocessed spectrum, and record them as the quality influence coefficient and spectral mean of each spectral peak, respectively.
[0014] Calculate the product of the normalized value of the quality influence coefficient of each spectral peak and the spectral mean. Use the mean of the product of all spectral peaks in each preprocessed spectrum as the first influence coefficient of each preprocessed spectrum.
[0015] Preferably, the smoothing feature value of each spectral peak in each preprocessed spectrum is the spectral angle of all spectral intensities between the neighborhood of each spectral peak in the preprocessed spectrum and its corresponding band in the initial spectrum.
[0016] Preferably, the loss characteristic value of each spectral peak in each preprocessed spectrum is the result of positively fusing the normalized value of the fitting error and the normalized value of the corresponding smooth characteristic value when fitting the spectral intensity of each spectral peak in the neighborhood of all wavelengths in each preprocessed spectrum.
[0017] Preferably, the method for determining the second influence coefficient of each preprocessed spectrum is as follows:
[0018] Calculate the product of the quality influence coefficient of each spectral peak in each preprocessed spectrum and the loss characteristic value, and take the mean of the product of all spectral peaks in each preprocessed spectrum as the second influence coefficient of each preprocessed spectrum.
[0019] Preferably, the weighting coefficient of each preprocessed spectrum is the reciprocal of the average of the normalized values of the first influence coefficient and the second influence coefficient of each preprocessed spectrum.
[0020] Preferably, the method for determining the target spectrum of the tea sample to be tested is as follows:
[0021] The product of the spectral intensity at each wavelength in each preprocessed spectrum of the tea sample to be tested and the normalized value of the corresponding weighting coefficient is calculated and denoted as the weighted spectral intensity. The mean of the weighted spectral intensities at the same wavelength in all preprocessed spectra of the tea sample to be tested is taken as the spectral intensity at the corresponding wavelength in the target spectrum. The target spectrum is obtained by traversing all wavelengths.
[0022] Preferably, the evaluation of the quality of the tea sample to be tested includes:
[0023] The target spectrum of the tea sample to be tested is used as input to the tea quality scoring model, and the tea quality score of the tea sample to be tested is output. Secondly, embodiments of this application also provide a rapid tea quality detection system, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps of any of the above-described rapid tea quality detection methods.
[0024] This application has at least the following beneficial effects:
[0025] This application performs baseline correction and noise smoothing on the near-infrared spectral data of the collected tea samples, effectively reducing background spectral drift caused by noise interference and the impact of noise on the accuracy of subsequent tea quality testing results. Furthermore, based on the average distribution of quality influence factors and the average distribution of spectral intensity at all wavelengths in the neighborhood of each spectral peak in each preprocessed spectrum, this application constructs a first influence coefficient to quantitatively evaluate the comprehensive impact of residual background drift on tea quality testing, effectively reducing background drift interference and helping to improve the accuracy of tea quality testing results. Furthermore, this application quantitatively evaluates the smoothing and loss eigenvalues of each spectral peak in the preprocessed spectrum, constructs a second influence coefficient in conjunction with the quality influence factor, and then determines the weight coefficient of each preprocessed spectrum by comprehensively considering the first influence coefficient. This effectively suppresses the interference of feature loss and residual background drift caused by smoothing processing on quality detection, thereby improving the accuracy of tea quality detection. In summary, this application comprehensively evaluates the impact of residual background drift and smoothing feature loss in the preprocessed spectrum on tea quality detection, constructs the first and second influence coefficients, and dynamically allocates the weight of each preprocessed spectrum accordingly. This effectively suppresses the interference of noise and distortion on the detection results, thereby improving the accuracy of tea quality detection. Attached Figure Description
[0026] To more clearly illustrate the technical solutions and advantages in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 A flowchart illustrating the steps of a rapid detection method for tea quality provided in one embodiment of this application;
[0028] Figure 2 This is a schematic diagram of the weight coefficient extraction process provided in one embodiment of this application. Detailed Implementation
[0029] To further illustrate the technical means and effects adopted by this application to achieve the intended purpose of the invention, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of a rapid detection method and system for tea quality proposed in this application. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.
[0030] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.
[0031] The following description, in conjunction with the accompanying drawings, details the specific scheme of a rapid detection method and system for tea quality provided in this application.
[0032] Please see Figure 1 The diagram illustrates a flowchart of a rapid tea quality detection method according to an embodiment of this application, which includes the following steps:
[0033] Step S1: Obtain the tea quality scoring model and the initial spectra of all measurements of the tea sample to be tested, and perform baseline correction and smoothing filtering on each initial spectrum to obtain each preprocessed spectrum of the tea sample to be tested.
[0034] First, a large number of tea samples of different qualities were manually selected, with each tea leaf constituting a single sample. These numerous samples represented all possible tea varieties. Next, near-infrared spectroscopy was used to acquire the spectra of each tea sample, and each sample was manually evaluated to obtain a tea quality score. Based on the spectra of all tea samples and their corresponding quality scores, a tea quality scoring model was constructed. Specifically:
[0035] Assume the relationship between the tea quality score and the corresponding spectrum for each tea sample is as follows:
[0036] In the formula, This represents the tea quality score of the j-th tea sample; Let represent the spectral intensity at wavelength i in the spectrum of the j-th tea sample. This represents the coefficient of the i-th independent variable. Therefore, each tea sample corresponds to one of the above relationships. Assuming there are m samples, we can derive m equations, namely:
[0037] Equation for tea sample 1: ;
[0038] Equation for tea sample 2: ;
[0039] …
[0040] The equation for tea sample m: ;
[0041] In the above system of equations, all Y and all X are known, and the only unknowns are A1, A2, ..., An. Furthermore, this embodiment employs Partial Least Squares (PLS), using the above system of equations as input and outputting the solutions corresponding to the unknowns, thus obtaining the known A1, A2, ..., An. From this, the tea quality scoring model Y can be obtained, specifically:
[0042]
[0043] In the formula, These represent the spectral intensities at wavelengths 1, 2, ..., i, ..., n, respectively. That is, according to the tea quality scoring model, by arbitrarily inputting the spectrum of a tea sample, its corresponding tea quality score Y can be obtained, thus completing the construction of the tea quality scoring model.
[0044] Among them, the partial least squares method (PLS) is a well-known technique, and the specific process of using it to solve for unknowns will not be elaborated here.
[0045] Furthermore, a tea sample to be tested is obtained, and the initial spectrum of the tea sample is repeatedly measured using a near-infrared spectrometer for a total of N measurements. The value of N is set manually. In this embodiment, the value of N is 20. In actual applications, as other implementation methods, implementers can also set their own values according to specific circumstances. This embodiment does not impose any special restrictions.
[0046] During the process of collecting the spectrum of tea samples using a near-infrared spectrometer, the instrument's condition often changes due to prolonged continuous operation. For example, the light source intensity of the near-infrared spectrometer varies with temperature and voltage, and the dark current increases with increasing detection temperature. This causes background spectral shift in the collected tea sample spectrum, resulting in baseline drift. Furthermore, the near-infrared spectrometer exhibits different energy responses to different bands in different spectra, leading to numerous noise spikes in the collected tea sample spectrum. Both background spectral shift and noise spikes cause the spectral intensity in the spectrum reflecting tea quality characteristics to deviate from its true value, thus affecting the accuracy of subsequent tea quality testing results.
[0047] Therefore, baseline correction is used to perform baseline correction on the spectrum of the tea sample to be tested, thereby reducing the probability of background spectral drift in the spectrum of the tea sample. There are many commonly used baseline correction methods. In this embodiment, a baseline correction method based on the first-order differential method is used to perform baseline correction on the spectrum of the tea sample to be tested. In practical applications, as other real-time methods, implementers can also use other baseline correction methods such as baseline correction drift based on polynomial fitting or baseline correction drift based on wavelet transform, depending on the specific situation. This embodiment does not impose any special restrictions on the selection of baseline correction methods.
[0048] The specific process of using the baseline correction method based on the first-order differential method to perform baseline correction processing on the spectrum of the tea sample to be tested is a well-known technique and will not be described in detail here.
[0049] Furthermore, in order to eliminate the burr noise within the spectral peaks, the spectrum of the tea sample to be tested after baseline correction is used as the input of the filtering algorithm, and the output is the smoothed filtered spectrum. In this embodiment, the Savitzky-Golay smoothing filtering algorithm is selected to smooth the spectrum. In practical applications, as other implementation methods, implementers may also select other filtering algorithms such as the moving window average smoothing algorithm according to specific circumstances. This embodiment does not impose any special restrictions on the selection of filtering algorithms.
[0050] Among them, the Savitzky-Golay smoothing filtering algorithm is a well-known technique, and the specific process of using it to smooth the spectrum will not be described in detail.
[0051] Thus, the preprocessed spectra of the tea samples to be tested are obtained by performing preliminary baseline correction and smoothing filtering on each initial spectrum of the tea sample to be tested.
[0052] Step S2: By comprehensively analyzing the quality influencing factors, spectral intensity distribution, smoothing eigenvalues and fitting errors of the preprocessed spectra, the first and second influence coefficients are calculated respectively to dynamically determine the weight coefficients of each preprocessed spectrum and optimize spectral fusion.
[0053] However, baseline correction processing usually cannot completely correct baseline drift in the spectrum. Therefore, this embodiment evaluates the impact of residual background spectral drift in the pre-processed spectrum of the tea sample on the tea quality detection results. Different weights are assigned to each spectral intensity in the weighted averaging process of the tea sample's spectrum to reduce the impact of residual background spectral drift on the tea sample quality detection results. The specific process is as follows:
[0054] S2.1 Based on the tea quality scoring model, obtain the quality influence factor of each wavelength in each preprocessed spectrum; based on the average distribution of the quality influence factor and the average distribution of the spectral intensity of all wavelengths in the neighborhood of each spectral peak in each preprocessed spectrum, determine the first influence coefficient of each preprocessed spectrum.
[0055] Since the criteria for judging the quality of different types of tea are usually different, different spectral peaks in the spectrum of the collected tea samples will often have different effects on the detection results of tea quality. For example, the spectral peaks of tannin compounds in the near-infrared spectrum are the most important characteristic spectral peaks of Pu'er tea, while the spectral peaks of carboxylic acid compounds and polysaccharide compounds in the near-infrared spectrum are typical spectral peaks of dark tea. Therefore, in order to more accurately evaluate the impact of residual background spectral drift in the spectrum of the tea samples on the detection results of tea quality, this embodiment first obtains the quality influence factor of each wavelength in each preprocessed spectrum based on the tea quality scoring model. Furthermore, it analyzes the average distribution of the quality influence factor of all wavelengths in the neighborhood of each spectral peak in each preprocessed spectrum, specifically:
[0056] First, in this embodiment, the preprocessed spectrum of the tea sample to be tested is used as the input of the symmetric zero-area peak finding method, and all spectral peaks in the preprocessed spectrum are output. The symmetric zero-area peak finding method is a well-known technique, and the specific process of obtaining spectral peaks in the spectrum using it will not be described in detail.
[0057] Furthermore, based on the tea quality scoring model, the quality influencing factors for each wavelength in each preprocessed spectrum are obtained, specifically:
[0058] In this embodiment, according to the expression of the tea quality scoring model in step S1, the independent variable in the tea quality scoring model is the spectral intensity at each wavelength, and the dependent variable is the tea quality score. The coefficients before all independent variables in the tea quality scoring model are used as the quality influence factors of the corresponding wavelengths, and the quality influence factors of each wavelength in each preprocessed spectrum in the tea quality scoring model are obtained.
[0059] Furthermore, this embodiment analyzes the average distribution of quality influence factors at all wavelengths within the neighborhood of each spectral peak in each preprocessed spectrum. Specifically:
[0060] In this embodiment, the mean value of the quality influence factor at all wavelengths in the neighborhood of each spectral peak in each preprocessed spectrum is calculated and denoted as the quality influence coefficient of each spectral peak. The quality influence coefficient reflects the importance of a certain spectral peak to the tea quality detection result and is used to characterize the importance of the spectral peak in the tea quality evaluation. If the quality influence coefficient of the current spectral peak is larger, it indicates that the current spectral peak has a stronger indicative role in the judgment of tea quality. Conversely, if the quality influence coefficient of the current spectral peak is smaller, it indicates that the current spectral peak has a weaker indicative role in the judgment of tea quality, indicating that the spectral peak has a lower importance in the tea quality evaluation and is not strongly correlated with the key characteristics of tea quality. Therefore, it should be given a smaller weight in subsequent modeling or weighted averaging to reduce its interference or influence on the final detection result.
[0061] It should be noted that the specific process for obtaining the neighborhood of the spectral peak is as follows: In this embodiment, the entire peak width of the spectral peak is taken as the neighborhood of the spectral peak.
[0062] Meanwhile, under normal circumstances, the baseline in the spectrum refers to the reference level of spectral intensity measured without a sample or light source. Ideally, it is a horizontal line close to zero spectral intensity. The drift of the background spectrum usually causes the overall baseline to shift or fluctuate, causing the bottom of the spectral peak of the background spectrum to deviate from its zero spectral intensity horizontal line, that is, the horizontal line where the ideal baseline in the spectrum is located. Therefore, the greater the degree to which the bottom of the spectral peak in the spectrum of the tea sample to be tested deviates from its zero spectral intensity horizontal line after baseline correction, the greater the residual degree of background spectral drift in the spectrum.
[0063] Therefore, based on the above analysis, this embodiment determines the first influence coefficient of each preprocessed spectrum by analyzing the average distribution of spectral intensity at all wavelengths in the neighborhood of each spectral peak, and combining it with the quality influence coefficient. Specifically:
[0064] In this embodiment, the mean value of the spectral intensity at all wavelengths in the neighborhood of each spectral peak in each preprocessed spectrum is recorded as the spectral mean of each spectral peak. This is used to characterize the degree to which the bottom of the spectral peak deviates from the ideal baseline. If the spectral mean of the current spectral peak is larger, it indicates that the spectral peak is more affected by background drift, and its spectral intensity may deviate from the true value, thereby reducing the weight of the current spectral peak in the subsequent weighted average. Conversely, if the spectral mean of the current spectral peak is smaller, it indicates that the spectral peak is less affected by background drift, and its spectral intensity is closer to the true value. This indicates that the spectral peak has a better background drift correction effect in the preprocessing process and the data has higher reliability. Therefore, it should be given a larger weight in the subsequent weighted average to enhance its contribution to the final tea quality detection result.
[0065] Furthermore, the product of the normalized value of the quality influence coefficient of each spectral peak and the spectral mean is calculated, and the mean of the product of all spectral peaks in each preprocessed spectrum is used as the first influence coefficient of each preprocessed spectrum.
[0066] It should be noted that there are many commonly used normalization methods. In this embodiment, the maximum-minimum normalization method is used to normalize the quality influence coefficient. In practical applications, as other implementation methods, implementers may also use other normalization methods such as z-score standardization according to specific circumstances. This embodiment does not impose any special restrictions on the selection of normalization methods.
[0067] The maximum-minimum normalization method is a well-known technique, and the specific process of using it to normalize the quality influence coefficient will not be elaborated here.
[0068] It should be noted that, unless otherwise specified, all normalization calculations in this embodiment adopt the maximum-minimum value normalization method, which will not be elaborated further.
[0069] Based on the first influence coefficient of each preprocessed spectrum, it can be understood that the first influence coefficient is used to characterize the comprehensive impact of residual background drift in the spectrum on the quality detection results. If the quality influence coefficient of the spectral peak in the current preprocessed spectrum is larger, it means that the corresponding spectral peak amplifies the influence of residual background drift, and the interference with the quality detection results is greater. Therefore, the larger the corresponding first influence coefficient, the greater the impact of residual background drift on the quality detection results of tea samples. At the same time, if the average level of the spectral mean of the spectral peak in the current preprocessed spectrum is larger, it means that the background drift of the current preprocessed spectrum is more serious, and the impact on the quality detection results of tea samples is greater. Therefore, the corresponding first influence coefficient is larger.
[0070] Conversely, if the quality influence coefficient of the spectral peak in the current preprocessed spectrum is smaller, it indicates that the amplification effect of the corresponding spectral peak on the residual background drift is weaker, and the interference on the quality detection results is smaller. Therefore, the smaller the corresponding first influence coefficient, the smaller the influence of the residual background drift on the quality detection results of the tea sample. At the same time, if the average level of the spectral mean of the spectral peak in the current preprocessed spectrum is smaller, it indicates that the background drift of the current preprocessed spectrum is more slight, and the influence on the quality detection results of the tea sample is smaller. Therefore, the corresponding first influence coefficient is smaller.
[0071] Thus, this embodiment combines the quality influence coefficient of the spectral peak with the spectral mean to quantitatively evaluate the comprehensive impact of residual background drift on tea quality detection, effectively reducing the interference of background drift and contributing to the accuracy of tea quality detection results.
[0072] S2.2 Based on the difference in spectral intensity between the neighborhood of each spectral peak in each preprocessed spectrum and its corresponding band in the initial spectrum, determine the smoothing characteristic value of each spectral peak in each preprocessed spectrum. Combined with the fitting error when fitting the spectral intensity at all wavelengths in the neighborhood of each spectral peak, determine the loss characteristic value of each spectral peak in each preprocessed spectrum. Based on the average distribution of the quality influence factors of all wavelengths in the neighborhood of each spectral peak in each preprocessed spectrum, and the loss characteristic value, determine the second influence coefficient of each preprocessed spectrum. Combined with the first influence coefficient, determine the weight coefficient of each preprocessed spectrum.
[0073] Furthermore, existing spectral data smoothing methods typically apply the same smoothing process to all data. For example, the Savitzky-Golay smoothing filter algorithm uses the same window length and polynomial order to smooth all spectral data. However, not all spectral peaks in the acquired near-infrared spectral data contain spike noise, and the amount of spike noise varies. This can lead to situations where, after smoothing, the spectral peaks in the acquired near-infrared spectral data of the tea sample being tested are over-smoothed, obscuring their original peak shapes, or the spectral peaks are not effectively smoothed, retaining some spike noise. This can affect the accuracy of subsequent quality detection of the tea sample.
[0074] Therefore, this embodiment determines the smoothing characteristic value of each spectral peak in each preprocessed spectrum based on the difference in spectral intensity between the neighborhood of each spectral peak in each preprocessed spectrum and its corresponding band in the initial spectrum. It then determines the loss characteristic value of each spectral peak in each preprocessed spectrum by combining the fitting error when fitting the spectral intensity at all wavelengths in the neighborhood of each spectral peak. Based on the average distribution of quality influence factors at all wavelengths in the neighborhood of each spectral peak in each preprocessed spectrum, and the loss characteristic value, it determines the second influence coefficient of each preprocessed spectrum. Combined with the first influence coefficient, it determines the weighting coefficient of each preprocessed spectrum. In other words, by evaluating the impact of the smoothing filtering results of all preprocessed spectra of the tea sample on the tea quality detection results, different weights are assigned to all preprocessed spectra in the subsequent weighted averaging process, thereby improving the accuracy of the tea sample quality detection. The specific process is as follows:
[0075] First, this embodiment determines the smoothing characteristic value of each spectral peak in each preprocessed spectrum based on the difference in spectral intensity between the neighborhood of each spectral peak in each preprocessed spectrum and its corresponding band in the initial spectrum. Specifically:
[0076] In this embodiment, the spectral angle between the neighborhood of each spectral peak in each preprocessed spectrum and the corresponding wavelength in the initial spectrum of all spectral intensities is used as the smoothing feature value of each spectral peak in each preprocessed spectrum. To facilitate understanding of the calculation of the spectral angle, a more detailed explanation is provided: all spectral intensities in the neighborhood of each spectral peak in each preprocessed spectrum are arranged in ascending order of wavelength to form a preprocessed spectral intensity vector. Similarly, all spectral intensities in the neighborhood of each spectral peak in each preprocessed spectrum within the corresponding wavelength segment in the initial spectrum are arranged in ascending order of wavelength to form an initial spectral intensity vector. The spectral angle between the preprocessed spectral intensity vector and the initial spectral intensity vector is used as the smoothing feature value of each spectral peak in each preprocessed spectrum.
[0077] The method for calculating the spectral angle is a well-known technique, and its specific calculation process will not be elaborated here.
[0078] Based on the smoothing feature value of each spectral peak in each preprocessed spectrum, it can be understood that the smoothing feature is used to evaluate the degree of loss of the initial spectrum of the spectral peak after smoothing filtering preprocessing. If the spectral angle of the current spectral peak is larger, that is, the smoothing feature value is larger, it indicates that the current smoothing process is excessive, resulting in severe distortion of the spectral peak shape. Conversely, if the spectral angle of the current spectral peak is smaller, that is, the smoothing feature value is smaller, it indicates that the current smoothing process is moderate, which can effectively remove noise while better preserving the shape and feature information of the original spectral peak. The spectral peak shape distortion is slight, the preprocessing result is more reliable, and it is beneficial to the accuracy of subsequent tea quality detection.
[0079] Furthermore, in this embodiment, based on the smoothing characteristic value of each spectral peak in each preprocessed spectrum, and combined with the fitting error when fitting all wavelengths and their spectral intensities in the neighborhood of each spectral peak, the loss characteristic value of each spectral peak in each preprocessed spectrum is determined, specifically as follows:
[0080] In this embodiment, all wavelengths within the neighborhood of each spectral peak in each preprocessed spectrum are used as independent variables in the fitting algorithm, and the spectral intensity at all wavelengths is used as the dependent variable in the fitting algorithm to obtain a fitting curve. The mean square error between the spectral intensity at all wavelengths within the neighborhood of each spectral peak and the corresponding fitting value on the fitting curve is used as the fitting error. The result of positively fusing the normalized value of the fitting error with the normalized value of the corresponding smooth feature value is used as the loss feature value of each spectral peak in each preprocessed spectrum.
[0081] It should be noted that there are many commonly used fitting algorithms. In this embodiment, a polynomial curve fitting algorithm based on the least squares method is used to fit all wavelengths and their spectral intensities in the neighborhood of the spectral peak. In practical applications, as other implementation methods, implementers may also use other fitting methods such as polynomial function fitting according to specific circumstances. This embodiment does not impose any special restrictions on the selection of fitting methods.
[0082] The least squares-based polynomial curve fitting algorithm and the mean square error calculation method are both well-known techniques. The specific process of fitting the wavelength and its spectral intensity using the least squares-based polynomial curve fitting algorithm and the specific calculation process of the mean square error will not be elaborated here.
[0083] It should be understood that positive fusion refers to combining two or more indicators through addition or multiplication to obtain a comprehensive indicator, thereby more comprehensively and accurately assessing a phenomenon or problem. This fusion method is not limited to simple arithmetic operations, but can also include more complex statistical models and analytical methods. Implementers can choose according to specific circumstances, and this embodiment does not impose any special restrictions.
[0084] Preferably, as a specific implementation method, this embodiment uses the result of multiplying the normalized value of the fitting error when fitting all wavelengths and their spectral intensities in the neighborhood of each spectral peak in each preprocessed spectrum with the normalized value of the corresponding smooth feature value as the loss feature value of each spectral peak in each preprocessed spectrum. In practical applications, as other implementation methods, implementers may also use other positive fusion methods such as addition according to specific circumstances. This embodiment does not impose any special restrictions.
[0085] Based on the loss characteristic values of each spectral peak in each preprocessed spectrum, it can be understood that the loss characteristic value reflects the degree of loss of the true spectral shape and feature information of the spectral peak during the smoothing process. It is used to characterize the deviation of the spectral peak from the original spectral peak after smoothing. Specifically, it includes the degree of distortion of the spectral peak shape, which is reflected by the smoothing characteristic value, and the degree of residual noise, which is reflected by the fitting error. If the smoothing characteristic value of the current spectral peak is larger, it means that the spectral peak after smoothing has lost more features compared with the corresponding spectral peak in the initial spectrum, which may affect the accurate judgment of the tea quality characteristics. The corresponding loss characteristic value is larger. At the same time, if the fitting error of the current spectral peak is larger, it means that the residual noise of the current spectral peak is higher after smoothing. Therefore, the corresponding loss characteristic value is larger, indicating that the smoothing process has not effectively removed noise. The true features of the current spectral peak may be masked by noise, leading to a decrease in the accuracy of subsequent tea quality detection results.
[0086] Conversely, the smaller the smoothing feature value of the current spectral peak, the less feature is lost by the smoothed spectral peak compared to the corresponding spectral peak in the initial spectrum. This means that the shape and key information of the original spectral peak are well preserved, which is beneficial for the accurate judgment of tea quality characteristics. The corresponding loss feature value is smaller. At the same time, the smaller the fitting error of the current spectral peak, the lower the residual degree of burr noise after smoothing. Therefore, the corresponding loss feature value is smaller, indicating that the smoothing process effectively removes noise without damaging features. The true features of the current spectral peak are clearly presented, thus ensuring the accuracy of subsequent tea quality detection results.
[0087] Furthermore, in this embodiment, based on the average distribution of the quality influence factors of all wavelengths in the neighborhood of each spectral peak in each preprocessed spectrum, and the loss characteristic value, a second influence coefficient is determined for each preprocessed spectrum. Specifically:
[0088] In this embodiment, the average of the product of the quality influence coefficient of each spectral peak in each preprocessed spectrum and the loss characteristic value is used as the second influence coefficient of each preprocessed spectrum.
[0089] Based on the second influence coefficient of each preprocessed spectrum, it can be understood that the second influence coefficient is used to evaluate the negative impact of the feature loss of the preprocessed spectrum compared to the initial spectrum on the tea quality detection results. If the quality influence coefficient of the spectral peak in the current preprocessed spectrum is larger, it indicates that the feature loss of the spectral peak is more serious, and the impact on the tea quality detection results is greater. The corresponding second influence coefficient will also be larger, which will reduce the weight of the current preprocessed spectrum to reduce the impact of the feature loss of the spectral peak on the tea quality detection results. At the same time, if the loss feature value of the spectral peak in the current preprocessed spectrum is larger, it indicates that the feature loss after the spectral peak smoothing is higher, and therefore the amplitude of the tea quality detection results is greater. The corresponding second influence coefficient will also be larger, which will reduce the weight of the current preprocessed spectrum to reduce the impact of the feature loss on the detection results.
[0090] Conversely, if the quality influence coefficient of the spectral peak in the current preprocessed spectrum is smaller, it indicates that the characteristic loss of the spectral peak is less, and the impact on the tea quality detection results is smaller. The corresponding second influence coefficient will also be smaller, which will increase the weight of the current preprocessed spectrum to make full use of its well-preserved characteristic information. At the same time, if the loss characteristic value of the spectral peak in the current preprocessed spectrum is smaller, it indicates that the characteristic loss after the spectral peak smoothing process is lower, and therefore the impact on the amplitude of the tea quality detection results is smaller. The corresponding second influence coefficient will also be smaller, which will increase the weight of the current preprocessed spectrum to enhance its contribution in the weighted average, thereby improving the accuracy and reliability of the final detection results.
[0091] Furthermore, by combining the first influence coefficient and the second influence coefficient, the weighting coefficient for each preprocessed spectrum is determined, specifically as follows:
[0092] In this embodiment, the reciprocal of the average of the normalized values of the first and second influence coefficients of each preprocessed spectrum is used as the weighting coefficient of each preprocessed spectrum.
[0093] Preferably, the schematic diagram of the weight coefficient extraction process provided in this embodiment is as follows: Figure 2 As shown.
[0094] Based on the weighting coefficient of each preprocessed spectrum, it can be understood that the weighting coefficient is used to characterize the importance of the preprocessed spectrum in the subsequent weighted average. If the first influence coefficient of the current preprocessed spectrum is larger, it indicates that the residual background drift has a greater negative impact on the quality detection results, and the reliability of the current preprocessed spectrum is lower. Therefore, the weighting coefficient of the current preprocessed spectrum is smaller. At the same time, if the second influence coefficient of the current preprocessed spectrum is larger, it indicates that the feature loss caused by the smoothing filter has a greater negative impact on the tea quality detection results, indicating that the reliability of the current preprocessed spectrum is lower. Therefore, the weighting coefficient of the current preprocessed spectrum is smaller.
[0095] Conversely, the smaller the first influence coefficient of the current preprocessed spectrum, the smaller the negative impact of residual background drift on the quality detection results, the better the background drift correction effect of the current preprocessed spectrum, and the higher its reliability. Therefore, the weight coefficient of the current preprocessed spectrum is larger. At the same time, the smaller the second influence coefficient of the current preprocessed spectrum, the smaller the negative impact of feature loss caused by smoothing filtering on the tea quality detection results, indicating that the current preprocessed spectrum effectively removes noise while retaining key features well, and has high reliability. Therefore, the weight coefficient of the current preprocessed spectrum is larger.
[0096] Thus, this embodiment effectively suppresses the interference of feature loss and residual background drift caused by smoothing processing on quality detection by quantitatively evaluating the smoothing feature value and loss feature value of each spectral peak in the preprocessed spectrum, constructing a second influence coefficient in combination with the quality influence factor, and then determining the weight coefficient of each preprocessed spectrum by combining the first influence coefficient. This improves the accuracy of tea quality detection.
[0097] Step S3: Based on all the preprocessed spectra of the tea sample to be tested and their weighting coefficients, determine the target spectrum of the tea sample to be tested, and evaluate the quality of the tea sample to be tested by combining it with the tea quality scoring model.
[0098] Based on the weighting coefficients obtained in step S2, and combined with all preprocessed spectra of the tea sample to be tested, the target spectrum of the tea sample is determined. Based on the target spectrum and combined with the tea quality scoring model, the quality of the tea sample to be tested is evaluated, specifically as follows:
[0099] In this embodiment, the product of the spectral intensity at each wavelength in each preprocessed spectrum of the tea sample to be tested and the normalized value of the corresponding weight coefficient is calculated and recorded as the weighted spectral intensity. The mean of the weighted spectral intensities at the same wavelength in all preprocessed spectra of the tea sample to be tested is taken as the spectral intensity at the corresponding wavelength in the target spectrum. By traversing all wavelengths, the target spectrum is obtained.
[0100] Furthermore, the target spectrum of the tea sample to be tested is used as the input to the tea quality scoring model obtained in step S1, and the tea quality score of the tea sample to be tested is finally output.
[0101] Thus, this embodiment, by comprehensively evaluating the impact of residual background drift and smoothing feature loss in the preprocessed spectrum on tea quality detection, constructs first and second influence coefficients and dynamically allocates the weight of each preprocessed spectrum accordingly, effectively suppressing the interference of noise and distortion on the detection results and significantly improving the accuracy of tea quality detection.
[0102] Based on the same inventive concept as the above method, this application embodiment also provides a rapid tea quality detection system, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps of any one of the above-described rapid tea quality detection methods.
[0103] It should be noted that the order of the embodiments described above is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments of this specification have been described above. Additionally, the processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired results. In some implementations, multitasking and parallel processing are possible or may be advantageous.
[0104] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.
[0105] The above description is only a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the principles of this application should be included within the protection scope of this application.
Claims
1. A rapid method for detecting tea quality, characterized in that, The method includes the following steps: The tea quality scoring model and the initial spectra of the tea sample under all measurements were obtained, and each initial spectrum was subjected to baseline correction and smoothing filtering to obtain each preprocessed spectrum of the tea sample. Based on the tea quality scoring model, the quality influence factor of each wavelength in each preprocessed spectrum is obtained; based on the average distribution of the quality influence factor and the average distribution of the spectral intensity at all wavelengths in the neighborhood of each spectral peak in each preprocessed spectrum, the first influence coefficient of each preprocessed spectrum is determined. Based on the differences in spectral intensities between the neighborhood of each spectral peak in each preprocessed spectrum and its corresponding band in the initial spectrum, the smoothing characteristic value of each spectral peak in each preprocessed spectrum is determined. Combined with the fitting error when fitting the spectral intensities at all wavelengths within the neighborhood of each spectral peak, the loss characteristic value of each spectral peak in each preprocessed spectrum is determined. Based on the average distribution of quality influence factors at all wavelengths within the neighborhood of each spectral peak in each preprocessed spectrum, and the loss characteristic value, the second influence coefficient of each preprocessed spectrum is determined. Combined with the first influence coefficient, the weighting coefficient of each preprocessed spectrum is determined. Based on all preprocessed spectra of the tea sample to be tested and their weighting coefficients, the target spectrum of the tea sample to be tested is determined, and the quality of the tea sample to be tested is evaluated by combining the tea quality scoring model. The method for determining the first influence coefficient of each preprocessed spectrum is as follows: Calculate the mean value of the quality influence factor and the mean value of the spectral intensity at all wavelengths in the neighborhood of each spectral peak in each preprocessed spectrum, and record them as the quality influence coefficient and spectral mean of each spectral peak, respectively. Calculate the product of the normalized value of the quality influence coefficient of each spectral peak and the spectral mean, and take the mean of the product of all spectral peaks in each preprocessed spectrum as the first influence coefficient of each preprocessed spectrum. The loss characteristic value of each spectral peak in each preprocessed spectrum is: the result of positively fusing the normalized value of the fitting error and the normalized value of the corresponding smooth characteristic value when fitting the spectral intensity of each spectral peak in the neighborhood of all wavelengths in each preprocessed spectrum. The method for determining the second influence coefficient of each preprocessed spectrum is as follows: Calculate the product of the quality influence coefficient of each spectral peak in each preprocessed spectrum and the loss characteristic value, and take the mean of the product of all spectral peaks in each preprocessed spectrum as the second influence coefficient of each preprocessed spectrum. The weighting coefficient for each preprocessed spectrum is the reciprocal of the average of the normalized values of the first and second influence coefficients of each preprocessed spectrum.
2. The rapid detection method for tea quality as described in claim 1, characterized in that, The method for obtaining the quality influence factor of each wavelength in each preprocessed spectrum is as follows: The independent variable in the tea quality scoring model is the spectral intensity at each wavelength, and the dependent variable is the tea quality score. The coefficients before all independent variables in the tea quality scoring model are used as the quality influence factors for the corresponding wavelengths. The quality influence factors for each wavelength in each preprocessed spectrum in the tea quality scoring model are obtained.
3. The rapid detection method for tea quality as described in claim 1, characterized in that, The smoothing characteristic value of each spectral peak in each preprocessed spectrum is the spectral angle of all spectral intensities between the neighborhood of each spectral peak in the preprocessed spectrum and its corresponding band in the initial spectrum.
4. The rapid detection method for tea quality as described in claim 1, characterized in that, The method for determining the target spectrum of the tea sample to be tested is as follows: The product of the spectral intensity at each wavelength in each preprocessed spectrum of the tea sample to be tested and the normalized value of the corresponding weighting coefficient is calculated and denoted as the weighted spectral intensity. The mean of the weighted spectral intensities at the same wavelength in all preprocessed spectra of the tea sample to be tested is taken as the spectral intensity at the corresponding wavelength in the target spectrum. The target spectrum is obtained by traversing all wavelengths.
5. The rapid detection method for tea quality as described in claim 1, characterized in that, The evaluation of the quality of the tea samples to be tested includes: The target spectrum of the tea sample to be tested is used as the input to the tea quality scoring model, and the tea quality score of the tea sample to be tested is output.
6. A rapid tea quality detection system, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the rapid detection method for tea quality as described in any one of claims 1-5.