A method and system for rapid detection of food synthetic pigments
By identifying inflection points and segmenting spectral segments during spectral detection, extracting extreme light intensity points and generating characteristic parameters, and combining regional clustering to calculate spectral perturbation factors, the original spectral data is weighted and reconstructed. This solves the problem of complex matrix interference in the detection of synthetic pigments in food, and improves the accuracy and efficiency of detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SUZHOU YAKEWANDE TESTING TECHNOLOGY CO LTD
- Filing Date
- 2026-03-02
- Publication Date
- 2026-05-29
AI Technical Summary
In the detection of synthetic pigments in food, the background interference caused by complex matrices in existing technologies seriously affects the specificity and sensitivity of spectral matching, especially for the identification and quantification of low-concentration pigments or mixed pigments.
By identifying inflection points on the spectral curve, segmenting spectral segments and calculating the cumulative slope, extracting the extreme light intensity points of key spectral regions, generating sequence structure feature parameters, calculating the spectral perturbation factor in conjunction with regional clustering, weighted reconstruction of the original spectral data, forming a corrected spectral curve, and matching it with a standard spectral database.
It achieves dynamic and adaptive positioning of key spectral regions, effectively filters background interference, improves the specificity of spectral matching and the ability to distinguish mixed systems, and enhances the reliability and accuracy of detection.
Smart Images

