Water pollutant detection method, system and equipment based on spectral analysis
Through the combination of multi-spectral sensor array and depth confidence network, the stability problem of vehicle-mounted water quality detection devices under vibration and light source changes is solved, and the simultaneous detection of multiple pollutants is achieved, which improves detection efficiency and accuracy.
Patent Information
- Application Number
- CN202511026729.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-24
- Publication Date
- 2025-08-29
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing vehicle-mounted water quality detection devices cannot detect multiple pollutants at the same time, and vibration interference and changes in ambient light sources during the vehicle's driving affect the detection stability and accuracy.
A multi-spectral sensor array is used, a four-point elastic support frame and magnetofluid damper is combined with a depth confidence network and a variational autoencoder to perform anti-vibration wavelength calibration of spectral data, ambient light source interference elimination and multivariate decomposition treatment to achieve pollutant feature matching analysis.
Achieve stable and continuous spectrum data acquisition during vehicle driving, improve the reliability and consistency of detection results, and can detect organic pollutants, heavy metal pollutants and nutrient pollutants at the same time, enhancing the ability to identify low-concentration pollutants.
Smart Images

Figure CN120558868A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of water quality detection technology, and in particular to a method, system and equipment for detecting water pollutants based on spectral analysis. Background Art
[0002] Existing vehicle-mounted water quality testing devices face multiple technical challenges, the most prominent of which is their inability to simultaneously detect multiple pollutants in the water. They can only detect a single indicator at a time, significantly reducing the efficiency of water quality monitoring. Furthermore, vibration interference from vehicles in motion seriously impacts the stability and accuracy of the testing equipment. Traditional devices lack effective anti-vibration mechanisms, leading to optical signal fluctuations and data distortion. Furthermore, the interference of ambient light source variations on test results has not been effectively addressed, resulting in a lack of consistency and comparability in data obtained under different lighting conditions. Summary of the Invention
[0003] The present application provides a method, system and equipment for detecting water pollutants based on spectral analysis, thereby effectively eliminating ambient light changes and other background interference, and can not only determine the type of pollutant, but also accurately quantify its concentration value.
[0004] In a first aspect, the present application provides a method for detecting water pollutants based on spectral analysis, the method comprising: The multispectral sensor array in the vehicle-mounted water quality detection device collects real-time spectral data of water samples while the vehicle is driving, and obtains a three-dimensional data cube of the water spectrum; Performing anti-vibration wavelength calibration and environmental light source interference elimination processing on the water body spectrum three-dimensional data cube to obtain a preprocessed spectrum data set; Performing canonical multivariate decomposition processing and horizontal local constrained optimization of pollutant target bands on the preprocessed spectral data set to obtain enhanced characteristic fingerprint spectra for different types of water pollutants; The enhanced characteristic fingerprint spectrum is input into a deep belief network model for pollutant feature matching analysis to obtain multiple pollutant types and their corresponding concentration values present in the water sample.
[0005] A second aspect of the present application provides a water quality pollutant detection system based on spectral analysis, the water quality pollutant detection system based on spectral analysis comprising: A data acquisition module is used to collect real-time spectral data of water samples while the vehicle is driving through the multispectral sensor array in the vehicle-mounted water quality detection device, and obtain a three-dimensional data cube of the water spectrum; An interference elimination module is used to perform anti-vibration wavelength calibration and environmental light source interference elimination processing on the water body spectrum three-dimensional data cube to obtain a preprocessed spectrum data set; A constrained optimization module is used to perform a canonical multivariate decomposition process and a horizontal local constrained optimization of the pollutant target band on the preprocessed spectral data set to obtain enhanced characteristic fingerprint spectra for different types of water pollutants; The matching analysis module is used to input the enhanced feature fingerprint spectrum into the deep belief network model to perform pollutant feature matching analysis to obtain the types of pollutants present in the water sample and their corresponding concentration values.
[0006] The third aspect of the present application provides an electronic device comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor calls the instructions in the memory so that the electronic device executes the above-mentioned water quality pollutant detection method based on spectral analysis.
[0007] Compared with the prior art, the present application has the following beneficial effects: through the combined application of a multi-spectral sensor array with a four-point elastic support frame and a magnetofluid damper, the vibration interference problem in a vehicle-mounted environment is solved, ensuring the acquisition of stable and continuous spectral data during vehicle driving, and realizing the function of detecting while driving. The adoption of a purely optical reagent-free detection mode completely avoids the detection deviation caused by the uneven mixing of water and detection agents in traditional vehicle-mounted water quality detection devices, and fundamentally improves the reliability and consistency of the detection results. By analyzing the spectral data in the three characteristic bands of 254-280nm, 320-380nm and 400-490nm, this method can simultaneously detect organic pollutants, heavy metal pollutants and nutrient salt pollutants in water bodies, greatly improving the detection efficiency. Through pre-processing technologies such as wavelength calibration, dark signal subtraction, scattering correction and dynamic light source compensation, the ambient light changes and other background interferences are effectively eliminated, ensuring the consistency of the detection results under various lighting conditions. A robust feature extraction method based on a variational autoencoder and a deep belief network, combined with multi-band constrained optimization and adaptive thresholding techniques, significantly enhances the ability to identify low-concentration pollutants and expands the detection range. Pollutant feature matching analysis using a deep belief network model, combined with concentration mapping and decision fusion techniques using the LASSO regression algorithm, not only identifies pollutant types but also accurately quantifies their concentrations. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces 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 invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0009] The structures, proportions, sizes, etc. depicted in the drawings of this specification are only used to match the contents disclosed in the specification so as to facilitate understanding and reading by persons familiar with this technology. They are not intended to limit the conditions under which the present invention can be implemented and therefore have no substantive technical significance. Any structural modifications, changes in proportional relationships, or adjustments in size should still fall within the scope of the technical contents disclosed in the present invention without affecting the effects and objectives that can be achieved by the present invention.
[0010] Figure 1 1 is a flow chart of a method for detecting water pollutants based on spectral analysis provided by an embodiment of the present invention; Figure 2 1 is a schematic block diagram of the structure of a water pollutant detection system based on spectral analysis provided by an embodiment of the present invention; Figure 3 It is a schematic block diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0011] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0012] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, combined, or partially merged, so the actual execution order may vary depending on the actual situation.
[0013] It should also be understood that the terms used in this specification are for the purpose of describing the target embodiments only and are not intended to limit the present application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0014] It should be further understood that the term "and / or" used in this specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations. Figure 1 In one embodiment of the present application, a method for detecting water pollutants based on spectral analysis includes: Step 100: Using a multispectral sensor array in a vehicle-mounted water quality detection device, real-time spectral data of water samples is collected while the vehicle is traveling, to obtain a three-dimensional data cube of water spectra; It is understandable that the execution subject of this application can be a water quality pollutant detection system based on spectral analysis, or a terminal or a server, which is not limited here. The embodiment of this application is described by taking the server as the execution subject as an example.
[0015] Specifically, a high-sensitivity spectral data acquisition system suitable for vehicle-mounted environments was constructed. The system's multispectral sensor array covers the full wavelength range from 220 to 720 nanometers. High-signal-to-noise ratio photomultiplier tubes (PMTs) are used, along with 15 bandpass filters, to ensure the capture of raw spectral signals from water samples in each wavelength band even when the vehicle is traveling at high speeds. A synchronous acquisition strategy is prioritized in the design, with a clock phase-locked mechanism ensuring microsecond-level synchronization of multi-channel spectral signals. This addresses the data distortion issues inherent in traditional acquisition systems due to driving vibrations and changing lighting conditions. The raw spectral signals are input into a high-precision 24-bit analog-to-digital converter for analog-to-digital conversion. A high-speed ADC chip converts the continuous analog spectral signals into a digital spectral signal stream in real time at an 8000Hz sampling rate, resulting in a digital spectral signal. To address the three-axis vibration interference in a vehicle environment, a combined structure of a four-point elastic support and a magnetofluid damper is introduced. The four-point support mechanically disperses and buffers the energy transmitted to the sensor array by vehicle vibration, while the magnetofluid damper dynamically adjusts the viscous damping coefficient at the microscopic level, automatically absorbing vibration energy based on real-time vibration amplitude changes, forming an effective three-axis vibration suppression mechanism. At this stage, hardware vibration suppression and an adaptive filtering algorithm based on sensor feedback are simultaneously processed to stabilize the spectral digital signal and output vibration-resistant stable spectral data. This vibration-resistant stable spectral data is input into the vehicle's embedded field-programmable gate array module. Its highly parallel data processing capabilities are utilized to rapidly decode and organize the data stream. A double-buffering mechanism is also implemented: while one data buffer acquires new data, the other outputs processed data. This ensures continuous and uninterrupted spectral data acquisition and processing, effectively preventing time domain interruptions caused by data overflow and sampling pauses. The spectral data stream is standardized within the field-programmable gate array (FPGA), including sampling point serialization, wavelength quantization, and time-dimensional indexing. Each sampling point is assigned a number to establish a sampling point index system. Data from different wavelength bands are quantized and normalized at equal intervals to reduce the impact of wavelength drift. The data is then finely time-tagged by recording sampling timestamps, transforming the continuous, uninterrupted spectral data stream into a structured spectral dataset. Based on the three-dimensional arrangement logic of the number of sampling points I, the number of wavelength dimensions J, and the number of time series K, this structured spectral dataset is organized into a standardized three-dimensional array of I × J × K, forming a three-dimensional water spectral data cube.
[0016] Step 200: Perform anti-vibration wavelength calibration and ambient light source interference elimination processing on the water body spectrum three-dimensional data cube to obtain a pre-processed spectrum data set; Specifically, wavelength calibration is performed on the three-dimensional water spectral data cube. Using a preset rare earth element standard sample as a calibration reference, the characteristic peak positions generated by the standard sample are compared between the actual measurement results and the theoretical values. By constructing a correspondence table, all wavelength positions in the measured data are individually adjusted to eliminate wavelength deviations caused by equipment drift, temperature changes, or vehicle vibration, thereby obtaining wavelength-accurate spectral data. The wavelength-corrected spectral data is then compared point by point with a noise baseline signal collected in complete darkness. By subtracting background noise components, the system noise and background electromagnetic interference generated by the equipment itself are removed, resulting in a purified spectral signal. The Savitzky-Golay algorithm is used to perform scatter correction on the purified spectral signal. This algorithm uses the surrounding data as a reference within each small interval to generate a smooth curve that best fits the overall trend. This effectively eliminates random high-frequency noise and scattering effects caused by suspended particles in the water, while preserving the true characteristic changes corresponding to changes in water composition. After smoothing, the spectral curve is subjected to second-order variation feature extraction. This involves examining the rate of change of the spectral signal at different wavelengths to highlight the characteristic response caused by changes in water composition. This enhances the spectral signal's sensitivity to pollutant changes and effectively suppresses interference from spectral baseline drift and measurement background fluctuations, resulting in a water composition variation signature. To address abnormal sampling during vehicle operation, such as localized signal anomalies caused by road vibration or sudden changes in illumination, the processed water composition variation signature is then subjected to outlier identification and repair. Through holistic statistical analysis, outlier regions in the spectral curve that are significantly inconsistent with surrounding data are detected. These outliers are then smoothed and reconstructed based on the data trends of the surrounding normal areas, ensuring a continuous transition across the entire spectral curve at the outlier points, maximally restoring the original signal's expected shape and variation patterns. Dynamic light source compensation is then applied to the spectral data after repairing the outliers. During measurement, a reference optical signal is simultaneously acquired that does not pass through the water sample. The ratio of the reference signal to the actual water sample spectral signal is calculated to dynamically correct for fluctuations in external illumination intensity. This allows for real-time compensation for factors such as sunlight fluctuations, road reflections, and vehicle shadows, resulting in a preprocessed spectral dataset.
[0017] Step 300: Performing standardized multivariate decomposition processing and horizontal local constrained optimization of pollutant target bands on the pre-processed spectral data set to obtain enhanced characteristic fingerprint spectra for different types of water pollutants; It should be noted that the preprocessed spectral dataset is input into the canonical multivariate decomposition processing module, which performs a kernel consistency evaluation on the data as a whole based on the tensor structure of the spectral data. By gradually setting different decomposition ranks, the consistency index between the decomposition results and the original data is calculated respectively. When the consistency change obtained by two consecutive improvements is lower than the set convergence threshold, the optimal decomposition rank is determined. Based on the optimal decomposition rank and the canonical multivariate decomposition processing module, the factor matrix of the preprocessed spectral dataset is initially generated. Based on the random initialization strategy, the initial sample factor matrix, initial wavelength factor matrix and initial time factor matrix are generated for the sample dimension, wavelength dimension and time dimension respectively. The elements in each matrix are generated with initial values according to uniform distribution or Gaussian distribution to ensure that the entire decomposition process can achieve rapid convergence based on a full exploration of the solution space. These three sets of initial factor matrices are simultaneously input into the alternating least squares algorithm module for optimization. During each iteration, two of the factor matrices are fixed and only the third is updated. The values of each matrix element are gradually optimized by minimizing the current reconstruction error. After each update, the roles of the fixed matrix and the solution matrix are switched alternately. Iteration continues until the overall error converges to the set minimum level, resulting in the first sample factor matrix, the first wavelength factor matrix, and the first time factor matrix. The first sample factor matrix, the first wavelength factor matrix, and the first time factor matrix are regularized, that is, the amplitude range of each column or row in the matrix is standardized to avoid excessively large or small values. At the same time, a line search strategy is introduced, and the step size of each update is adaptively adjusted according to the downward trend of the error to ensure that the iterative process does not oscillate or converge to a suboptimal solution prematurely. Through this process, the second sample factor matrix, the wavelength factor matrix, and the time factor matrix are obtained. To accelerate the overall decomposition process, a parallel computing strategy is introduced at the hardware level. The update operations for different matrices are distributed to multiple processing cores or threads for simultaneous execution, thereby increasing computational speed and obtaining a set of three-dimensional factor matrices reflecting different water characteristics: the target sample factor matrix, the target wavelength factor matrix, and the target time factor matrix. Horizontal local constrained optimization of the pollutant target bands is performed on these three-dimensional factor matrices. Based on an existing pollutant spectral database, the key response band intervals for each type of pollutant are determined on the spectrum. A local weighting mechanism is then applied to these intervals. This assigns higher optimization weights to the corresponding target bands during the decomposition optimization process, enhancing the differences between pollutant signals and background signals. Multi-scale convolution processing and feature selection mechanisms are also combined to effectively enhance the prominence of pollutant features and suppress interference from irrelevant background noise. Through these steps, enhanced characteristic fingerprint spectra for different types of water quality pollutants are ultimately extracted from the spectral data.
[0018] In this embodiment, a target sample factor matrix, a target wavelength factor matrix, and a target time factor matrix are extracted from a three-dimensional factor matrix. The sample factor matrix describes the projected distribution of different water samples in the overall feature space, the wavelength factor matrix reveals the importance of each spectral band to the overall feature construction, and the time factor matrix reflects the dynamic changes at different sampling moments. To meet the requirements of pollutant feature extraction, characteristic band ranges are defined within the target wavelength factor matrix. The wavelength range of 254 to 280 nanometers is defined as the characteristic band for organic pollutants, used to capture the ultraviolet absorption characteristics of organic molecules; the wavelength range of 320 to 380 nanometers is defined as the characteristic band for heavy metal pollutants, used to capture the spectral response of heavy metal ions at specific energy level transitions; and the wavelength range of 400 to 490 nanometers is defined as the characteristic band for nutrient pollutants, used to characterize the changes in the visible light absorption characteristics of nutrients such as phosphorus and nitrogen. This forms a local constraint domain for the pollutant target band. Based on the pollutant target band constraint domain, a weighted multi-band optimization objective function is constructed. In this objective function, different bands are assigned different optimization weights based on their relevance to the pollutant class. The target sample factor matrix, target wavelength factor matrix, and target time factor matrix are jointly input into a variational autoencoder structure. The encoder module maps the high-dimensional factor data into a low-dimensional latent space, while the decoder module reconstructs the latent representation. During the reconstruction process, the difference between the original factor matrix and the reconstructed matrix is minimized. The robustness and generalizability of the features are improved by regularizing the latent space distribution, resulting in a robust pollutant feature representation. Multi-scale filtering technology is applied to the robust pollutant feature representation. Convolution operations are performed within the feature space using filter kernels of different receptive field sizes to extract feature information of different granularities, effectively capturing the spectral response characteristics of water pollutants at different scales. A feature weight matrix is calculated based on the feature information of different granularities. By introducing an attention mechanism, dynamically adjustable weights are assigned to features at each scale, enabling the system to adaptively focus on the most discriminative feature regions while suppressing background noise and irrelevant components, resulting in a feature vector with enhanced target features. The feature vectors of the enhanced target features are constrained for time dimension feature consistency. By comparing the feature vector change trends between adjacent sampling time points, the optimization strategy is automatically adjusted to ensure the continuity and smoothness of the same pollutant features on the time axis, avoiding feature drift or recognition errors due to short-term fluctuations, and ultimately obtaining enhanced feature fingerprint spectra for different types of water quality pollutants.
[0019] In this embodiment, different weight coefficients are applied to the characteristic band intervals corresponding to each pollutant in the target wavelength factor matrix. The wavelength range between 254 and 280 nanometers is defined as the characteristic band of organic pollutants, and the preset first weight is loaded in this area to highlight the spectral characteristics of organic pollutants in the ultraviolet region; the wavelength range between 320 and 380 nanometers is defined as the characteristic band of heavy metal pollutants, and the preset second weight is loaded in this area to enhance the energy level transition response of heavy metal elements; the wavelength range between 400 and 490 nanometers is defined as the characteristic band of nutrient salt pollutants, and the preset third weight is loaded in this area to enhance the sensitivity to the visible light absorption characteristics of nutrients such as nitrogen and phosphorus. Through a targeted weight loading strategy, a multi-band weighted feature matrix is effectively constructed. The multi-band weighted feature matrix is merged with the target sample factor matrix and the target time factor matrix, and a joint input feature vector is obtained through vector splicing or fusion operations. The joint input feature vector is fed into the encoding portion of the variational autoencoder model. Through a forward computation process, the originally high-dimensional and complex joint feature vector is compressed and mapped into a low-dimensional latent feature space. During the compression process, the encoder preserves key information as much as possible while effectively suppressing random noise, local perturbations, and abnormal fluctuations in the input data, resulting in a compressed latent feature representation. The decoding portion of the variational autoencoder then performs a reconstruction calculation on the latent feature representation, restoring the compressed latent vector back to the original feature space to obtain the initial reconstructed feature vector. The reconstruction loss is calculated by comparing the difference between the initial reconstructed feature vector and the original joint input feature vector. This loss reflects the effectiveness of the latent feature in preserving the original information. Furthermore, to guide feature learning, the performance of the reconstructed features in each key band is comprehensively evaluated in combination with the previously constructed weighted multi-band optimization objective function to form a feature optimization metric. According to the feature optimization index, feature enhancement operations are performed on the compressed latent feature representation. By adjusting the amplitude, sparsity or correlation of each feature component in the latent space, the output feature vector shows stronger discrimination and robustness in the key pollutant band. At the same time, it has higher noise resistance and stability in the overall feature space, forming a pollutant feature representation with enhanced robustness.
[0020] Step 400: Input the enhanced feature fingerprint spectrum into the deep belief network model to perform pollutant feature matching analysis to obtain multiple pollutant types and their corresponding concentration values in the water sample.
[0021] Specifically, the enhanced feature fingerprint spectrum is input into a deep belief network model, which uses a four-layer stacked restricted Boltzmann machine structure and is optimized through layer-by-layer unsupervised pre-training and global supervised fine-tuning. This allows it to establish a high-order mapping relationship between pollutant categories and feature spectra in a complex spectral feature space. Feature extraction, compression, and abstraction are sequentially completed through each layer of the restricted Boltzmann machine. Each layer of the network continuously improves the data's discriminative ability and abstraction level by learning the conditional probability distribution between features, ultimately forming a preliminary pollutant category mapping result at the output end, obtaining an initial feature mapping result. This result represents the various potential pollutants in the water sample in the form of a high-dimensional probabilistic feature space. Using a set of spectral basis functions consisting of Gaussian functions, Lorentzian functions, and Voigt functions, the initial feature mapping result is subjected to multiple modes of feature extraction. In this way, the spectral response is fitted and described from different line shapes, different widths, and different peak change angles, and the target pollutant spectrum feature vector is extracted. Quantitative calculations are performed based on the target pollutant spectral feature vectors. A compressed feature representation is obtained by normalizing and compressing various characteristics, such as the feature vector amplitude, distribution density, and variation trend. Multi-pollutant probability calculations are then performed on this compressed feature representation. Using the multi-class probability distribution mechanism in the output layer of the deep belief network, the probability of each pollutant being present in the water sample is predicted, forming a presence probability matrix covering all target pollutants. For pollutants with a presence probability greater than a preset threshold, concentration mapping is performed using a LASSO regression algorithm. Sparse modeling and parameter optimization are performed on the relationship between the target pollutant features and the actual concentration values in the feature space to avoid overfitting and variable redundancy, resulting in the initial concentration values for each pollutant. Spectral residual analysis and decision fusion are then performed based on the initial pollutant concentration values. The theoretical spectral curve generated by the predicted concentration is compared with the actual detected spectral curve. Residual analysis identifies model deviations. The initial prediction results are then combined with the residual information using a multi-source decision-making mechanism to ultimately determine the actual pollutant types and their corresponding concentrations in the water sample.
[0022] In this embodiment, an organic pollutant mapping subset, a heavy metal pollutant mapping subset, and a nutrient salt pollutant mapping subset are created based on the initial feature mapping results. For the organic pollutant mapping subset, a Gaussian function is used as a feature extraction tool for analysis and processing. Since organic pollutants exhibit symmetrical and smooth absorption peaks in the ultraviolet band, feature matching through the Gaussian function effectively captures key information such as peak position, peak width, and peak height, thereby extracting the dominant characteristics of organic pollutants in the spectral space and forming an organic pollutant feature vector. At the same time, for the heavy metal pollutant mapping subset, considering that heavy metal elements are accompanied by sharper and relatively asymmetric characteristic peaks in the spectral response, the Lorentzian function is used for feature extraction. By performing peak recognition, peak shape characterization, and width measurement on each characteristic peak, the spectral response characteristics corresponding to different heavy metal ions are effectively located and described, and the heavy metal pollutant feature vector is obtained. For the nutrient pollutant mapping subset, since its spectral response characteristics include both Gaussian expansion components and superimposed Lorentzian microstructure characteristics, a hybrid curve fitting using the Voigt function was used. By weighted fusion and adaptive fitting of the Gaussian and Lorentzian function characteristics, local anomalies were carefully characterized while maintaining overall profile accuracy, thereby extracting the main spectral characteristics of nutrient pollutants and obtaining the nutrient pollutant feature vector. The organic pollutant feature vector, heavy metal pollutant feature vector, and nutrient pollutant feature vector were combined and connected, that is, through vector cascade, to obtain the pollutant target spectral feature vector.
[0023] In the embodiment of the present application, the vibration interference problem in the vehicle environment is solved by the combined application of a multispectral sensor array, a four-point elastic support frame and a magnetorheological damper, ensuring the acquisition of stable and continuous spectral data during vehicle driving, and realizing the function of detecting while driving. The pure optical reagent-free detection mode is adopted to completely avoid the detection deviation caused by the uneven mixing of water and detection agent in the traditional vehicle-mounted water quality detection device, and fundamentally improve the reliability and consistency of the test results. By analyzing the three characteristic bands of spectral data at 254-280nm, 320-380nm and 400-490nm, this method can simultaneously detect organic pollutants, heavy metal pollutants and nutrient salt pollutants in water bodies, greatly improving the detection efficiency. Through pre-processing techniques such as wavelength calibration, dark signal subtraction, scattering correction and dynamic light source compensation, the ambient light changes and other background interferences are effectively eliminated, ensuring the consistency of the test results under various lighting conditions. The robust feature extraction method based on variational autoencoder and deep belief network, combined with multi-band constrained optimization and adaptive threshold technology, significantly enhances the recognition ability of low-concentration pollutants and expands the detection range. By performing pollutant feature matching analysis through a deep belief network model and combining it with the concentration mapping and decision fusion technology of the LASSO regression algorithm, not only can the type of pollutant be determined, but its concentration value can also be accurately quantified.
[0024] In a specific embodiment, the process of executing step 100 may specifically include the following steps: The original spectral signals of water samples are collected by the multispectral sensor array in the vehicle-mounted water quality detection device during the vehicle's driving process; Perform analog-to-digital conversion on the original spectral signal to obtain a spectral digital signal; A four-point elastic support frame and a magnetofluid damper are used to perform triaxial vibration suppression on the spectral digital signal to obtain stable spectral data that is resistant to vibration interference. The stable spectral data that is resistant to vibration interference is input into the field programmable gate array for parallel processing, and a continuous and uninterrupted spectral data stream is obtained through a double buffer mechanism; The continuous and uninterrupted spectral data stream is processed by sampling point serialization, wavelength dimension quantization and time dimension indexing to obtain a structured spectral data group; The structured spectral data set is organized according to the I×J×K dimension, where I represents the number of sampling points, J represents the wavelength dimension, and K represents the time series, to obtain a three-dimensional data cube of the water spectrum.
[0025] Specifically, a high-performance multispectral sensor array is integrated into the vehicle-mounted detection platform. This array covers the entire wavelength range from ultraviolet to visible light. The specific configuration selects fifteen equally spaced bandpass filters covering 220 to 720 nanometers. Each channel is equipped with a high-sensitivity photoelectric conversion element to ensure the simultaneous acquisition of the spectral response of water samples in different bands. At the same time, to cope with the inevitable vibration, acceleration changes, and fluctuations in the external lighting environment during vehicle driving, the sensor array is reinforced at multiple points and is simultaneously equipped with an ambient light monitoring sub-module to introduce compensation mechanisms in subsequent processing. In actual operation, when the vehicle is driving in different waters, the multispectral sensor array senses the spectral signals reflected or transmitted by the water in real time and outputs continuously changing analog voltage or current signals. These analog signals represent the absorption, reflection, and scattering characteristics of water at different wavelengths. The original analog spectral signal undergoes high-precision analog-to-digital conversion. A high-speed, high-precision analog-to-digital converter is configured at the sensor output, using a chip with 24-bit resolution and a sampling rate of at least 8,000 times per second. This ensures that the rapidly changing spectral signal during driving is meticulously captured and accurately digitized. After analog-to-digital conversion, the spectral digital signal is obtained. Vibration interference suppression is performed on the digital signal. When the vehicle travels under different road conditions, triaxial vibrations will cause micro-displacements in the sensor, which in turn induce slight drift or jitter in the spectral signal along the time and wavelength axes. A four-point elastic support is installed at the sensor array and its connection module. This layout introduces balanced force at the four corners of the sensor, and a magnetic fluid damper is superimposed to form a continuously adjustable viscous damping layer between the sensor and the support structure. This damping layer automatically adjusts its resistance according to changes in vibration amplitude, thereby achieving effective vibration energy absorption and attenuation in the three axes of the mechanical structure. Through the aforementioned mechanical and material designs, the first-order effects of vibration on signal output are significantly reduced at the physical level. At the same time, a real-time vibration status monitoring module is introduced into the data acquisition channel, and an adaptive filter is used to suppress noise within the vibration frequency range, thereby obtaining stable spectral data that is resistant to vibration interference. The stable spectral data that is resistant to vibration interference is input into a field-programmable gate array module on the vehicle platform. The field-programmable gate array has parallel processing capabilities and can synchronously decode, pre-process, and cache data from multi-channel sensors in real time. A double-buffering mechanism is used in the data processing flow. That is, while one buffer is collecting data, the other buffer performs data transmission and processing tasks. When the acquisition buffer is full, it quickly switches to ensure uninterrupted and delay-free data flow, improving the real-time and continuity of the system while avoiding frame loss or signal truncation caused by instantaneous data accumulation.The continuous and uninterrupted spectral data stream is standardized within the field programmable gate array (FPGA). Each set of collected data is numbered according to the sampling point sequence to implement sampling point serialization operations, ensuring that each sampling data unit has an independent and clear spatiotemporal identity. Each data unit is quantized in the wavelength direction, and the continuous wavelength range is divided into a fixed number of wavelength units using a unified discretization rule, for example, with a sampling interval of 10 nanometers, forming a standardized quantization matrix in the wavelength dimension. In the time dimension, each frame of spectral data is marked with a continuously increasing timestamp index, and time serialization processing is used to ensure the sequence and traceability of all data frames. After completing the above standardization and organization operations, all processed spectral data units are organized into a three-dimensional structure, with the number of sampling points as the first dimension, the number of wavelength discrete units as the second dimension, and the sampling time series number as the third dimension, to construct a standardized three-dimensional water spectral data cube.
[0026] In a specific embodiment, the process of executing step 200 may specifically include the following steps: Perform wavelength calibration on the three-dimensional data cube of water spectrum to obtain spectral data with wavelength accuracy correction; The purified spectral signal is obtained by performing difference calculation between the spectral data after wavelength accuracy correction and the noise baseline signal collected in the darkroom; The Savitzky-Golay algorithm is used to perform scattering correction on the purified spectral signal to obtain a smoothed spectral curve. The second-order derivative spectrum analysis is performed on the smoothed spectral curve to obtain the characteristics of water component changes. Outlier identification and local spectral reconstruction are performed on the water component change characteristics to obtain spectral data after repairing the abnormal area. Dynamic light source compensation is performed on the spectral data after repairing the abnormal area to obtain a preprocessed spectral dataset.
[0027] Specifically, wavelength calibration is performed on the three-dimensional water spectral data cube. To eliminate wavelength drift errors caused by temperature drift, mechanical wear, or vibration during long-term device use, a standard rare earth element sample is preset as a built-in reference source. By detecting the deviation of the characteristic absorption peak of the standard sample from the ideal theoretical position, the wavelength calibration in the actual measurement data is corrected point by point. The wavelength dimension of all data points in the entire spectral cube is uniformly calibrated to obtain wavelength-corrected spectral data. Noise purification is performed on the wavelength-corrected spectral data. During the system initialization phase, a baseline noise signal is collected in a completely darkroom environment. This darkroom data records the background noise, electrical interference, and system bias drift generated by the device itself in the absence of external light input. This darkroom baseline signal is used as a reference template and the difference between each frame of wavelength-corrected spectral data is calculated point by point. By subtracting the corresponding dark noise value at each wavelength channel, the inherent noise component of the device is eliminated, retaining only the true response information of the water sample to light, and thus obtaining the purified spectral signal. To address scattering interference in the spectral signal caused by physical factors such as suspended particles, impurities, and bubbles in the water, scattering correction is applied to the purified spectral signal. The Savitzky-Golay smoothing filter algorithm uses a polynomial fit to the original signal trend within each local window, replacing the original data points with the fitted curve. This smoothes out high-frequency noise and scattering artifacts while preserving the true absorption peaks and characteristic variations in the original spectrum. The sliding window size and the order of the fitting polynomial are dynamically adjusted based on the rate of change of the spectral signal, ensuring a smoothing effect that balances signal fidelity and noise suppression. After processing with the Savitzky-Golay algorithm, a smoothed spectral curve is obtained. Second-order derivative spectral analysis is performed on the smoothed spectral curve. By calculating the second-order rate of change for each spectral data point, subtle characteristic peaks are enhanced while effectively suppressing large-scale background variations. This highlights the subtle but significant spectral responses caused by changes in pollutant composition and identifies water composition variation signatures. Outlier identification and local spectral reconstruction are performed on these water composition variation signatures. Statistical analysis methods are used to evaluate the local mean and standard deviation of each characteristic curve, and outliers are identified based on pre-set anomaly criteria. For detected anomalous areas, interpolation and reconstruction methods based on surrounding normal data segments are used. Spline interpolation, local polynomial fitting, or weighted average interpolation are used to reconstruct the signal trend in the outlier area, ensuring that the repaired spectral data curve remains continuous, natural, and free of abrupt changes. Dynamic light source compensation is performed on the spectral data after repairing the anomalous area.By setting up a reference optical path, the signal changes of the reference channel and the sample channel are collected simultaneously, and the external light intensity change factor is calculated in real time through the change in the ratio of the two. Then, the amplitude of the sample signal is corrected, and the influence of the external light source intensity fluctuation on the measurement results is dynamically eliminated, and finally a preprocessed spectral data set is obtained.
[0028] In a specific embodiment, the process of executing step 300 may specifically include the following steps: The pre-processed spectral data set is input into the canonical multivariate decomposition processing module, and the canonical multivariate decomposition processing module performs kernel consistency evaluation and iterative calculation to obtain the optimal decomposition rank; Based on the optimal decomposition rank and normed multivariate decomposition processing module, the initial factor matrix of the preprocessed spectral dataset is randomly initialized to obtain the initial sample factor matrix, initial wavelength factor matrix and initial time factor matrix; Input the initial sample factor matrix, the initial wavelength factor matrix and the initial time factor matrix into the alternating least squares algorithm, and solve the third factor matrix by fixing the two factor matrices to obtain the first sample factor matrix, the first wavelength factor matrix and the first time factor matrix; Regularization and line search are performed on the first sample factor matrix, the first wavelength factor matrix, and the first time factor matrix to obtain a second sample factor matrix, a second wavelength factor matrix, and a second time factor matrix; and parallel calculation is performed on the second sample factor matrix, the second wavelength factor matrix, and the second time factor matrix to obtain a three-dimensional factor matrix group reflecting water body characteristics, the three-dimensional factor matrix group including a target sample factor matrix, a target wavelength factor matrix, and a target time factor matrix; Horizontal local constrained optimization of pollutant target bands is performed on the three-dimensional factor matrix group to obtain enhanced characteristic fingerprint spectra for different types of water quality pollutants.
[0029] Specifically, the preprocessed spectral data set is input into the canonical multivariate decomposition processing module, which is specially designed for the three-dimensional tensor data structure and can extract the most representative intrinsic factors while maintaining the original three-dimensional characteristics of the data: sampling points, wavelength, and time series. Through kernel consistency evaluation, a series of candidate decomposition rank values are set, and a rapid preliminary decomposition is performed on each candidate rank value. The data reconstruction error under the current decomposition is calculated, and the reconstruction error reduction rate is evaluated. When it is found that the amplitude of the reconstruction error reduction gradually tends to saturation after increasing the decomposition rank, that is, the new rank cannot significantly improve the reconstruction quality, the rank value corresponding to this time is selected as the optimal decomposition rank. Based on the optimal decomposition rank and the canonical multivariate decomposition processing module, the factor matrix of the preprocessed spectral data set is initially initialized. The initial factor matrix is randomly generated for the sample dimension, wavelength dimension, and time dimension respectively to ensure that the elements of each matrix are distributed within the set reasonable range, avoid information loss caused by excessive sparseness, and avoid numerical instability caused by excessive concentration. The initial sample factor matrix, initial wavelength factor matrix, and initial time factor matrix are obtained respectively. The initial sample factor matrix, initial wavelength factor matrix, and initial time factor matrix are input into the alternating least squares algorithm module, initiating the main loop of the canonical multivariate decomposition. In each iteration, two of the factor matrices are fixed, while only the third is updated. This optimization is then performed by minimizing the reconstruction error. The remaining factor matrices are then updated alternately, and this process is repeated until the overall reconstruction error drops below a preset threshold or the maximum number of iterations is reached. This alternating optimization process fully exploits the intrinsic correlations between the factor matrices, continuously approaching the optimal low-rank decomposition result, resulting in the first optimized sample factor matrix, wavelength factor matrix, and time factor matrix. Regularization is then performed on the first sample factor matrix, wavelength factor matrix, and time factor matrix. This involves normalizing or adjusting the magnitude of the vectors in each matrix to keep the norm within a reasonable range, thus avoiding numerical inflation or gradient explosion problems in subsequent calculations. Furthermore, to accelerate the overall optimization process and avoid falling into local optima, a line search mechanism is introduced. During each update step, the step size is dynamically adjusted based on the current descent direction and step size, ensuring that each update effectively reduces the overall reconstruction error, thereby improving convergence speed and the globality of the final result. After regularization and line search optimization, the second version of the sample factor matrix, wavelength factor matrix, and time factor matrix were obtained. To meet the high real-time requirements of large-scale spectral data in actual vehicle-mounted environments, parallel computing was implemented on the second version of the factor matrix group. By splitting and executing matrix operations of different dimensions simultaneously on multi-core processors or parallel acceleration units, the time required for overall decomposition was shortened while maintaining the consistency and coherence of each iterative update. Through parallel optimization, a set of three-dimensional factor matrices reflecting the multidimensional characteristics of the water samples was obtained, corresponding to the target sample factor matrix, target wavelength factor matrix, and target time factor matrix.Horizontal local constrained optimization of the pollutant target bands is performed on the three-dimensional factor matrix group. Based on the existing pollutant spectral database, the key characteristic intervals of organic pollutants, heavy metal pollutants, and nutrient pollutants in the wavelength dimension are determined respectively. A local weighting mechanism is set on these characteristic bands. That is, during the decomposition optimization process, higher optimization weights are assigned to data in the key bands, strengthening the expression intensity of the pollutant fingerprint characteristics in the decomposition results, while suppressing the background noise interference of non-target bands. Through multiple rounds of iterative correction, the optimal decomposition result that takes into account global accuracy and local sensitivity is continuously converged, and enhanced characteristic fingerprint spectra for different types of water quality pollutants are obtained.
[0030] In a specific embodiment, the execution step performs horizontal local constrained optimization of the pollutant target band on the three-dimensional factor matrix group to obtain enhanced characteristic fingerprint spectra for different types of water pollutants, which may specifically include the following steps: The target sample factor matrix, target wavelength factor matrix, and target time factor matrix are extracted from the three-dimensional factor matrix group. The 254-280nm wavelength range in the target wavelength factor matrix is defined as the characteristic band of organic pollutants, the 320-380nm wavelength range is defined as the characteristic band of heavy metal pollutants, and the 400-490nm wavelength range is defined as the characteristic band of nutrient salt pollutants, thereby obtaining the pollutant target band constraint domain. Construct a weighted multi-band optimization objective function based on the pollutant target band constraint domain; Based on a weighted multi-band optimization objective function and a variational autoencoder, a nonlinear mapping is performed on the target sample factor matrix, the target wavelength factor matrix, and the target time factor matrix to obtain a pollutant feature representation with enhanced robustness. Multi-scale filtering is performed on the robust pollutant feature representation to obtain feature information of different granularities. The feature weight matrix is calculated based on the feature information of different granularities, and the feature vector with enhanced target features is obtained through the attention mechanism. The feature vector of the target feature enhancement is constrained in time dimension to obtain enhanced feature fingerprint spectra for different types of water pollutants.
[0031] Specifically, a structured extraction is performed on the three-dimensional factor matrix group, sequentially separating the target sample factor matrix describing spatial distribution characteristics, the target wavelength factor matrix describing wavelength response characteristics, and the target time factor matrix recording temporal evolution characteristics. The target wavelength factor matrix is then partitioned into intervals based on the spectral response characteristics of the pollutants. The wavelength range of 254 to 280 nanometers is defined as the characteristic band for organic pollutants. This range primarily covers the ultraviolet absorption peaks of most organic pollutants and serves as the primary basis for identifying organic pollutants. The wavelength range of 320 to 380 nanometers is defined as the characteristic band for heavy metal pollutants. This band contains the characteristic energy level transition response of heavy metal ions and has high discriminative power. Furthermore, the wavelength range of 400 to 490 nanometers is defined as the characteristic band for nutrient pollutants, corresponding to the absorption characteristic changes of nitrogen and phosphorus nutrients in the visible light region. This forms a targeted pollutant target band constraint domain. Based on the pollutant target band constraint domain, a weighted multi-band optimization objective function is constructed. The objective function is designed to assign different optimization weight coefficients to the characteristic bands of organic pollutants, heavy metal pollutants, and nutrient pollutants. The organic pollutant band is given a higher weight due to its relatively weak signal, the heavy metal pollutant band is given a medium weight due to its clear peak, and the nutrient pollutant band is given a moderately increased weight due to its high background interference. Through the weight distribution mechanism, the optimization process can focus more on the key pollutant characteristic intervals, avoid the interference of irrelevant information on feature extraction, and improve the sensitivity and stability of the final model. Based on the weighted multi-band optimization objective function, the target sample factor matrix, target wavelength factor matrix, and target time factor matrix are jointly input into the designed variational autoencoder structure. In the encoder part, the original high-dimensional input is compressed and mapped to the low-dimensional latent space through nonlinear transformation, capturing the most discriminative intrinsic features. At the same time, the decoder part reconstructs the compressed latent features to ensure that the integrity and detailed changes of the pollutant fingerprint characteristics are preserved as much as possible during the dimensionality reduction process, resulting in a set of pollutant feature representations with strong robustness and high discriminability. Multi-scale filtering is performed on the robust pollutant feature representation. Filter banks with different receptive field sizes are applied in the feature space, including wide windows to capture global trends and narrow windows to enhance local details. Through a multi-scale information fusion strategy, the macroscopic distribution characteristics of pollutants are extracted and small but important fine-grained variations are identified, resulting in multiple sets of feature information covering different granularity levels. Based on the feature information extracted at different scales, a feature weight matrix is calculated. This means that by analyzing the importance and discriminative power of features at each scale, a dynamically adjustable weight coefficient is assigned to each set of features.By introducing an attention mechanism, the system constructs a correlation map between features and performs a weighted combination of features based on this. This allows the output target feature enhancement vector to highlight the most discriminative information and suppress background noise and irrelevant changes, thereby achieving adaptive enhancement and dynamic focusing of pollutant fingerprint features. The feature vectors of the target feature enhancement are constrained by time-dimensional feature consistency. By constraining the trend of feature changes between consecutive time points to ensure smoothness, the amplitude of feature changes at adjacent time points is required to conform to the natural evolution of water pollutants, avoiding drastic jumps or abnormal drift, and obtaining enhanced feature fingerprint spectra for different types of water pollutants.
[0032] In a specific embodiment, the execution step of performing nonlinear mapping on the target sample factor matrix, the target wavelength factor matrix, and the target time factor matrix based on the weighted multi-band optimization objective function and the variational autoencoder to obtain the pollutant feature representation with enhanced robustness may specifically include the following steps: Different weight coefficients are added to the characteristic band intervals in the target wavelength factor matrix, a preset first weight is added to the organic pollutant band, a preset second weight is added to the heavy metal pollutant band, and a preset third weight is added to the nutrient salt pollutant band, to obtain a multi-band weighted characteristic matrix; The multi-band weighted feature matrix is combined with the target sample factor matrix and the target time factor matrix to obtain a joint input feature vector; Performing forward calculation on the joint input feature vector through the encoding part of the variational autoencoder to obtain a compressed latent feature representation, and performing reconstruction calculation on the latent feature representation through the decoding part of the variational autoencoder to obtain an initial reconstructed feature vector; The reconstruction loss is calculated based on the initial reconstructed feature vector and the joint input feature vector, and the feature optimization index is calculated in combination with the weighted multi-band optimization objective function; The compressed latent feature representation is enhanced according to the feature optimization index to obtain the pollutant feature representation with enhanced robustness.
[0033] Specifically, different weight coefficients are added to the characteristic band intervals in the target wavelength factor matrix. The wavelength range of 254 to 280 nanometers is determined as the response region for organic pollutants. A preset first weight is added to this range to enhance the importance of the band characteristics in the overall feature optimization. Organic pollutants have weak but highly recognizable absorption characteristics in the ultraviolet band, so they are significantly amplified through a weighted strategy. The wavelength range of 320 to 380 nanometers is defined as the response region for heavy metal pollutants, and a preset second weight is added to this range. Considering that the spectral response of heavy metal ions is relatively obvious but the peak shape changes are complex, the weight setting needs to take into account both response intensity and morphology preservation. The wavelength range of 400 to 490 nanometers is determined as the response region for nutrient salt pollutants. A preset third weight is added to this range. Since nutrient salt substances have strong interference and superposition with background impurities, the characteristic weight is moderately enhanced to highlight their absorption characteristics. Through targeted weight loading, the target wavelength factor matrix has differentiated response intensities in different key regions, forming a multi-band weighted feature matrix. The multi-band weighted feature matrix is combined with the target sample factor matrix and the target time factor matrix. Within the feature vector space, wavelength features, sample features, and time features are concatenated or fused according to unified rules. Through feature concatenation, cross-dimensional splicing, or feature interaction encoding, a joint input feature vector is formed that contains triple information: spectral response, spatial distribution, and temporal variation. The joint input feature vector is then fed into a variational autoencoder (VAE). The encoder performs forward computation, compressing the high-dimensional joint feature vector into a low-dimensional latent feature space through a series of nonlinear transformation layers. During this process, the encoder strives to preserve as much key information as possible from the input features relevant to pollutant identification. The latent space modeling mechanism effectively suppresses noise, redundancy, and interference, resulting in a dense and highly discriminative compressed latent feature representation. The latent feature representation is then reconstructed by the VAE's decoding phase. The decoder's inverse nonlinear transformation process reconstructs an initial reconstructed feature vector from the latent space that is as close as possible to the original joint input feature vector. The reconstruction loss is calculated based on the initial reconstructed feature vector and the combined input feature vector, measuring the effectiveness of the latent feature representation in maintaining the integrity of the original information. The reconstruction effect is quantified by calculating the element-by-element difference, overall distance, or probability distribution difference between the two. Furthermore, combined with the previously defined weighted multi-band optimization objective function, a weighted evaluation of the reconstruction effect of each pollutant characteristic band is performed to form a comprehensive feature optimization index.According to the feature optimization index, feature enhancement processing is performed on the compressed latent feature representation. According to the importance information reflected in the feature optimization index, the amplitude, direction or correlation of each component of the latent feature vector is adjusted. Through weight adjustment, sparsity enhancement or feature selection mechanism, the final output latent feature representation has higher response intensity and lower redundant interference in the key pollutant feature area, forming a set of pollutant feature representations with enhanced robustness.
[0034] In a specific embodiment, the process of executing step 400 may specifically include the following steps: The enhanced feature fingerprint spectrum is input into the deep belief network model, and the pollutant category mapping is performed through the four-layer stacked restricted Boltzmann machine in the deep belief network model to obtain the initial feature mapping result; The spectral basis function set consisting of Gaussian function, Lorentzian function and Voigt function is used to extract the features of the initial feature mapping results and obtain the target spectrum feature vector of the pollutant. Quantitative calculations are performed based on the pollutant target spectral feature vectors to obtain a compressed feature representation, and multi-pollutant probability calculations are performed on the compressed feature representation to obtain the probability values of each type of pollutant in the water sample; Based on the LASSO regression algorithm, the concentration of pollutants with probability values greater than the preset threshold is mapped to obtain the initial value of the pollutant concentration; Spectral residual analysis and decision fusion are performed based on the initial values of pollutant concentrations to determine the various pollutant types and their corresponding concentration values present in the water samples.
[0035] Specifically, the enhanced feature fingerprint spectrum is input into a deep belief network model, which consists of four stacked layers of restricted Boltzmann machines. Each layer gradually abstracts and compresses the input feature information. In this process, the first layer of the restricted Boltzmann machine mainly captures the low-order local features of the enhanced feature fingerprint spectrum. The second layer integrates the information output by the first layer to extract mid-order correlation features. The third layer builds on this to capture deeper cross-band comprehensive features. The fourth layer performs high-order combination and summary of the complex feature relationships abstracted from the first three levels. Through layer-by-layer abstraction and compression, the key structure of the pollutant characteristics is retained to the greatest extent possible, while redundant information and measurement noise are effectively eliminated. The initial feature mapping result is obtained in the form of a highly dense and significantly discriminative feature vector. The initial feature mapping result is extracted using a spectral basis function set consisting of Gaussian, Lorentzian, and Voigt functions. For the characteristic segments of organic pollutants, since their absorption peaks present approximately symmetrical curves with moderate width, Gaussian functions are used for fitting and extraction. For heavy metal pollutants, since their spectral responses have sharp absorption characteristics and long tail extensions, Lorentzian functions are used for characteristic peak identification. For nutrient pollutants, the spectral characteristics of this type of component are mixed curves formed by the superposition of Gaussian characteristics and Lorentzian characteristics, so Voigt functions are used for mixed fitting and extraction. Through the classification and refinement of basis function processing, the feature extraction strategy is flexibly adjusted according to the characteristics of different types of pollutants to obtain the target spectral feature vectors of the pollutants. Quantitative calculations are performed on the target spectral feature vectors of the pollutants. Through operations such as feature scaling, normalization, and vector compression, the original high-dimensional feature vectors are mapped to a more compact feature subspace to form a compressed feature representation. Based on the compressed feature representation, multi-pollutant probability calculations are performed. The compressed features are input into a set of trained multi-class classifiers. Using a probability output mechanism, a probability of presence value is generated for each type of pollutant, reflecting the likelihood of the pollutant appearing in the current water sample. These probability values together form a pollutant presence probability vector, reflecting the distribution of each type of pollutant in the sample. Concentration estimation is performed for pollutants whose probability of presence is greater than a preset judgment threshold. A method based on the LASSO regression algorithm is introduced. Through sparse regression modeling technology, a robust mapping relationship is established between the compressed feature representation and the pollutant concentration value. LASSO regression can effectively suppress noise interference and automatically select the feature subset that contributes most to concentration prediction, thereby improving the accuracy of concentration prediction and the generalization ability of the model. After regression calculation, the initial concentration values of each pollutant that meets the presence conditions are obtained. Spectral residual analysis and decision fusion are performed based on the initial pollutant concentration values.Based on the initial concentration of each pollutant, the theoretical spectral curve is inferred and compared with the actual measured spectral data. The residual signal between the two is calculated. By analyzing the size of the residual and the pattern, potential abnormalities are identified. If the residual is within a reasonable range, the validity of the initial concentration prediction is confirmed. If the residual exceeds the set threshold, the concentration is corrected or misclassification is identified based on the residual information. At the same time, combined with the probability of the existence of multiple pollutants obtained in the early stage and the confidence index of each concentration prediction, through a decision fusion mechanism, the multiple results of probability information, concentration inference and residual analysis are comprehensively considered to obtain the various types of pollutants that are actually present in the water sample and their corresponding concentration values.
[0036] In a specific embodiment, the execution step uses a spectral basis function set consisting of a Gaussian function, a Lorentzian function, and a Voigt function to extract features from the initial feature mapping result to obtain the pollutant target spectral feature vector, which may specifically include the following steps: Based on the initial feature mapping results, an organic pollutant mapping subset, a heavy metal pollutant mapping subset, and a nutrient salt pollutant mapping subset are created; Perform feature matching on the organic pollutant mapping subset based on Gaussian function to obtain the organic pollutant feature vector; Based on the Lorentzian function, the characteristic peaks of the heavy metal pollutant mapping subset are identified to obtain the heavy metal pollutant characteristic vector; Based on the Voigt function, a mixed curve fitting is performed on the mapping subset of nutrient salt pollutants to obtain the nutrient salt pollutant feature vector; The characteristic vectors of organic pollutants, heavy metal pollutants and nutrient salt pollutants are combined and connected to obtain the target spectrum characteristic vector of the pollutant.
[0037] Specifically, the initial feature mapping results output by the deep belief network are targeted into subsets based on pollutant category characteristics. By retrieving the characteristic response values corresponding to different wavelength characteristic intervals in the initial feature mapping results, the portion of the spectral features located in the 254 to 280 nanometer range and having typical organic pollutant absorption characteristics is extracted and defined as the organic pollutant mapping subset. This data mainly reflects the overall characteristics of the energy absorption of organic components in the water body in the ultraviolet region. At the same time, the feature data in the 320 to 380 nanometer range and exhibiting sharp absorption peak characteristics are extracted to form the heavy metal pollutant mapping subset. This range includes the characteristic responses of common heavy metal ions such as lead, copper, and cadmium. The features with wavelength distribution in the 400 to 490 nanometer range and exhibiting complex absorption change patterns are extracted as the nutrient salt pollutant mapping subset. This part of the features is mainly related to the spectral changes caused by nutrients such as nitrogen and phosphorus in the water body. Through the above division, the initial complex spectral mapping results are organized into three independent subsets according to pollutant category. For the organic pollutant mapping subset, a Gaussian function is used for feature matching. Since organic pollutants present a symmetrical, smooth, and moderately wide absorption peak shape in the spectral response, the Gaussian function is suitable for describing such spectral characteristics due to its good symmetry and controllable width. In actual operation, for each spectral curve, a Gaussian curve is fitted within the target range of organic pollutants to find the parameter combination that best conforms to the actual data change trend, including peak position, peak height, and half-height width, to ensure that the fitting curve can accurately cover the original absorption peak shape, thereby extracting the organic pollutant characteristic vector representing the characteristics of the organic pollutant. This characteristic vector describes the response pattern of the organic component to the ultraviolet spectrum and has good discrimination and stability. At the same time, for the heavy metal pollutant mapping subset, the Lorentzian function is used to identify characteristic peaks. The spectral response peaks of heavy metal ions are sharper and have longer tails. The Lorentzian function is suitable for modeling and extracting the characteristics of heavy metal pollutants because it is steep near the central peak and exhibits a long tail extension away from the peak position. By fitting a Lorentzian function to each curve within the characteristic band of heavy metal pollutants, the characteristic absorption peaks of each heavy metal ion are located, and detailed parameters such as peak position, peak height, and tail expansion are extracted to generate a heavy metal pollutant characteristic vector. This characteristic vector effectively captures the differences in spectral responses of different metal elements, improving the accuracy and sensitivity of heavy metal pollutant classification. For the mapping subset of nutrient salt pollutants, a mixed curve fitting using the Voigt function is used.Since the spectral characteristics of nutrients contain the composite characteristics of Gaussian expansion and Lorentzian tail, the Voigt function formed by the convolution of Gaussian and Lorentzian functions is used to simultaneously model the expansibility of the central peak and the diffusion of the edge under a unified framework, thereby achieving high-precision fitting of complex spectral morphologies. In the actual processing process, for each characteristic curve belonging to nutrient pollutants, the optimal Voigt function parameter set is found by minimizing the fitting residual method, thereby extracting the nutrient pollutant feature vector that can accurately represent the characteristics of nitrogen and phosphorus substances. The organic pollutant feature vector, heavy metal pollutant feature vector and nutrient pollutant feature vector are combined and connected. The three sets of features are sequentially spliced into a unified pollutant target spectrum feature vector in a preset order.
[0038] The above describes the water quality pollutant detection method based on spectral analysis in the embodiment of the present application. The following describes the water quality pollutant detection system 10 based on spectral analysis in the embodiment of the present application. Figure 2 In one embodiment of the present application, a water pollutant detection system 10 based on spectral analysis includes: The data acquisition module 11 is used to collect real-time spectral data of water samples during the vehicle's driving process through the multispectral sensor array in the vehicle-mounted water quality detection device to obtain a three-dimensional data cube of the water spectrum; Interference elimination module 12, used for performing anti-vibration wavelength calibration and ambient light source interference elimination processing on the water body spectrum three-dimensional data cube to obtain a pre-processed spectrum data set; The constrained optimization module 13 is used to perform a standardized multivariate decomposition process and a horizontal local constrained optimization of the pollutant target band on the pre-processed spectral data set to obtain enhanced characteristic fingerprint spectra for different types of water pollutants; The matching analysis module 14 is used to input the enhanced feature fingerprint spectrum into the deep belief network model to perform pollutant feature matching analysis to obtain the various pollutant types and their corresponding concentration values present in the water sample.
[0039] Through the synergistic cooperation of the above-mentioned components, and the combined application of a multispectral sensor array, a four-point elastic support frame, and a magnetorheological damper, the problem of vibration interference in a vehicle-mounted environment is solved, ensuring the acquisition of stable and continuous spectral data while the vehicle is driving, and realizing the function of detection while driving. The use of a purely optical reagent-free detection mode completely avoids the detection deviation caused by the uneven mixing of water and detection agents in traditional vehicle-mounted water quality detection devices, fundamentally improving the reliability and consistency of the detection results. By analyzing the spectral data in the three characteristic bands of 254-280nm, 320-380nm, and 400-490nm, this method can simultaneously detect organic pollutants, heavy metal pollutants, and nutrient salt pollutants in water bodies, greatly improving the detection efficiency. Through pre-processing technologies such as wavelength calibration, dark signal subtraction, scattering correction, and dynamic light source compensation, ambient light changes and other background interference are effectively eliminated, ensuring the consistency of detection results under various lighting conditions. A robust feature extraction method based on a variational autoencoder and a deep belief network, combined with multi-band constrained optimization and adaptive thresholding techniques, significantly enhances the ability to identify low-concentration pollutants and expands the detection range. Pollutant feature matching analysis using a deep belief network model, combined with concentration mapping and decision fusion techniques using the LASSO regression algorithm, not only identifies pollutant types but also accurately quantifies their concentrations.
[0040] See also Figure 3 , Figure 3 This is a schematic block diagram of the structure of an electronic device 300 provided in an embodiment of the present application. The electronic device 300 includes a processor 301 and a memory 302. The processor 301 and the memory 302 are connected via a system bus 303, wherein the memory 302 may include a non-volatile storage medium and an internal memory.
[0041] The non-volatile storage medium can store a computer program. The computer program includes program instructions. When the program instructions are executed by the processor 301, the processor 301 can execute any of the above-mentioned water quality pollutant detection methods based on spectral analysis.
[0042] The processor 301 is used to provide computing and control capabilities to support the operation of the entire electronic device 300 .
[0043] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor 301, the processor 301 can execute any of the above-mentioned water quality pollutant detection methods based on spectral analysis.
[0044] Those skilled in the art will understand that Figure 3The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the electronic device 300 involved in the solution of the present application. The specific electronic device 300 may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0045] It should be understood that the processor 301 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0046] It should be noted that, those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the electronic device 300 described above can refer to the corresponding process of the aforementioned water pollutant detection method based on spectral analysis, and will not be repeated here.
[0047] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described systems, systems and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0048] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling an electronic device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program code.
[0049] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for detecting water pollutants based on spectral analysis, characterized in that: include: The multispectral sensor array in the vehicle-mounted water quality detection device collects real-time spectral data of water samples while the vehicle is driving, and obtains a three-dimensional data cube of the water spectrum; Performing anti-vibration wavelength calibration and environmental light source interference elimination processing on the water body spectrum three-dimensional data cube to obtain a preprocessed spectrum data set; Performing canonical multivariate decomposition processing and horizontal local constrained optimization of pollutant target bands on the preprocessed spectral data set to obtain enhanced characteristic fingerprint spectra for different types of water pollutants; The enhanced characteristic fingerprint spectrum is input into a deep belief network model for pollutant feature matching analysis to obtain multiple pollutant types and their corresponding concentration values present in the water sample.
2. The method for detecting water pollutants based on spectral analysis according to claim 1, characterized in that: The multispectral sensor array in the vehicle-mounted water quality detection device collects real-time spectral data of water samples during vehicle driving to obtain a three-dimensional data cube of water spectrum, including: The original spectral signals of water samples are collected by the multispectral sensor array in the vehicle-mounted water quality detection device during the vehicle's driving process; Performing analog-to-digital conversion on the original spectral signal to obtain a spectral digital signal; A four-point elastic support frame and a magnetic fluid damper are used to perform triaxial vibration suppression processing on the spectral digital signal to obtain stable spectral data that is resistant to vibration interference; Inputting the stable spectral data resistant to vibration interference into a field programmable gate array for parallel processing, and obtaining a continuous and uninterrupted spectral data stream through a double buffer mechanism; Performing sampling point serialization, wavelength dimension quantization, and time dimension indexing processing on the continuous and uninterrupted spectral data stream to obtain a structured spectral data group; The structured spectral data set is organized according to the I×J×K dimension, where I represents the number of sampling points, J represents the wavelength dimension, and K represents the time series, to obtain a three-dimensional data cube of the water body spectrum.
3. The method for detecting water pollutants based on spectral analysis according to claim 1, characterized in that: The anti-vibration wavelength calibration and ambient light source interference elimination processing are performed on the water body spectrum three-dimensional data cube to obtain a pre-processed spectrum data set, including: performing wavelength calibration on the three-dimensional data cube of the water body spectrum to obtain spectrum data after wavelength accuracy correction; The wavelength accuracy corrected spectral data is subjected to difference calculation with the noise baseline signal collected in the darkroom to obtain a purified spectral signal; Using the Savitzky-Golay algorithm to perform scattering correction on the purified spectral signal to obtain a smoothed spectral curve, and performing second-order derivative spectrum analysis on the smoothed spectral curve to obtain water component change characteristics; Outlier identification and local spectrum reconstruction are performed on the water component change characteristics to obtain spectral data after repairing the abnormal area, and dynamic light source compensation is performed on the spectral data after repairing the abnormal area to obtain a preprocessed spectral data set.
4. The method for detecting water pollutants based on spectral analysis according to claim 1, characterized in that: The pre-processed spectral data set is subjected to a canonical multivariate decomposition process and a horizontal local constrained optimization of the pollutant target band to obtain enhanced characteristic fingerprint spectra for different types of water pollutants, including: Inputting the preprocessed spectral data set into a canonical multivariate decomposition processing module, performing kernel consistency evaluation and iterative calculation through the canonical multivariate decomposition processing module to obtain an optimal decomposition rank; Based on the optimal decomposition rank and the canonical multivariate decomposition processing module, randomly initializing the initial factor matrix of the preprocessed spectral data set to obtain an initial sample factor matrix, an initial wavelength factor matrix, and an initial time factor matrix; Inputting the initial sample factor matrix, the initial wavelength factor matrix, and the initial time factor matrix into an alternating least squares algorithm, and solving the third factor matrix by fixing the two factor matrices to obtain a first sample factor matrix, a first wavelength factor matrix, and a first time factor matrix; Regularizing and line searching the first sample factor matrix, the first wavelength factor matrix, and the first time factor matrix to obtain a second sample factor matrix, a second wavelength factor matrix, and a second time factor matrix; and performing parallel calculations on the second sample factor matrix, the second wavelength factor matrix, and the second time factor matrix to obtain a three-dimensional factor matrix group reflecting water body characteristics, the three-dimensional factor matrix group including a target sample factor matrix, a target wavelength factor matrix, and a target time factor matrix; Horizontal local constrained optimization of pollutant target bands is performed on the three-dimensional factor matrix group to obtain enhanced characteristic fingerprint spectra for different types of water pollutants.
5. The method for detecting water pollutants based on spectral analysis according to claim 4, characterized in that: The performing of horizontal local constrained optimization of the pollutant target band on the three-dimensional factor matrix group to obtain enhanced characteristic fingerprint spectra for different types of water pollutants includes: Extracting a target sample factor matrix, a target wavelength factor matrix, and a target time factor matrix from the three-dimensional factor matrix group, respectively, and defining the 254-280nm wavelength range in the target wavelength factor matrix as a characteristic band for organic pollutants, the 320-380nm wavelength range as a characteristic band for heavy metal pollutants, and the 400-490nm wavelength range as a characteristic band for nutrient salt pollutants, thereby obtaining a pollutant target band constraint domain; Constructing a weighted multi-band optimization objective function according to the pollutant target band constraint domain; Based on the weighted multi-band optimization objective function and the variational autoencoder, nonlinear mapping is performed on the target sample factor matrix, the target wavelength factor matrix, and the target time factor matrix to obtain a pollutant feature representation with enhanced robustness; Performing multi-scale filtering on the robustness-enhanced pollutant feature representation to obtain feature information of different granularities, calculating a feature weight matrix based on the feature information of different granularities, and obtaining a feature vector with enhanced target features through an attention mechanism; The feature vector of the target feature enhancement is constrained in time dimension feature consistency to obtain enhanced feature fingerprint spectra for different types of water pollutants.
6. The method for detecting water pollutants based on spectral analysis according to claim 5, characterized in that: The method of performing nonlinear mapping on the target sample factor matrix, the target wavelength factor matrix, and the target time factor matrix based on the weighted multi-band optimization objective function and the variational autoencoder to obtain a pollutant feature representation with enhanced robustness includes: Loading different weight coefficients on the characteristic band intervals in the target wavelength factor matrix, loading a preset first weight on the organic pollutant band, loading a preset second weight on the heavy metal pollutant band, and loading a preset third weight on the nutrient salt pollutant band, to obtain a multi-band weighted characteristic matrix; Combining the multi-band weighted feature matrix with the target sample factor matrix and the target time factor matrix to obtain a joint input feature vector; Performing a forward calculation on the joint input feature vector through the encoding part of the variational autoencoder to obtain a compressed latent feature representation, and performing a reconstruction calculation on the latent feature representation through the decoding part of the variational autoencoder to obtain an initial reconstructed feature vector; Calculating a reconstruction loss based on the initial reconstruction feature vector and the joint input feature vector, and calculating a feature optimization index in combination with the weighted multi-band optimization objective function; Feature enhancement is performed on the compressed potential feature representation according to the feature optimization index to obtain a pollutant feature representation with enhanced robustness.
7. The method for detecting water pollutants based on spectral analysis according to claim 1, characterized in that: The enhanced feature fingerprint spectrum is input into the deep belief network model to perform pollutant feature matching analysis to obtain multiple pollutant types and their corresponding concentration values present in the water sample, including: Inputting the enhanced feature fingerprint spectrum into a deep belief network model, performing pollutant category mapping through a four-layer stacked restricted Boltzmann machine in the deep belief network model, and obtaining an initial feature mapping result; A spectral basis function set consisting of a Gaussian function, a Lorentzian function, and a Voigt function is used to perform feature extraction on the initial feature mapping result to obtain a target spectrum feature vector of the pollutant; Performing quantization calculation based on the pollutant target spectral feature vector to obtain a compressed feature representation, and performing multi-pollutant probability calculation on the compressed feature representation to obtain the existence probability value of each type of pollutant in the water sample; Performing concentration mapping on the pollutants whose existence probability values are greater than a preset threshold based on the LASSO regression algorithm to obtain an initial value of the pollutant concentration; Spectral residual analysis and decision fusion are performed based on the initial pollutant concentration value to determine multiple pollutant types and their corresponding concentration values present in the water sample.
8. The method for detecting water pollutants based on spectral analysis according to claim 7, characterized in that: The spectral basis function set composed of Gaussian function, Lorentzian function and Voigt function is used to extract features from the initial feature mapping result to obtain the pollutant target spectrum feature vector, including: Creating an organic pollutant mapping subset, a heavy metal pollutant mapping subset, and a nutrient salt pollutant mapping subset based on the initial feature mapping results; Performing feature matching on the organic pollutant mapping subset based on a Gaussian function to obtain an organic pollutant feature vector; Performing characteristic peak identification on the heavy metal pollutant mapping subset based on a Lorentzian function to obtain a heavy metal pollutant characteristic vector; Performing mixed curve fitting on the nutrient salt pollutant mapping subset based on the Voigt function to obtain a nutrient salt pollutant feature vector; The organic pollutant feature vector, the heavy metal pollutant feature vector and the nutrient salt pollutant feature vector are combined and connected to obtain a pollutant target spectrum feature vector.
9. A water pollutant detection system based on spectral analysis, characterized in that: Used to perform the water pollutant detection method based on spectral analysis according to any one of claims 1 to 8, the water pollutant detection system based on spectral analysis comprises: A data acquisition module is used to collect real-time spectral data of water samples while the vehicle is driving through the multispectral sensor array in the vehicle-mounted water quality detection device, and obtain a three-dimensional data cube of the water spectrum; An interference elimination module is used to perform anti-vibration wavelength calibration and environmental light source interference elimination processing on the water body spectrum three-dimensional data cube to obtain a preprocessed spectrum data set; A constrained optimization module is used to perform a canonical multivariate decomposition process and a horizontal local constrained optimization of the pollutant target band on the preprocessed spectral data set to obtain enhanced characteristic fingerprint spectra for different types of water pollutants; The matching analysis module is used to input the enhanced feature fingerprint spectrum into the deep belief network model to perform pollutant feature matching analysis to obtain the types of pollutants present in the water sample and their corresponding concentration values.
10. An electronic device, characterized in that: The electronic device comprises: a memory and at least one processor, wherein instructions are stored in the memory; The at least one processor calls the instructions in the memory to enable the electronic device to execute the water pollutant detection method based on spectral analysis as described in any one of claims 1 to 8.
Citation Information
Cited By
Method for detecting content of salidroside in rhodiola rosea extracting solution based on artificial intelligence
CN120741405A
Indoor pollutant emission concentration estimation method
CN120833870A
Multi-mode spectrum in-situ identification and drift self-adaption method for mine water pollutants
CN120992533A
In-situ multi-modal spectral identification and drift adaptive method for mine water contaminants
CN120992533B
Methane column concentration inversion method and system based on physically-driven variational auto-encoder
CN121027002A
