A soil heavy metal pollution detection method, device and system
By dynamically adjusting the filter window length and multi-feature series strategy, the problem of noise interference in soil heavy metal detection is solved, and more accurate and stable detection results are achieved.
Patent Information
- Application Number
- CN202510747527.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2045-06-05
AI Technical Summary
The existing XRF instruments are affected by noise interference in soil heavy metal pollution detection, resulting in inaccurate measurement results, especially in low-content sample measurements, and the unreasonable setting of the existing filtering algorithm window affects the detection accuracy.
By analyzing the differences in adjacent spectral values of the spectral signal, similarity of feature window fit curves and similarity of multiple measurement results, the filter window length is dynamically adjusted, and combining multi-element series strategy and multivariate statistical data analysis, a disturbance evaluation method is constructed to remove noise interference.
It improves the accuracy and stability of soil heavy metal pollution detection, ensures the authenticity and consistency of spectral information, and reduces the impact of noise interference on the detection results.
Smart Images

Figure CN120253922B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of soil heavy metal detection, and specifically to a soil heavy metal pollution detection method, equipment and system. Background Art
[0002] With the rapid development of industrialization and urbanization, heavy metal contamination in soil has become a global environmental problem. Once in the soil, heavy metals such as lead (Pb), mercury (Hg), cadmium (Cd), and chromium (Cr) are not only difficult to degrade but can also pose a serious threat to human health through biomagnification in the food chain. Therefore, the development of efficient and accurate methods and technologies for detecting heavy metal contamination in soil is crucial.
[0003] An XRF (X-ray fluorescence spectrometer) is an instrument used to analyze the chemical composition of substances. It excites a sample with X-rays and detects the resulting X-ray fluorescence to determine the type and content of elements in the sample. These instruments are portable, fast, and easy to use, making them widely used in soil heavy metal contamination detection. However, during XRF analysis, spectral data is affected not only by inherent noise from electronic components in the hardware system and statistical fluctuations in the detector, but also by environmental and experimental instability. This can lead to significant deviations or even inaccuracies in the measurement results, especially in low-content samples, which can even cause erroneous results. Therefore, spectral data de-noising is necessary. However, existing filtering algorithms use a fixed window size for denoising. If the window size is set too large, soil spectral information may be obscured, while if it is set too small, denoising will not be achieved. The window size setting in the denoising algorithm can affect the accuracy of soil heavy metal contamination detection. Summary of the Invention
[0004] In a first aspect, an embodiment of the present application provides a method for detecting heavy metal pollution in soil, the method comprising the following steps:
[0005] Acquiring multiple spectral signals of a soil sample to be tested;
[0006] Cluster all spectral values in each spectral signal, divide all spectral values in each cluster into the same window according to wavelength arrangement, analyze the abnormality of the difference between each spectral value and its adjacent spectral values in each window, and determine the first disturbance degree of each spectral value in each window;
[0007] The length of all windows of each spectral value is used as the input of the threshold segmentation algorithm, and the window with a length greater than the segmentation threshold is recorded as a characteristic window. All spectral values in each characteristic window are fitted, and the confidence of each characteristic window of each spectral signal is determined by analyzing the similarity of the fitting curve between each characteristic window and the other characteristic windows, as well as the goodness of fit of the fitting curve in each characteristic window, so as to obtain the second disturbance degree of each spectral value in each spectral signal;
[0008] By comparing the difference in the number of characteristic windows and the difference in characteristic peaks between each spectral signal and the rest of the spectral signals, and combining the similarity between each spectral signal and the rest of the spectral signals, the similarity coefficient between each spectral signal and the rest of the spectral signals is determined to obtain the similar spectral signal of each spectral signal;
[0009] Based on the degree of dispersion of all spectral values at the same wavelength in each spectral signal and all its similar spectral signals, and in combination with the first disturbance degree and the second disturbance degree, the disturbance degree of each spectral value in each spectral signal is determined to improve the filter window length when denoising the spectral signal, and heavy metal detection is performed on the soil sample to be tested based on the denoised spectral signal.
[0010] Preferably, the method for determining the first disturbance degree of each spectral value in each window is:
[0011] Calculate the mean of the differences between each spectral value and its adjacent spectral values in each window, use the mean of all spectral values as the input of the anomaly detection algorithm, output the anomaly score of the mean of all spectral values in each window, and take the normalized value of the anomaly score of the mean of each spectral value in each window as the first disturbance degree of each spectral value in each window.
[0012] Preferably, the confidence expression of each characteristic window of each spectral signal is: Where, Represents the confidence of the s-th feature window of spectral signal A; Indicates the goodness of fit of the fitting curve in the s-th feature window of the spectral signal A; Represents the similarity of the fitting curve between the sth feature window and the jth feature window of the spectral signal A; represents the number of all feature windows of the spectral signal A; norm() represents the normalization function.
[0013] Preferably, the second disturbance degree of each spectral value in each spectral signal is a normalized value of the inverse of the confidence degree of the characteristic window where each spectral value is located.
[0014] Preferably, the method for determining the similarity coefficient between each spectral signal and the remaining spectral signals is:
[0015] Calculate the center wavelength differences of all characteristic windows between each spectral signal and the remaining spectral signals, and use the two characteristic windows whose center wavelength differences are smaller than a preset threshold as matching windows between each spectral signal and its respective spectral signals;
[0016] Similarity coefficient between spectral signal A and spectral signal B The expression is: Where, Represents the difference in the number of feature windows between spectral signal A and spectral signal B; represents the difference in characteristic peaks in the hth pair of matching windows between spectral signals A and B; represents the number of all pairs of matching windows between spectral signal A and spectral signal B; norm[ ] represents the normalization function.
[0017] Preferably, the method for obtaining the similar spectral signal of each spectral signal is:
[0018] The similarity coefficient between each spectral signal and all other spectral signals is used as the input of the threshold segmentation algorithm, and the segmentation threshold is output, which is recorded as the similarity threshold. Among all other spectral signals, the spectral signal with a similarity coefficient greater than the similarity threshold is used as the similar spectral signal of each spectral signal.
[0019] Preferably, the method for determining the disturbance degree of each spectral value in each spectral signal is:
[0020] Obtaining, from all similar spectral signals of each spectral signal, all spectral values at the same wavelength as each spectral value in each spectral signal, and calculating the variance of each spectral value and all spectral values at the same wavelength as each spectral value as the third disturbance degree of each spectral value in each spectral signal;
[0021] For all spectral values in all characteristic windows of each spectral signal, the normalized value of the average of the first disturbance degree, the second disturbance degree and the third disturbance degree of each spectral value is used as the disturbance degree of each spectral value in each spectral signal.
[0022] Preferably, the method of improving the filter window length when denoising the spectral signal and detecting soil heavy metal pollution based on the denoised spectral signal includes:
[0023] The filter window length of the spectral value a in the spectral signal A The expression is: Where, Indicates the degree of disturbance of the spectrum value a in the spectrum signal A; n, Respectively represent a preset first value and a preset second value, wherein the preset first value is smaller than the preset second value;
[0024] All spectral values in each spectral signal are used as inputs of the filtering algorithm, wherein the size of the filtering window is set to the filtering window length of each spectral value, and the denoised spectral signal is output;
[0025] A multi-feature concatenation strategy is used to obtain the characteristic variables in all denoised spectral signals, and a multivariate statistical data analysis method is used to build a model based on the characteristic variables to obtain a quantitative analysis model for the heavy metal content of soil samples. The heavy metal content quantitative analysis model is used to detect heavy metal pollution in the soil.
[0026] In a second aspect, an embodiment of the present application further provides a soil heavy metal pollution detection device, wherein a computer program is stored in the device, and when the computer program is executed by a processor, the soil heavy metal pollution detection method described in any one of the above items is implemented.
[0027] In a third aspect, an embodiment of the present application provides a soil heavy metal pollution detection system, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein when the processor executes the computer program, the steps of any one of the above-mentioned soil heavy metal pollution detection methods are implemented.
[0028] As can be seen from the above embodiments, the method for detecting heavy metal pollution in soil provided by the embodiments of the present application has at least the following beneficial effects:
[0029] The present application constructs a first disturbance degree by calculating the abnormal degree of the difference between adjacent spectral values in each window of the spectral signal, which can effectively evaluate the degree of noise interference, thereby accurately reducing the noise of the spectral value according to the degree of noise interference suffered by the spectral value, and then improving the spectral value to improve the accuracy of soil heavy metal pollution detection; further, by analyzing the possibility of containing a true characteristic peak in the characteristic window, a second disturbance degree is constructed, which helps to determine the true reliability of the spectral value, thereby improving the accuracy of the soil heavy metal pollution detection result; further, by comprehensively considering the first disturbance degree and the second disturbance degree, and combining the discrete degree of all spectral values at the same wavelength in each spectral signal and all its similar spectral signals, a disturbance degree is constructed, which can more comprehensively evaluate the degree of noise interference of each spectral value, thereby dynamically adjusting the filtering window of the spectral value, performing more effective denoising processing on the spectral signal, retaining more real spectral information, thereby improving the accuracy of soil heavy metal content detection. The present application can more accurately evaluate and remove noise interference in spectral data by comprehensively analyzing the abnormal degree of the difference between adjacent spectral values, the difference between characteristic peaks and noise, and the similarity of multiple measurement results, thereby improving the accuracy of soil heavy metal pollution detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the technical solutions and advantages of the embodiments of the present application or the prior art, the following is a brief introduction to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0031] Figure 1 A flowchart of a method for detecting heavy metal pollution in soil provided in one embodiment of the present application;
[0032] Figure 2 A schematic diagram of a second disturbance degree acquisition process provided in one embodiment of the present application. DETAILED DESCRIPTION
[0033] In order to further illustrate the technical means and effects adopted by this application to achieve the intended invention objectives, the following, in conjunction with the accompanying drawings and preferred embodiments, describes in detail a method, device, and system for detecting heavy metal pollution in soil proposed in this application, including its specific implementation, structure, features, and effects. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. In addition, specific features, structures, or characteristics of one or more embodiments may be combined in any suitable form.
[0034] Unless defined otherwise, 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 belongs.
[0035] The following describes in detail a method, device and system for detecting heavy metal pollution in soil provided by the present application with reference to the accompanying drawings.
[0036] See also Figure 1 , which shows a flowchart of a method for detecting heavy metal pollution in soil provided by an embodiment of the present application, the method comprising the following steps:
[0037] S1: Acquire multiple spectral signals of the soil sample to be tested.
[0038] Spectral data analysis is a very effective method in environmental monitoring and soil pollution assessment. In order to accurately identify and quantify the heavy metal content in the soil, an X-ray fluorescence (XRF) analyzer is used to test the soil samples.
[0039] The reason for using XRF analyzers to test soil samples is that XRF technology can non-destructively determine the elemental composition of the soil. By emitting X-rays to irradiate the soil sample, different elements will emit characteristic fluorescent X-rays. These rays are received by the detector and converted into spectral signals. These spectral signals contain the characteristic information of the elements and are the key to analyzing the heavy metal content in the soil.
[0040] Soil samples are usually collected from contaminated or suspected contaminated areas. Due to soil heterogeneity, even samples collected at the same location may have different levels of contamination. Therefore, to obtain more representative data, it is necessary to collect spectral signals from the same soil multiple times. Specifically, the soil is tested using an existing XRF analyzer to obtain multiple sets of spectral signals from the same soil sample.
[0041] S2: Cluster all spectral values in each spectral signal, divide all spectral values in each cluster into the same window according to wavelength arrangement, analyze the abnormality of the difference between each spectral value in each window and its adjacent spectral values, and determine the first disturbance degree of each spectral value in each window.
[0042] Spectral signals identify elements based on characteristic peaks. Characteristic peaks are more prominent in spectral data, but they change continuously. Therefore, the influence of noise on spectral signals can be analyzed based on the difference in changes in spectral data adjacent to characteristic peaks. Since the spectral data in the characteristic peak area changes at different rates from those in other areas, in order to better analyze, this example first classifies the spectral signals. The classification method is as follows:
[0043] All spectral values in each spectral signal are used as inputs of the clustering algorithm, and multiple clusters are output. In this embodiment, all spectral values in each cluster are sorted into the same window according to the results of ascending order of wavelength.
[0044] It should be noted that there are many commonly used clustering algorithms. In this embodiment, the DBSCAN density clustering algorithm is used to cluster all spectral values in each spectral signal. In actual application, as other implementation methods, the implementer may also use DPC density peak clustering or k-means clustering algorithm to cluster the spectral values. Regarding the selection of clustering algorithm, this embodiment does not impose any special restrictions.
[0045] Among them, the DBSACN density clustering algorithm is a well-known technology, and its specific clustering principle is not repeated here.
[0046] It is supplemented that the method for determining the metric distance in the clustering algorithm is: the spectral value and its corresponding wavelength are grouped into two tuples, and the Euclidean distance between the two tuples is used as the metric distance.
[0047] The calculation method of the Euclidean distance is a well-known technology, and its specific calculation process will not be described in detail.
[0048] Furthermore, the abnormal degree of the difference between each spectral value in each window and its adjacent spectral values is analyzed to determine the first disturbance degree of each spectral value in each window, specifically:
[0049] Calculate the mean of the differences between each spectral value and its adjacent spectral values in each window, use the mean of all spectral values as the input of the anomaly detection algorithm, output the anomaly score of the mean of all spectral values in each window, and take the normalized value of the anomaly score of the mean of each spectral value in each window as the first disturbance degree of each spectral value in each window.
[0050] In particular, for the first and last spectral values in each window, the difference between the first spectral value and its adjacent subsequent spectral value is used as the input of the anomaly detection algorithm, and the difference between the last spectral value and its adjacent previous spectral value is used as the input of the anomaly detection algorithm.
[0051] It should be noted that there are many methods for measuring the difference between two data. In this embodiment, the absolute value of the difference between each spectral value in each window and its two adjacent spectral values is used as the difference between each spectral value in each window and its two adjacent spectral values. In actual application, as other implementation methods, the implementer may also adopt other methods for measuring the difference between data, such as the square or ratio of the difference, based on the specific circumstances. This embodiment does not impose any special restrictions on the selection of the method for measuring the difference between data.
[0052] In addition, it should be understood that there are many commonly used anomaly detection algorithms. In this embodiment, the LOF anomaly detection algorithm is used to obtain the anomaly scores of the respective means of all spectral values. In actual application, as other implementation methods, implementers may also use other anomaly detection algorithms such as the isolation forest algorithm. Regarding the selection of anomaly detection algorithms, this embodiment does not impose any special restrictions.
[0053] Among them, the LOF anomaly detection algorithm is a well-known technology, and the specific process of using it to evaluate data anomaly scores will not be repeated here.
[0054] According to the first disturbance degree of each spectral value in each window, it can be understood that the first disturbance degree reflects whether the difference between adjacent spectral values in the spectral signal is abnormal. If the first disturbance degree of the current spectral value is larger, it indicates that the difference between the current spectral value and its adjacent spectral values in the spectral signal is larger. This difference is likely caused by noise interference, indicating that the noise interference received by the spectral value is relatively serious, and its spectral information may have been obscured by the noise.
[0055] On the contrary, if the first disturbance degree of the current spectral value is smaller, it means that the difference between the current spectral value and its adjacent spectral values is smaller, and the current spectral value is less affected by noise, which means that the current spectral value retains more original signal features. During the denoising process, only slight filtering may be required or no filtering may be required to avoid losing important spectral information.
[0056] Thus, by analyzing the abnormality of the difference between each spectral value and its adjacent spectral values in each window, the first disturbance degree of each spectral value is obtained.
[0057] Step S3: All window lengths of each spectral value are used as input to the threshold segmentation algorithm, and windows with lengths greater than the segmentation threshold are recorded as feature windows. All spectral values in each feature window are fitted, and the confidence of each feature window of each spectral signal is determined by analyzing the similarity of the fitting curves between each feature window and the remaining feature windows, as well as the goodness of fit of the fitting curves in each feature window, so as to obtain the second disturbance degree of each spectral value in each spectral signal.
[0058] During the XRF analysis process, spectral data is affected not only by the inherent noise of electronic components in the hardware system and statistical fluctuations of the detector, but also by unstable factors such as the external environment and experimental conditions, which can cause large deviations or even inaccuracies in the measurement results, especially in the measurement of low-content samples.
[0059] Among them, noise data can make the signal stand out and abnormal, and the window in which it is located is made smaller due to the clustering in step S2. The signal with a more prominent signal and a smaller window may also be a characteristic peak of the spectral data. Therefore, it is necessary to analyze the information within each window and cluster the window length to confirm the degree of abnormality of the signal within the window. Because the characteristic peak conforms to the characteristics of the peak, its adjacent signals will also conform to the characteristics of the "peak" when changing. However, the signal changes of the signal with a greater degree of noise interference will not conform to the characteristics of the characteristic peak.
[0060] Therefore, based on the above analysis, first, all window lengths of each spectral value are used as input to the threshold segmentation algorithm, and the windows with lengths greater than the segmentation threshold are recorded as feature windows, which are used to characterize the windows where the characteristic peaks are suspected to be located.
[0061] It should be noted that there are many commonly used threshold segmentation algorithms. In this embodiment, the maximum inter-class variance algorithm is used to obtain the segmentation threshold. In actual application, as other implementation methods, implementers can also use other threshold segmentation methods. Regarding the selection of threshold segmentation methods, this embodiment does not impose any special restrictions.
[0062] Among them, the maximum inter-class variance algorithm is a well-known technology, and its specific principle is not repeated here.
[0063] It is supplemented that, in this embodiment, all the content related to threshold segmentation adopts the maximum inter-class variance algorithm.
[0064] Secondly, by analyzing the similarity of the spectral value fitting results between each characteristic window and the rest of the characteristic windows, as well as the goodness of fit of the spectral value fitting process within each characteristic window, the confidence level of each characteristic window of each spectral signal is determined to obtain the second disturbance degree of each spectral value in each spectral signal. The specific process is as follows:
[0065] (1) Fit all spectral values in each characteristic window to obtain a fitting curve for each characteristic window. In this embodiment, a polynomial function fitting method is used to fit all spectral values. In actual application, as other implementation methods, the implementer may also adopt other fitting methods such as the least squares method in combination with specific circumstances. This embodiment does not impose any special restrictions on the selection of the fitting method.
[0066] Among them, polynomial function fitting is a well-known technology, and the specific process of fitting the spectrum values using it will not be described in detail.
[0067] (2) Furthermore, by analyzing the similarity of the fitting curves between each feature window and the other feature windows, as well as the goodness of fit of the fitting curve within each feature window, the confidence level of each feature window of each spectral signal is determined, specifically:
[0068] In this embodiment, as an implementation method, the confidence level of the s-th characteristic window of the spectral signal A is The expression is: Where, Indicates the goodness of fit of the fitting curve in the s-th feature window of the spectral signal A; Represents the similarity of the fitting curves between the sth feature window and the jth feature window of spectral signal A; represents the number of all feature windows of spectral signal A; norm( ) represents the normalization function.
[0069] It should be noted that there are many methods for measuring the similarity of fitting curves. In this embodiment, the inverse of the DTW distance of the fitting curve between the sth feature window and the jth feature window of the spectral signal A is used as the similarity of the fitting curve between the sth feature window and the jth feature window of the spectral signal A. In actual application, the implementer may also use the cosine similarity or the inverse of the Euclidean distance to measure the similarity between the fitting curves. This embodiment does not impose any special restrictions on the selection of the method for measuring the similarity.
[0070] The calculation methods of the DTW distance and the goodness of fit are both well-known technologies, and their specific calculation processes are not described in detail here.
[0071] It is additionally noted that, in this embodiment, all contents involving calculation of similarity use the inverse of the DTW distance.
[0072] According to the confidence of each characteristic window of each spectral signal, it can be understood that the confidence reflects the degree of credibility of the characteristic window as a window containing a characteristic peak. If the similarity of the fitting curve between the s-th characteristic window and the j-th characteristic window is greater, it means that the spectral values between the s-th characteristic window and the j-th characteristic window may be generated by the spectral emission of the same specific element, and the greater the goodness of fit of the fitting curve in the s-th characteristic window, the greater the possibility that the s-th characteristic window contains a characteristic peak, and the greater the confidence finally obtained, the greater the possibility that the s-th characteristic window contains a characteristic peak, rather than an illusion caused by noise or other interference;
[0073] On the contrary, if the similarity of the fitting curves between the sth feature window and the jth feature window is smaller, it means that the spectral values between the sth feature window and the jth feature window may be generated by the spectral emissions of different specific elements, and the smaller the fitting goodness of the fitting curve in the sth feature window, the smaller the possibility of the sth feature window containing the characteristic peak, and the smaller the final confidence level, which means that the possibility of the sth feature window containing the characteristic peak is smaller, and the peak of the suspected characteristic peak in the feature window is more likely to be caused by noise or other interference.
[0074] (3) Further, based on the confidence of each characteristic window of each spectral signal, the second disturbance degree of each spectral value in each spectral signal is obtained, specifically:
[0075] The reciprocal normalized value of the confidence level of the characteristic window where each spectral value is located is taken as the second interference level of each spectral value in each spectral signal, which reflects the possibility that the characteristic window where the spectral value is located contains a true characteristic peak and quantifies the possibility that the spectral value is interfered with by noise. If the second interference level is larger, it means that the possibility that the characteristic window where the spectral value is located contains a true characteristic peak is smaller, and the possibility that the signal in the characteristic window where the spectral value is located is more likely to be affected by noise or other interference is greater, which means that the degree of noise interference on the spectral value is greater and the authenticity of the signal is lower.
[0076] On the contrary, if the second interference degree is smaller, it means that the possibility that the characteristic window where the spectral value is located contains a real characteristic peak is greater, and the possibility that the signal in the characteristic window where the spectral value is located is less affected by noise or other interference is smaller, which means that the degree of noise interference on the spectral value is smaller, and the authenticity of its signal is higher.
[0077] Preferably, the second disturbance degree acquisition process diagram provided in this embodiment is as follows: Figure 2 shown.
[0078] At this point, by analyzing the fitting differences of the spectral values between each characteristic window and the rest of the characteristic windows, the second disturbance degree of each spectral value is obtained, and the degree to which each spectral value in the spectral signal is disturbed by noise is quantified.
[0079] Step S4: By comparing the difference in the number of characteristic windows and the difference in characteristic peaks between each spectral signal and the remaining spectral signals, and combining the similarity between each spectral signal and the remaining spectral signals, the similarity coefficient between each spectral signal and the remaining spectral signals is determined to obtain a similar spectral signal for each spectral signal.
[0080] Since the soil sample is fixed, the spectral data obtained from multiple measurements and analyses may be similar, while the noise interference is random. Therefore, when performing denoising analysis, the spectral signals similar to the current spectral signal in the multiple measurement results can be combined for analysis to determine the degree of noise interference on the current spectral signal. Therefore, by comparing the difference in the number of characteristic windows and the difference in characteristic peaks between each spectral signal and the remaining spectral signals, and combining the similarity between each spectral signal and the remaining spectral signals, the similarity coefficient between each spectral signal and the remaining spectral signals is determined to obtain the similar spectral signal of each spectral signal, specifically:
[0081] Calculate the center wavelength differences of all characteristic windows between each spectral signal and the remaining spectral signals, and use the two characteristic windows whose center wavelength differences are smaller than a preset threshold as matching windows between each spectral signal and its respective spectral signals;
[0082] It should be noted that the central wavelength is the median of all wavelengths in the characteristic window.
[0083] Furthermore, based on the difference in the number of characteristic windows and the difference in characteristic peaks between each spectral signal and the rest of the spectral signals, and combined with the similarity between each spectral signal and the rest of the spectral signals, the similarity coefficient between each spectral signal and the rest of the spectral signals is determined, specifically:
[0084] In this embodiment, as an implementation method, the similarity coefficient between the spectral signal A and the spectral signal B is The expression is: Where, Represents the difference in the number of feature windows between spectral signal A and spectral signal B; represents the difference in characteristic peaks in the hth pair of matching windows between spectral signals A and B; represents the number of all pairs of matching windows between spectral signal A and spectral signal B; norm[ ] represents the normalization function.
[0085] The reciprocal of the DTW distance between the spectral signal A and the spectral signal B is used as the similarity between the spectral signal A and the spectral signal B.
[0086] It should be noted that the characteristic peak is a well-known technology, and its specific principles and concepts are not described in detail.
[0087] According to the similarity coefficient between each spectral signal and the other spectral signals, it can be understood that the similarity coefficient reflects the degree of similarity between two spectral signals. If the similarity coefficient is larger, it means that the similarity between the two spectral signals is higher, that is, they are closer in the number of characteristic windows, the position and shape of characteristic peaks, which means that the two spectral signals are more likely to have similar noise interference patterns. Therefore, they show higher consistency in the spectrum;
[0088] On the contrary, if the similarity coefficient is smaller, it means that the similarity between the two spectral signals is lower, that is, they differ greatly in the number of characteristic windows, the position and shape of characteristic peaks, which means that the possibility of the two spectral signals being subject to similar noise interference patterns is smaller. Therefore, they show lower similarity in the spectrum and are not suitable for mutual verification.
[0089] Furthermore, based on the similarity coefficient obtained above, similar spectral signals of the spectral signals are obtained. Specifically, the similarity coefficient between each spectral signal and all other spectral signals is used as the input of the threshold segmentation algorithm, and the segmentation threshold is output, which is recorded as the similarity threshold. Among all other spectral signals, the spectral signal with a similarity coefficient greater than the similarity threshold is used as the similar spectral signal of each spectral signal.
[0090] At this point, by analyzing the similarity of spectral information between spectral signals, similar spectral signals of each spectral signal are obtained.
[0091] Step S5: Based on the degree of dispersion of all spectral values at the same wavelength in each spectral signal and all its similar spectral signals, and in combination with the first disturbance degree and the second disturbance degree, the disturbance degree of each spectral value in each spectral signal is determined to improve the filter window length when denoising the spectral signal, and heavy metal detection is performed on the soil sample to be tested based on the denoised spectral signal.
[0092] Determining the disturbance degree of each spectral value in each spectral signal based on the degree of dispersion of all spectral values at the same wavelength in each spectral signal and all similar spectral signals thereof, and in combination with the first disturbance degree obtained in step S2 and the second disturbance degree obtained in step S3, specifically by obtaining, from all similar spectral signals of each spectral signal, all spectral values at the same wavelength as each spectral value in each spectral signal, and calculating the variance of each spectral value with all spectral values at the same wavelength as the variance of each spectral value, as the third disturbance degree of each spectral value in each spectral signal;
[0093] For all spectral values in all characteristic windows of each spectral signal, the normalized value of the average of the first disturbance degree, the second disturbance degree and the third disturbance degree of each spectral value is used as the disturbance degree of each spectral value in each spectral signal.
[0094] According to the disturbance degree of each spectral value in each spectral signal, it can be understood that the disturbance degree reflects the comprehensive situation of the spectral value being disturbed by noise. If the disturbance degree of the current spectral value is greater, it means that the noise interference of the current spectral value is more serious, which may lead to wrong judgment or underestimation of soil composition; on the contrary, if the disturbance degree of the current spectral value is smaller, it means that the spectral value is less disturbed by noise, and the current spectral value is closer to the real spectral signal, with higher reliability, which helps to more accurately evaluate the composition and pollutant content in soil samples.
[0095] At this point, by combining the first and second disturbances and combining the discrete degrees of all spectral values at the same wavelength in each spectral signal and all its similar spectral signals, the spectral disturbance degree is obtained, which quantifies the degree to which each spectral value in the spectral signal is interfered with by noise.
[0096] Furthermore, based on the degree of disturbance of each spectral value in each spectral signal, the filter window length when denoising the spectral signal is improved, and heavy metal detection is performed on the soil sample to be tested based on the denoised spectral signal, specifically:
[0097] The filter window length of the spectral value a in the spectral signal A The expression is: Where, Indicates the degree of disturbance of the spectrum value a in the spectrum signal A; n, They respectively represent a preset first value and a preset second value, wherein the preset first value is smaller than the preset second value.
[0098] It should be noted that, in this embodiment, the preset first value is 5, and the preset second value is 99. This is because the preset first value is usually set to a smaller number to ensure that when the spectral value is less disturbed, the length of the filter window will not be too large. A smaller filter window helps to retain more spectral details, especially for spectral values that are less affected by noise. This can avoid over-smoothing the signal, thereby retaining the fine structure of the characteristic peak; the preset second value is usually set to a larger number to increase the length of the filter window when the spectral value is more disturbed. A larger filter window helps to better smooth those spectral values that are more affected by noise, thereby reducing the impact of noise on the signal; the implementer can also set it by himself according to the specific situation, and this embodiment does not impose any special restrictions.
[0099] Furthermore, all spectral values in each spectral signal are used as inputs of a filtering algorithm, wherein the size of the filtering window is set to the filtering window length of each spectral value, and the denoised spectral signal is output;
[0100] It should be noted that, in this embodiment, a Gaussian filtering algorithm is used to perform denoising on the spectral signal. The implementer may also use other filtering methods such as median filtering. This embodiment does not impose any special restrictions on the selection of the filtering algorithm.
[0101] The Gaussian filtering algorithm is a well-known technology, and its specific filtering principle will not be described in detail.
[0102] Furthermore, a multi-feature concatenation strategy was used to obtain the characteristic variables in all denoised spectral signals, and a multivariate statistical data analysis method was used to build a model based on the characteristic variables to obtain a quantitative analysis model for the heavy metal content of soil samples, which was used for the detection of heavy metal content in soil samples.
[0103] It should be noted that the multi-feature concatenation strategy in this embodiment adopts the interval combination optimization algorithm (ICO). In actual application, the implementer may also adopt other methods such as competitive adaptive reweighted sampling (CARS) or continuous projection algorithm (SPA) in combination with specific circumstances; in addition, with respect to the multivariate statistical data analysis method, the partial least squares method (PLS) is adopted in this embodiment. As other implementation methods, the implementer may also adopt other multivariate statistical data analysis methods such as multivariate regression method in combination with specific circumstances. This embodiment does not impose any special restrictions on the selection of the multi-feature concatenation strategy and the multivariate statistical data analysis method.
[0104] Among them, the interval combinatorial optimization algorithm (ICO) and the partial least squares method (PLS) are both well-known technologies, and the specific processes of obtaining characteristic variables using the interval combinatorial optimization algorithm (ICO) and modeling using the partial least squares method (PLS) are not described in detail.
[0105] Thus, this embodiment has comprehensively analyzed the differences between adjacent spectral values, the degree of abnormality of the signal within the window, and the similarity of multiple measurement results to accurately evaluate and remove noise interference in the spectral data, thereby improving the reliability of the spectral values; further, in the denoising process, special attention is paid to the retention of spectral characteristic peaks to ensure that key information used for element identification and quantitative analysis is not mistakenly denoised, thereby improving the availability of data and the accuracy of analysis; further, through similarity analysis and comprehensive denoising of multiple groups of measurement data, the consistency and stability between different measurement results are enhanced, avoiding fluctuations in analysis results caused by the randomness of a single measurement or the influence of noise, ensuring the stability and reliability of the analysis results, and then accurately evaluating and removing noise interference in the spectral data, thereby improving the accuracy of the detection results of heavy metal content in soil.
[0106] Based on the same inventive concept as the above method, an embodiment of the present application also provides a soil heavy metal pollution detection device, in which a computer program is stored. When the computer program is executed by a processor, it implements any of the above-mentioned soil heavy metal pollution detection methods.
[0107] Based on the same inventive concept as the above method, an embodiment of the present application also provides a soil heavy metal pollution 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, the steps of any one of the above-mentioned soil heavy metal pollution detection methods are implemented.
[0108] It should be noted that the order in which the embodiments of the present application are presented is for illustrative purposes only and does not necessarily represent the superiority or inferiority of the embodiments. Furthermore, the foregoing descriptions of specific embodiments of this specification are provided. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential sequence shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0109] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments.
[0110] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for detecting heavy metal pollution in soil, characterized in that: The method comprises the following steps: Acquiring multiple spectral signals of a soil sample to be tested; Cluster all spectral values in each spectral signal, divide all spectral values in each cluster into the same window according to wavelength arrangement, analyze the abnormality of the difference between each spectral value and its adjacent spectral values in each window, and determine the first disturbance degree of each spectral value in each window; The length of all windows of each spectral value is used as the input of the threshold segmentation algorithm, and the window with a length greater than the segmentation threshold is recorded as a characteristic window. All spectral values in each characteristic window are fitted, and the confidence of each characteristic window of each spectral signal is determined by analyzing the similarity of the fitting curve between each characteristic window and the other characteristic windows, as well as the goodness of fit of the fitting curve in each characteristic window, so as to obtain the second disturbance degree of each spectral value in each spectral signal; By comparing the difference in the number of characteristic windows and the difference in characteristic peaks between each spectral signal and the rest of the spectral signals, and combining the similarity between each spectral signal and the rest of the spectral signals, the similarity coefficient between each spectral signal and the rest of the spectral signals is determined to obtain the similar spectral signal of each spectral signal; Determining the disturbance degree of each spectral value in each spectral signal based on the degree of dispersion of all spectral values at the same wavelength in each spectral signal and all similar spectral signals thereof, and in combination with the first disturbance degree and the second disturbance degree, so as to improve the filter window length when denoising the spectral signal, and performing heavy metal detection on the soil sample to be tested based on the denoised spectral signal; The confidence expression of each characteristic window of each spectral signal is: Where, Represents the confidence of the s-th feature window of spectral signal A; Indicates the goodness of fit of the fitting curve in the s-th feature window of the spectral signal A; Represents the similarity of the fitting curves between the sth feature window and the jth feature window of spectral signal A; Represents the number of all feature windows of spectral signal A; norm( ) represents the normalization function; The method for determining the similarity coefficient between each spectral signal and the remaining spectral signals is: Calculate the center wavelength differences of all characteristic windows between each spectral signal and the remaining spectral signals, and use the two characteristic windows whose center wavelength differences are smaller than a preset threshold as matching windows between each spectral signal and its respective spectral signals; Similarity coefficient between spectral signal A and spectral signal B The expression is: Where, Represents the difference in the number of feature windows between spectral signal A and spectral signal B; represents the difference in characteristic peaks in the hth pair of matching windows between spectral signals A and B; represents the number of all pairs of matching windows between spectral signal A and spectral signal B; norm[ ] represents the normalization function.
2. A soil heavy metal pollution detection method according to claim 1, characterized in that: The method for determining the first disturbance degree of each spectral value in each window is as follows: Calculate the mean of the differences between each spectral value and its adjacent spectral values in each window, use the mean of all spectral values as the input of the anomaly detection algorithm, output the anomaly score of the mean of all spectral values in each window, and take the normalized value of the anomaly score of the mean of each spectral value in each window as the first disturbance degree of each spectral value in each window.
3. A soil heavy metal pollution detection method according to claim 1, characterized in that: The second disturbance degree of each spectral value in each spectral signal is a normalized value of the inverse of the confidence degree of the characteristic window where each spectral value is located.
4. A soil heavy metal pollution detection method according to claim 1, characterized in that: The method for obtaining the similar spectral signal of each spectral signal is: The similarity coefficient between each spectral signal and all other spectral signals is used as the input of the threshold segmentation algorithm, and the segmentation threshold is output, which is recorded as the similarity threshold. Among all other spectral signals, the spectral signal with a similarity coefficient greater than the similarity threshold is used as the similar spectral signal of each spectral signal.
5. A soil heavy metal pollution detection method according to claim 1, characterized in that: The method for determining the disturbance degree of each spectral value in each spectral signal is as follows: Obtaining, from all similar spectral signals of each spectral signal, all spectral values at the same wavelength as each spectral value in each spectral signal, and calculating the variance of each spectral value and all spectral values at the same wavelength as each spectral value as the third disturbance degree of each spectral value in each spectral signal; For all spectral values in all characteristic windows of each spectral signal, the normalized value of the average of the first disturbance degree, the second disturbance degree and the third disturbance degree of each spectral value is used as the disturbance degree of each spectral value in each spectral signal.
6. A method for detecting heavy metal pollution in soil according to claim 1, characterized in that: The method improves the filter window length when denoising the spectral signal and detects soil heavy metal pollution based on the denoised spectral signal, including: The filter window length of the spectral value a in the spectral signal A The expression is: Where, Indicates the degree of disturbance of the spectrum value a in the spectrum signal A; n, Respectively represent a preset first value and a preset second value, wherein the preset first value is smaller than the preset second value; All spectral values in each spectral signal are used as inputs of the filtering algorithm, wherein the size of the filtering window is set to the filtering window length of each spectral value, and the denoised spectral signal is output; A multi-feature concatenation strategy is used to obtain the characteristic variables in all denoised spectral signals, and a multivariate statistical data analysis method is used to build a model based on the characteristic variables to obtain a quantitative analysis model for the heavy metal content of soil samples. The heavy metal content quantitative analysis model is used to detect heavy metal pollution in the soil.
7. A soil heavy metal pollution detection device, wherein a computer program is stored in the device, characterized in that: When the computer program is executed by a processor, a method for detecting heavy metal pollution in soil according to any one of claims 1 to 6 is implemented.
8. A soil heavy metal pollution 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, the method for detecting heavy metal pollution in soil as described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Rapid soil layer pollution detection method based on spectral analysis
CN117629967A
Soil heavy metal content detection and correction method based on X-ray fluorescence spectrum
CN119355025A