Figure CN122108975A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of food spectral detection technology, specifically a rapid detection method and system for synthetic pigments in food. Background Technology
[0002] Currently, the detection of synthetic pigments in food widely employs spectroscopic analysis. A common technique involves directly acquiring the full-wavelength spectrum of the sample and comparing it with a spectral library of standard pigments across the entire spectrum or selected characteristic bands. This method assumes that the entire spectral range or artificially fixed bands have equal diagnostic value. However, the complex matrix of food and the presence of coexisting substances in the sample can cause background absorption and scattering interference, leading to baseline drift, characteristic peak distortion, or overlapping spurious peaks. When matching across the entire spectrum, these interference signals from non-target substances severely reduce the specificity and sensitivity of feature matching, making the identification and quantification of low-concentration pigments or mixed pigments inaccurate.
[0003] To reduce background interference, existing technologies often employ preprocessing methods such as derivative spectroscopy, multivariate scattering correction, or standard normal transformation. While these methods can partially eliminate baseline effects, they essentially perform global mathematical transformations on the entire spectral curve, failing to distinguish which regions of the spectrum's information originate from the true characteristics of the target pigment and which are random noise or non-specific background disturbances. They lack the ability to adapt to the spectral morphology of specific samples and cannot dynamically focus on the most discriminative spectral segments under complex interference. Even after preprocessing, they may still retain a large amount of irrelevant information or weaken key features. Therefore, intelligently extracting feature regions strongly correlated with the target pigment from complex and variable spectral curves and accurately correcting for spectral perturbations inherent to the sample itself is a key challenge for improving the reliability of rapid on-site detection. Summary of the Invention
[0004] This invention aims to solve at least one of the technical problems existing in the prior art;
[0005] Therefore, this invention proposes a rapid detection method for synthetic food pigments, comprising:
[0006] Obtain the raw spectral data of the solution to be tested;
[0007] Based on the changes in light intensity in the original spectral data, identify and mark all inflection points on the spectral curve;
[0008] The original spectral data is divided into multiple spectral segments based on the inflection point position, and the cumulative slope of each spectral segment is calculated.
[0009] All spectral segments are classified according to the slope accumulation, and the set of spectral segments whose slope accumulation exceeds a preset threshold after classification is defined as the key spectral region.
[0010] Extract the extreme light intensity points in the key spectral regions and construct a sequence of extreme light intensity points;
[0011] Analyze the intensity variation amplitude and wavelength interval between adjacent points in the light intensity extreme point sequence to generate sequence structure characteristic parameters;
[0012] The regional clustering degree is calculated based on the distribution density of the key spectral regions in the original spectral data;
[0013] By combining the sequence structure characteristic parameters with the regional clustering degree, the spectral perturbation factor is obtained;
[0014] The original spectral data is weighted and reconstructed using the spectral perturbation factor to form a corrected spectral curve;
[0015] The corrected spectral curve is compared point by point with a preset pigment standard spectral database, and the type and concentration information of synthetic pigments in the food are determined based on the matching results.
[0016] Preferably, the method for identifying and marking the inflection point position is as follows:
[0017] The light intensity value sequence in the original spectral data is smoothed by filtering to obtain a smoothed spectral curve;
[0018] Calculate the first derivative value of the smoothed spectral curve at each data point to generate a first derivative sequence;
[0019] Traverse the sequence of first derivatives, locate all points where the first derivative value changes from positive to negative or from negative to positive, and record these points as potential inflection points.
[0020] Calculate the variance of the first derivative value in the neighborhood of each potential inflection point. If the variance is greater than a set variance threshold, the potential inflection point is confirmed as a valid inflection point, and its corresponding wavelength coordinates are recorded.
[0021] Preferably, the method for calculating the cumulative slope of the spectral segment is as follows:
[0022] For a spectral segment defined by two adjacent inflection points, obtain all continuous data points within the spectral segment;
[0023] Calculate the ratio of the light intensity difference between each pair of consecutive data points to its corresponding wavelength difference to obtain the local slope between each pair of consecutive data points;
[0024] The summation of the absolute values of the local slopes of all consecutive data point pairs within the spectral segment is the cumulative slope of the spectral segment.
[0025] Preferably, the method for determining the key spectral region is as follows:
[0026] Sort all spectral segments from highest to lowest according to their corresponding slope accumulation values;
[0027] Select the spectral fragments that rank high from the sorted spectral fragment sequence and whose sum of slope accumulation reaches a certain proportion of the total accumulation.
[0028] Check the continuity of the selected spectral segments on the wavelength axis. If there is a wavelength gap smaller than the set gap threshold, merge the spectral segments on both sides of the gap.
[0029] The final set of spectral fragments is defined as the key spectral region, and its start and end wavelength positions are recorded.
[0030] Preferably, the method for generating the sequence structure feature parameters is as follows:
[0031] Extract each pair of adjacent extreme points sequentially from the sequence of extreme light intensity points;
[0032] For each pair of adjacent extreme points, the absolute difference between the light intensity values between them is calculated as the light intensity transition amount of each pair of adjacent extreme points.
[0033] Calculate the absolute value of the wavelength difference between each pair of adjacent extreme points, and use it as the wavelength span between the adjacent extreme points;
[0034] The average and variance of the light intensity transitions of all point pairs in the entire light intensity extreme point sequence are statistically analyzed and used as the light intensity transition characteristics.
[0035] The average and variance of the wavelength span of all point pairs in the entire sequence of extreme light intensity points are statistically analyzed and used as the wavelength span characteristic.
[0036] The light intensity transition characteristics and wavelength span characteristics are combined to form the sequence structure characteristic parameters.
[0037] Preferably, the method for calculating the regional clustering degree is as follows:
[0038] Obtain the starting and ending wavelength positions for all key spectral regions;
[0039] Calculate the distance between the center points of every two distinct key spectral regions on the wavelength axis;
[0040] The reciprocal of the distance between each pair of key spectral regions is calculated, and all reciprocals are summed to obtain the initial aggregation index.
[0041] The total number of key spectral regions is counted, and the initial clustering index is multiplied by the total number of key spectral regions to obtain the normalized regional clustering.
[0042] Preferably, the method for obtaining the spectral perturbation factor is as follows:
[0043] Extract the variance of the light intensity transition and the average value of the wavelength span from the sequence structure feature parameters;
[0044] The primary perturbation coefficient is obtained by multiplying the variance of the light intensity transition by the average value of the wavelength span.
[0045] The aggregation degree of the region is multiplied by a preset adjustment factor to obtain the aggregation degree contribution value;
[0046] The primary perturbation coefficient is added to the aggregation contribution value, and the sum is then mapped by a preset standardization function to finally output the spectral perturbation factor.
[0047] Preferably, the method for forming the corrected spectral curve is as follows:
[0048] The spectral perturbation factor is used as the global adjustment weight;
[0049] The light intensity value corresponding to each wavelength point in the original spectral data is multiplied by the global adjustment weight to obtain the weighted light intensity value of the wavelength point;
[0050] Connect all wavelength points and their corresponding weighted light intensity values in wavelength order to form the corrected spectral curve.
[0051] Preferably, the method for performing point-by-point matching and comparison between the corrected spectral curve and a preset pigment standard spectral database is as follows:
[0052] Retrieve the standard spectral curve of each synthetic pigment from the pigment standard spectral database;
[0053] Align the corrected spectral curve with each standard spectral curve at the same wavelength point;
[0054] Calculate the sum of squares of the differences in light intensity values at corresponding wavelengths between the corrected spectral curve and each standard spectral curve.
[0055] The synthetic pigment species corresponding to the standard spectral curve with the smallest sum of squared differences were selected as the preliminary determination result;
[0056] Based on the overall intensity ratio between the corrected spectral curve and the standard spectral curve corresponding to the preliminary judgment result, the concentration of the synthetic pigment corresponding to the preliminary judgment result in the test solution is calculated.
[0057] Preferably, the present invention also includes a rapid detection system for synthetic food colorings, the system including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the rapid detection method for synthetic food colorings described above.
[0058] Compared with the prior art, the beneficial effects of the present invention are:
[0059] Based on the automatic identification and segmentation of inflection points on spectral curves, and by classifying and thresholding based on the cumulative slope of each spectral segment, this method achieves dynamic and adaptive localization of key spectral regions. This technology can automatically identify segments with drastic signal changes that may contain pigment characteristic fingerprints from the full-spectrum information, while effectively filtering out stable background interference caused by the food matrix. This allows the analysis target to focus on information-dense feature regions, reducing the complexity of subsequent data processing while improving the specificity of spectral matching and the ability to distinguish mixed systems.
[0060] By extracting the extreme light intensity sequence of key spectral regions, analyzing their structural characteristic parameters, and calculating the regional aggregation degree in conjunction with the distribution density of key regions, a spectral perturbation factor characterizing sample-specific interference is generated. This factor is then used to reconstruct a weighted spectrum of the original spectrum, resulting in a customized corrected spectral curve. This process essentially constructs an adaptive data optimization model based on the sample's own spectral morphology. It can specifically correct baseline drift and characteristic peak distortion caused by the complex matrix of the sample, suppress non-specific perturbations, and thus output high-quality data that more closely approximates the intrinsic spectrum of the target pigment, laying a reliable foundation for subsequent accurate matching. Attached Figure Description
[0061] Figure 1 This is a flowchart illustrating the steps of the rapid detection method for synthetic food pigments described in this invention.
[0062] Figure 2 A flowchart showing the method for calculating the cumulative slope of a spectral segment;
[0063] Figure 3 A flowchart of a method for generating sequence structure feature parameters;
[0064] Figure 4 A bar chart comparing the intensity at key wavelengths;
[0065] Figure 5Grouped bar charts showing the distribution of key spectral regions in different wavelength areas. Detailed Implementation
[0066] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0067] This method analyzes the raw spectral data of the test solution, and through a series of feature extraction and data processing steps, ultimately achieves rapid determination of the type and concentration of synthetic pigments. Please refer to [link / reference]. Figure 1 The overall implementation plan is as follows:
[0068] The raw spectral data of the solution to be tested is acquired, containing a series of wavelength points and their corresponding light intensity values. Based on the light intensity changes in the raw spectral data, all inflection points on the spectral curve are identified and marked. The raw spectral data is segmented into multiple spectral segments based on these inflection points, and the cumulative slope of each segment is calculated. All spectral segments are classified according to the cumulative slope, and the set of spectral segments with a cumulative slope exceeding a preset threshold after classification is defined as key spectral regions. Extreme light intensity points are extracted from the key spectral regions to construct a sequence of extreme light intensity points. The magnitude of light intensity changes and wavelength intervals between adjacent points in this sequence are analyzed to generate sequence structure feature parameters. The regional clustering degree is calculated based on the distribution density of the key spectral regions in the raw spectral data. The spectral perturbation factor is obtained by combining the sequence structure feature parameters and the regional clustering degree. The raw spectral data is weighted and reconstructed using the spectral perturbation factor to form a corrected spectral curve. The corrected spectral curve is compared point-by-point with a preset pigment standard spectral database, and the type and concentration information of synthetic pigments in the food are determined based on the matching results.
[0069] In one embodiment of the present invention, see [reference] Figure 2The light intensity value sequence in the original spectral data is smoothed by filtering to obtain a smoothed spectral curve. The first derivative value of the smoothed spectral curve at each data point is calculated, generating a first derivative sequence. The first derivative sequence is traversed to locate all points where the first derivative value changes from positive to negative or vice versa, and these points are recorded as potential inflection points. The variance of the first derivative value in the neighborhood of each potential inflection point is calculated. If the variance is greater than a set variance threshold, the potential inflection point is confirmed as a valid inflection point, and its corresponding wavelength coordinates are recorded. For a spectral segment defined by two adjacent valid inflection points, all continuous data points within that segment are obtained. The ratio of the light intensity difference between each pair of continuous data points to its corresponding wavelength difference is calculated to obtain the local slope between each pair of continuous data points. The absolute values of the local slopes of all pairs of continuous data points within the spectral segment are summed, and the sum is the cumulative slope of that spectral segment. All spectral segments are sorted from highest to lowest according to their corresponding cumulative slope values. From the sorted spectral fragment sequence, select the top-ranking spectral fragments whose sum of slope accumulations reaches a specific proportion of the total accumulation. Check the continuity of the selected spectral fragments on the wavelength axis; if there are wavelength gaps smaller than a set gap threshold, merge the spectral fragments on both sides of the gap. Define the final set of spectral fragments as the key spectral region and record its start and end wavelength positions.
[0070] In practice, this involves preprocessing the raw spectral data, feature segmentation, and key region extraction. Taking a test solution containing a mixture of tartrazine and sunset yellow pigments as an example, its raw spectral data consists of a sequence of light intensity values collected at fixed intervals within a wavelength range of 400 nm to 700 nm. The light intensity value sequence in the raw spectral data is smoothed using a smoothing filter, for example, the Savitzky-Golay convolution smoothing algorithm, to obtain a smoothed spectral curve. The smoothed spectral curve effectively suppresses high-frequency random noise. The first derivative value of the smoothed spectral curve at each data point is calculated, generating a first derivative sequence. This first derivative sequence reflects the rate of change of light intensity with wavelength. The first derivative sequence is traversed to locate all points where the first derivative value changes from positive to negative or from negative to positive. These points are recorded as potential inflection points, corresponding to wavelength positions where the concavity / convexity of the spectral curve changes. Calculate the variance of the first derivative value in the neighborhood of each potential inflection point. If the variance is greater than the set variance threshold, the potential inflection point is confirmed as a valid inflection point, and its corresponding wavelength coordinates are recorded. This step can eliminate false inflection points caused by small fluctuations.
[0071] In some embodiments, for a spectral segment defined by two adjacent effective inflection points, all consecutive data points within the spectral segment are acquired. The ratio of the light intensity difference between each pair of consecutive data points to its corresponding wavelength difference is calculated to obtain the local slope between each pair of consecutive data points. The absolute values of the local slopes of all pairs of consecutive data points within the spectral segment are summed, and the summation result is the cumulative slope of the spectral segment. The cumulative slope S can be calculated using the following formula:
[0072] ;
[0073] in: and They represent wavelengths respectively. and The corresponding light intensity value at that location; and This is an index for the start and end data points of a spectral segment. A steep and complex spectral segment will have a high cumulative slope.
[0074] It's understandable that after obtaining the cumulative slope of all spectral segments, all spectral segments are sorted from highest to lowest according to their corresponding cumulative slope values. From the sorted sequence, the top-ranked spectral segments whose sum of cumulative slope values reaches a specific proportion of the total cumulative slope value are selected; for example, segments whose cumulative contribution reaches 80% of the total cumulative slope value. The continuity of the selected spectral segments along the wavelength axis is checked. If there is a wavelength gap smaller than a set gap threshold, the spectral segments on both sides of the gap are merged. The final set of spectral segments is defined as a key spectral region, and its start and end wavelength positions are recorded. In the example scenario, the original spectrum may have two spectral segments with high cumulative slope values near 510 nm and 480 nm. If the wavelength gap between the two segments is smaller than the set gap threshold, they are merged into a continuous key spectral region from 475 nm to 525 nm.
[0075] Optionally, the window size and polynomial order of the smoothing filter can be adjusted according to the noise level of the original spectral data. In some embodiments, the calculation of the first derivative can be performed using the central difference method to improve accuracy. The set variance threshold and wavelength gap threshold can be pre-calibrated and optimized by analyzing a large amount of spectral data of known pure pigments.
[0076] It is understandable that by implementing the above steps, key regions with drastic spectral changes can be objectively identified from the original spectral data. The calculation and sorting of slope accumulation provides a quantitative basis for subsequent focusing on information-rich spectral segments, while the merging of spectral segments ensures the physical integrity of the extracted key spectral regions.
[0077] In one embodiment of the present invention, see [reference] Figure 3 From the sequence of extreme light intensity points, each pair of adjacent extreme points is extracted sequentially. For each pair of adjacent extreme points, the absolute difference in light intensity values between them is calculated as the light intensity transition. The absolute value of the wavelength difference between each pair of adjacent extreme points is calculated as the wavelength span. The average and variance of the light intensity transitions of all point pairs in the entire sequence of extreme light intensity points are calculated as the light intensity transition feature. The average and variance of the wavelength spans of all point pairs in the entire sequence of extreme light intensity points are calculated as the wavelength span feature. The light intensity transition feature and the wavelength span feature are combined to form the sequence structure feature parameters. The starting and ending wavelength positions of all key spectral regions are obtained. The distance between the center points of every two different key spectral regions on the wavelength axis is calculated. The reciprocal of the distances between all pairs of key spectral regions is taken, and all reciprocals are summed to obtain the initial clustering index. The total number of key spectral regions is counted, and the initial clustering index is multiplied by the total number of key spectral regions to obtain the normalized regional clustering.
[0078] In practice, this involves further quantifying the internal structure and distribution characteristics of the extracted key spectral regions. Based on multiple key spectral regions obtained from the examples, extreme light intensity points are extracted from each key spectral region. All extreme light intensity points are arranged in order of their wavelengths to form an extreme light intensity point sequence. Taking a test solution containing carmine pigment as an example, five extreme light intensity points may be extracted in the key spectral region from 490 nm to 530 nm. The wavelength coordinates of the extreme light intensity point sequence are as follows: The corresponding light intensity value is .
[0079] Each pair of adjacent extreme points is extracted sequentially from the sequence of extreme light intensity points. For each pair of adjacent extreme points, the absolute difference in light intensity values between them is calculated as the light intensity transition amount. The absolute value of the wavelength difference between each pair of adjacent extreme points is calculated as the wavelength span. The average and variance of the light intensity transition amounts of all pairs of points in the entire sequence of extreme light intensity points are calculated as the light intensity transition feature. The average and variance of the wavelength span of all pairs of points in the entire sequence of extreme light intensity points are calculated as the wavelength span feature. The light intensity transition feature and the wavelength span feature together constitute the sequence structure feature parameters.
[0080] In some embodiments, the start and end wavelength positions of all key spectral regions are obtained. Assuming there are three key spectral regions with start and end wavelength positions of [missing information], respectively... , , Calculate the distance between the center points of every two distinct key spectral regions on the wavelength axis. Take the reciprocal of the distances between all pairwise key spectral regions and sum all the reciprocals to obtain an initial clustering index. Count the total number of key spectral regions. Multiply the initial clustering index by the total number of key spectral regions to obtain the normalized region clustering. (Center point distance) The calculation formula is:
[0081] ;
[0082] in: and Representing the key spectral regions The start and end wavelengths, and Representing the key spectral regions The starting and ending wavelengths.
[0083] It is understandable that sequence structure characteristic parameters reflect the intensity of signal fluctuations and the density of fluctuation point distribution within key spectral regions, while regional clustering characterizes the degree of concentration of multiple key spectral regions along the wavelength dimension. Optionally, the extraction of extreme light intensity points can be achieved by finding points in the key spectral regions where the first derivative of the spectral curve is zero and the second derivative is not zero. The statistical calculation of light intensity transitions and wavelength spans can be performed using standard arithmetic mean and unbiased variance estimation algorithms.
[0084] In other embodiments, when calculating the distance between center points, wavelength coordinates must use a uniform physical unit. The calculation of the initial aggregation index reflects the inverse relationship between the distances between regions, meaning that the closer the regions are to each other, the greater their contribution to the aggregation. It can be understood that the sequence structure feature parameters and the regional aggregation together provide quantitative input for the subsequent calculation of the spectral perturbation factor, and their combination provides a multi-dimensional description of the differences in the spectral fingerprints of different pigments.
[0085] In one embodiment of the present invention, the variance of the light intensity transition and the average value of the wavelength span are extracted from the sequence structure feature parameters. The variance of the light intensity transition and the average value of the wavelength span are multiplied to obtain the primary perturbation coefficient. The regional clustering degree is multiplied by a preset adjustment factor to obtain the clustering contribution value. The primary perturbation coefficient and the clustering contribution value are added together, and the sum is then mapped through a preset normalization function to finally output the spectral perturbation factor.
[0086] In practice, this involves calculating a spectral perturbation factor by combining sequence structural characteristic parameters and regional aggregation degree. The variance of light intensity transitions and the average wavelength span are extracted from the sequence structural characteristic parameters. The calculation of the spectral perturbation factor is based on the sequence structural characteristic parameters obtained by analyzing the sequence of extreme light intensity points within key spectral regions, and the regional aggregation degree calculated by evaluating the compactness of the distribution of key spectral regions along the wavelength axis. Taking a test solution containing a bright blue pigment as an example, assuming the variance of light intensity transitions in its sequence structural characteristic parameters is σ², the average wavelength span is μ, the regional aggregation degree is C, and the preset adjustment factor is γ.
[0087] Multiplying the variance σ² of the light intensity transition by the average value μ of the wavelength span yields the primary perturbation coefficient P. The formula for calculating the primary perturbation coefficient P is as follows: ,in: The variance representing the intensity transition of light. The average value represents the wavelength span. The variance σ² of the intensity transition describes the dispersion of the intensity variation between adjacent extreme points in the key spectral region, while the average value μ of the wavelength span reflects the average size of the wavelength interval between these extreme points. The primary perturbation coefficient P obtained by multiplying the two values integrates the influence of the fluctuation of the signal amplitude and the distribution density of the variation points.
[0088] Multiplying the regional clustering degree C by a preset adjustment factor γ yields the clustering contribution value A, i.e. The introduction of the aggregation contribution value A incorporates the overall compactness of the key spectral regions along the wavelength axis into the final calculation of the spectral perturbation factor. A preset adjustment factor γ is used to balance the relative weights of the influence of sequence structural features and regional distribution features on the final spectral perturbation factor. The value of the adjustment factor γ can be preset by analyzing standard sample spectral datasets.
[0089] The initial perturbation coefficient P is added to the clustering contribution value A, and the sum is then mapped through a predefined normalization function to finally output the spectral perturbation factor F. The normalization function can take the form of linear scaling or the sigmoid function, etc., and its purpose is to map the sum to a predetermined numerical range. For example, the value of the spectral perturbation factor F is constrained to be between 0 and 1 or between 1 and 10 to facilitate subsequent weighted calculations.
[0090] In some embodiments, the variance of the intensity transition and the average value of the wavelength span can be normalized separately before multiplication to eliminate the influence of different dimensions. The preset adjustment factor γ can be a fixed constant obtained through offline optimization, or it can be a variable dynamically adjusted according to the number of key spectral regions.
[0091] Optionally, the specific form and parameters of the standardized function mapping must be consistent to ensure the comparability of spectral perturbation factors calculated for different test solutions. The addition of the primary perturbation coefficients and the aggregation contribution value is a linear fusion method; in other implementations, weighted geometric averaging or other nonlinear fusion methods can also be used.
[0092] It is understandable that the numerical value of the spectral perturbation factor F comprehensively characterizes the complexity and clustering of the original spectral data in key feature regions. A test solution with dramatic and dense spectral fluctuations often yields a large spectral perturbation factor value. By introducing a standardized function mapping, the spectral perturbation factors calculated from spectral data obtained from different batches and under different instrument conditions can be normalized to a uniform scale, providing a consistent adjustment benchmark for subsequent weighted reconstruction steps.
[0093] In some embodiments, if the calculation method of the regional clustering degree C results in a large numerical range, it can be logarithmically transformed or linearly scaled before multiplying with the adjustment factor γ to prevent the clustering degree contribution value A from excessively dominating the final spectral perturbation factor. The cutoff point or saturation region setting of the normalization function mapping should avoid causing the vast majority of calculated F values to fall in insensitive regions, thereby ensuring the spectral perturbation factor's ability to distinguish spectral morphological differences.
[0094] In one embodiment of the present invention, a spectral perturbation factor is used as a global adjustment weight. The light intensity value corresponding to each wavelength point in the original spectral data is multiplied by the global adjustment weight to obtain the weighted light intensity value for that wavelength point. All wavelength points and their corresponding weighted light intensity values are connected in wavelength order to form a corrected spectral curve.
[0095] In practice, this involves using a spectral perturbation factor to weighted reconstruct the original spectral data to form a corrected spectral curve. Taking a test solution containing allura red pigment as an example, assuming the spectral perturbation factor calculated through the aforementioned steps is 2.5, this spectral perturbation factor, as a global adjustment weight, means that the light intensity values of the entire original spectral data will be scaled according to a uniform scaling factor. The light intensity value corresponding to each wavelength point in the original spectral data is multiplied by the global adjustment weight to obtain the weighted light intensity value at that wavelength point. The calculation formula is:
[0096] ;
[0097] in: Indicates the weighted light intensity value; This indicates that the spectral perturbation factor is used as a global adjustment weight; This represents the original light intensity value. For each wavelength point, the original light intensity value... With spectral perturbation factor Multiplying these values results in the weighted light intensity value for that wavelength. For example, the original light intensity value at a wavelength of 500 nanometers is 150.0 arbitrary units. After multiplying by the global adjustment weight of 2.5, the weighted light intensity value becomes 375.0 arbitrary units.
[0098] In some embodiments, the raw spectral data contains hundreds of wavelength points, each of which requires the multiplication operation described above. Referring to Table 1, a comparison of the raw light intensity values and weighted light intensity values for some example wavelength points is shown.
[0099] Table 1: Comparison of Original and Weighted Light Intensity Values at Example Wavelengths
[0100] It is understood that the data in the table is for illustrative purposes only, and the actual number and values of data points will vary depending on the specific detection conditions. Connecting all wavelength points and their corresponding weighted light intensity values in wavelength order forms a corrected spectral curve. The corrected spectral curve is similar in shape to the original spectral curve, but the overall light intensity value is proportionally amplified or reduced. The amplification or reduction ratio is determined by the spectral perturbation factor. Optionally, the spectral perturbation factor, as a global adjustment weight, is applied uniformly across the entire spectral range. If the spectral perturbation factor is less than 1, the overall intensity of the corrected spectral curve will be lower than the original spectral curve; if the spectral perturbation factor is greater than 1, the overall intensity of the corrected spectral curve will be higher than the original spectral curve. This global weighting operation does not change the relative peak and valley positions and shape contours of the spectral curve, but it changes the absolute intensity scale of the curve.
[0101] In some embodiments, the original spectral data may have undergone baseline correction or normalization preprocessing. In this case, the spectral perturbation factor, as a global adjustment weight, will be applied to the preprocessed data. The calculation of weighted light intensity values can be performed point-by-point in real time, or the entire spectral array can be processed in batches. It is understood that by implementing the above steps, the original spectral data is converted into a corrected spectral curve. The corrected spectral curve retains all the characteristic peaks and valleys of the original spectrum, but the overall intensity level is adjusted by the spectral perturbation factor. This adjustment helps reduce intensity deviations caused by differences in sample concentration, optical path, or instrument response when subsequently matching with a standard spectral database, making the matching process more focused on the similarity of spectral shapes. Optionally, the calculation of weighted light intensity values may involve floating-point operations, requiring ensuring calculation accuracy to avoid rounding errors. The global adjustment weight, i.e., the spectral perturbation factor, is derived from the calculation results of the embodiments, ensuring that the basis for weighted reconstruction is related to the complexity and clustering characteristics of the spectrum.
[0102] See Figure 4This is a bar chart comparing the intensity of key wavelengths, showing the contrast between the original and weighted intensity values at key wavelengths in the detection of synthetic food pigments. All orange bars (weighted values) are consistently 2.5 times the height of the blue bars (original values), indicating that the global weighting operation is uniform across the entire wavelength range, without altering the relative peak-valley shapes of the spectrum, only changing the absolute intensity. The purpose of this global weighting correction is to eliminate intensity deviations caused by differences in sample concentration, optical path length, or instrument response, allowing subsequent matching with the standard spectral library to focus more on the similarity of spectral shapes, thereby improving the accuracy of pigment type and concentration determination.
[0103] In one embodiment of the present invention, standard spectral curves for each synthetic pigment are retrieved from a pigment standard spectral database. The corrected spectral curve is aligned with each standard spectral curve at the same wavelength point. The sum of squares of the differences in light intensity values between the corrected spectral curve and each standard spectral curve at the corresponding wavelength point is calculated. The synthetic pigment type corresponding to the standard spectral curve with the smallest sum of squares is selected as the preliminary determination result. Based on the overall intensity ratio between the corrected spectral curve and the standard spectral curve corresponding to the preliminary determination result, the concentration of the synthetic pigment corresponding to the preliminary determination result in the test solution is calculated.
[0104] In practice, this involves matching and comparing the corrected spectral curve with a pre-set pigment standard spectral database to determine the type and concentration. Taking a test solution suspected of containing tartrazine as an example, its corrected spectral curve has been obtained through the steps of the example. The standard spectral curve of each synthetic pigment is retrieved from the pigment standard spectral database. The pigment standard spectral database pre-stores standard spectral data of various permitted food synthetic pigments at specific concentrations, such as tartrazine, carmine, sunset yellow, and brilliant blue. Each standard spectral curve contains a sequence of standard light intensity values at sampling points with the same wavelength as the spectrum to be tested.
[0105] Align the corrected spectral curve with each standard spectral curve at the same wavelength point. Wavelength alignment ensures that the two curves are compared at data points located at the same physical wavelength. If the sampling intervals are different, the standard spectral curve needs to be interpolated and resampled to match the wavelength coordinates of the corrected spectral curve. Calculate the sum of squares of the differences in light intensity values between the corrected spectral curve and each standard spectral curve at the corresponding wavelength point. The calculation formula is: ,in: This represents the total number of wavelength points. This indicates the corrected spectral curve at wavelength The light intensity value at that location, This indicates that a certain standard spectral curve is at a wavelength The standard light intensity value at that location. The above calculation was performed on the standard spectral curve of each pigment in the database, yielding a series of sum-of-squares differences.
[0106] The synthetic pigment species corresponding to the standard spectral curve with the smallest sum of squared differences is selected as the preliminary judgment result. For example, if the calculation result shows that the sum of squared differences with the "tartrazine" standard spectral curve is the smallest, then it is preliminarily determined that the test solution contains tartrazine. Based on the overall intensity ratio between the corrected spectral curve and the standard spectral curve corresponding to the preliminary judgment result, the concentration of the synthetic pigment corresponding to the preliminary judgment result in the test solution is calculated. The overall intensity ratio can be obtained by calculating the average ratio or area ratio of the light intensity values of the two curves at all wavelengths. Knowing the reference concentration corresponding to the standard spectral curve, multiplying the reference concentration by this overall intensity ratio can estimate the actual concentration in the test solution.
[0107] In some embodiments, the standard spectral curves in the pigment standard spectral database should be stored after being measured and validated using known pure pigments at a series of concentrations on a spectrometer consistent with the measurement conditions of the test solution. The calculation of the sum of squares of the differences covers the entire detection wavelength range, for example, 400 nm to 700 nm.
[0108] Optionally, the wavelength alignment process needs to consider the calibration of instrument wavelength drift. Wavelength correction can be performed using the built-in standard lamp spectrum to ensure alignment accuracy. The calculation of the overall intensity ratio can employ robust statistical methods, such as taking the median of the intensity ratios at multiple characteristic absorption peaks, to reduce the influence of random noise or baseline residue.
[0109] It is understandable that by calculating the sum of squared differences point by point, the overall shape difference between the measured spectrum and each standard spectrum can be quantitatively assessed, with the minimum value corresponding to the most similar standard substance. The concentration calculation is based on the linear relationship assumption of the Lambert-Beer law, that is, within a certain concentration range, the light absorption intensity of the solution is proportional to the pigment concentration, so the overall intensity ratio directly reflects the concentration ratio.
[0110] In some embodiments, to prevent misjudgment due to the presence of pigments not included in the database or severe interference in the test solution, an absolute threshold for the sum of squared differences can be set. If all sums of squared differences are greater than this threshold, the solution is judged as "unmatched" or "may contain unknown pigments". The calculation of the overall intensity ratio can also be performed in the key spectral region to further improve the anti-interference capability.
[0111] It is understandable that after the perturbation factor weighting of the modified spectral curve in the aforementioned steps, its overall intensity scale has been adjusted. This makes the intensity ratio calculation with respect to the standard spectral curve more focused on the systematic scaling caused by concentration differences, rather than the local intensity fluctuations caused by the complexity and noise of the original spectrum, thereby improving the stability and reliability of concentration estimation.
[0112] See Figure 5 This is a grouped bar chart showing the distribution of key spectral regions across different wavelengths. It clearly presents the distribution characteristics of "regional importance" and "peak intensity" in different wavelength regions during the detection of synthetic food pigments. Overall, wavelengths with high "regional importance" also have relatively high "peak intensity," which aligns with the principle in spectral analysis that "the higher the signal intensity, the more effective information it contains." From 400nm to 700nm, both "regional importance" and "peak intensity" show a trend of first increasing and then decreasing, reaching a peak at 451–500nm, indicating that the characteristic absorption of the pigment is mainly concentrated in this range. This chart can help you quickly identify key spectral regions in subsequent detection processes and prioritize in-depth analysis of data from these regions, thereby improving detection efficiency and accuracy.
[0113] The above embodiments are only used to illustrate the technical methods of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical methods of the present invention without departing from the spirit and scope of the technical methods of the present invention.
Claims
1. A rapid detection method for synthetic food colorings, characterized in that, The method includes: Obtain the raw spectral data of the solution to be tested; Based on the changes in light intensity in the original spectral data, identify and mark all inflection points on the spectral curve; The original spectral data is divided into multiple spectral segments based on the inflection point position, and the cumulative slope of each spectral segment is calculated. All spectral segments are classified according to the slope accumulation, and the set of spectral segments whose slope accumulation exceeds a preset threshold after classification is defined as the key spectral region. Extract the extreme light intensity points in the key spectral regions and construct a sequence of extreme light intensity points; Analyze the intensity variation amplitude and wavelength interval between adjacent points in the light intensity extreme point sequence to generate sequence structure characteristic parameters; The regional clustering degree is calculated based on the distribution density of the key spectral regions in the original spectral data; By combining the sequence structure characteristic parameters with the regional clustering degree, the spectral perturbation factor is obtained; The original spectral data is weighted and reconstructed using the spectral perturbation factor to form a corrected spectral curve; The corrected spectral curve is compared point by point with a preset pigment standard spectral database, and the type and concentration information of synthetic pigments in the food are determined based on the matching results.
2. The rapid detection method for synthetic food pigments as described in claim 1, characterized in that, The method for identifying and marking the inflection point is as follows: The light intensity value sequence in the original spectral data is smoothed by filtering to obtain a smoothed spectral curve; Calculate the first derivative value of the smoothed spectral curve at each data point to generate a first derivative sequence; Traverse the sequence of first derivatives, locate all points where the first derivative value changes from positive to negative or from negative to positive, and record these points as potential inflection points. Calculate the variance of the first derivative value in the neighborhood of each potential inflection point. If the variance is greater than a set variance threshold, the potential inflection point is confirmed as a valid inflection point, and its corresponding wavelength coordinates are recorded.
3. The rapid detection method for synthetic food pigments as described in claim 1, characterized in that, The method for calculating the cumulative slope of the spectral segment is as follows: For a spectral segment defined by two adjacent inflection points, obtain all continuous data points within the spectral segment; Calculate the ratio of the light intensity difference between each pair of consecutive data points to its corresponding wavelength difference to obtain the local slope between each pair of consecutive data points; The summation of the absolute values of the local slopes of all consecutive data point pairs within the spectral segment is the cumulative slope of the spectral segment.
4. The rapid detection method for synthetic food pigments as described in claim 1, characterized in that, The method for determining the key spectral region is as follows: Sort all spectral segments from highest to lowest according to their corresponding slope accumulation values; Select the spectral fragments that rank high from the sorted spectral fragment sequence and whose sum of slope accumulation reaches a certain proportion of the total accumulation. Check the continuity of the selected spectral segments on the wavelength axis. If there is a wavelength gap smaller than the set gap threshold, merge the spectral segments on both sides of the gap. The final set of spectral fragments is defined as the key spectral region, and its start and end wavelength positions are recorded.
5. The rapid detection method for synthetic food pigments as described in claim 1, characterized in that, The method for generating the sequence structure feature parameters is as follows: Extract each pair of adjacent extreme points sequentially from the sequence of extreme light intensity points; For each pair of adjacent extreme points, the absolute difference between the light intensity values between them is calculated as the light intensity transition amount of each pair of adjacent extreme points. Calculate the absolute value of the wavelength difference between each pair of adjacent extreme points, and use it as the wavelength span between the adjacent extreme points; The average and variance of the light intensity transitions of all point pairs in the entire light intensity extreme point sequence are statistically analyzed and used as the light intensity transition characteristics. The average and variance of the wavelength span of all point pairs in the entire sequence of extreme light intensity points are statistically analyzed and used as the wavelength span characteristic. The light intensity transition characteristics and wavelength span characteristics are combined to form the sequence structure characteristic parameters.
6. The rapid detection method for synthetic food pigments as described in claim 1, characterized in that, The method for calculating the regional clustering degree is as follows: Obtain the starting and ending wavelength positions for all key spectral regions; Calculate the distance between the center points of every two distinct key spectral regions on the wavelength axis; The reciprocal of the distance between each pair of key spectral regions is calculated, and all reciprocals are summed to obtain the initial aggregation index. The total number of key spectral regions is counted, and the initial clustering index is multiplied by the total number of key spectral regions to obtain the normalized regional clustering.
7. The rapid detection method for synthetic food pigments as described in claim 1, characterized in that, The method for obtaining the spectral perturbation factor is as follows: Extract the variance of the light intensity transition and the average value of the wavelength span from the sequence structure feature parameters; The primary perturbation coefficient is obtained by multiplying the variance of the light intensity transition by the average value of the wavelength span. The aggregation degree of the region is multiplied by a preset adjustment factor to obtain the aggregation degree contribution value; The primary perturbation coefficient is added to the aggregation contribution value, and the sum is then mapped by a preset standardization function to finally output the spectral perturbation factor.
8. The rapid detection method for synthetic food pigments as described in claim 1, characterized in that, The method for forming the corrected spectral curve is as follows: The spectral perturbation factor is used as the global adjustment weight; The light intensity value corresponding to each wavelength point in the original spectral data is multiplied by the global adjustment weight to obtain the weighted light intensity value of the wavelength point; Connect all wavelength points and their corresponding weighted light intensity values in wavelength order to form the corrected spectral curve.
9. The rapid detection method for synthetic food pigments as described in claim 1, characterized in that, The method for performing point-by-point matching and comparison between the corrected spectral curve and the preset pigment standard spectral database is as follows: Retrieve the standard spectral curve of each synthetic pigment from the pigment standard spectral database; Align the corrected spectral curve with each standard spectral curve at the same wavelength point; Calculate the sum of squares of the differences in light intensity values at corresponding wavelengths between the corrected spectral curve and each standard spectral curve. The synthetic pigment species corresponding to the standard spectral curve with the smallest sum of squared differences were selected as the preliminary determination result; Based on the overall intensity ratio between the corrected spectral curve and the standard spectral curve corresponding to the preliminary judgment result, the concentration of the synthetic pigment corresponding to the preliminary judgment result in the test solution is calculated.
10. A rapid detection system for synthetic food colorings, 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 in the rapid detection method for synthetic food pigments as described in any one of claims 1 to 9.