Hyperspectral imaging rapid detection method and system for soil available phosphorus content
By employing methods such as adaptive baseline correction, target-oriented orthogonal signal correction, and fractional-order differential transformation, combined with multi-scale dilated causal convolutional regression networks and environmental compensation, the problems of cumbersome procedures and insufficient environmental adaptability in soil available phosphorus detection have been solved, enabling rapid and accurate detection of soil available phosphorus content.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NANJING AGRICULTURAL UNIVERSITY
- Filing Date
- 2026-03-24
- Publication Date
- 2026-06-05
AI Technical Summary
Existing technologies for detecting available phosphorus in soil are cumbersome, time-consuming, and require a large amount of reagents. Furthermore, spectroscopic detection systems are inadequate in terms of targeted preprocessing capabilities, multi-level feature extraction, environmental adaptability, and specific capture of weak available phosphorus signals, making it difficult to meet the needs for rapid and accurate field testing.
A preprocessing method combining adaptive baseline correction, target-oriented orthogonal signal correction, and fractional-order differential transform, along with sparse Bayesian band selection using mutual information graph Laplace regularization, is employed to construct a multi-scale hollow causal convolutional regression network for phosphorus adsorption state sensing. Environmental compensation is then performed using Kubelka-Munk diffuse reflection theory, establishing a deeply coupled closed-loop collaborative architecture for detecting available phosphorus content in soil.
It significantly improves the extraction sensitivity and specificity of effective phosphorus weak signals, enhances detection accuracy and robustness, and can be applied in rapid field screening and batch laboratory testing, adapting to changes in different soil types and environmental factors.
Smart Images

Figure CN122150155A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of spectral analysis and intelligent detection technology, specifically relating to a rapid detection method and system for available phosphorus content in soil using hyperspectral imaging. Background Technology
[0002] Available phosphorus in soil is a core indicator for evaluating soil phosphorus supply capacity and guiding precision fertilization. Its content level directly affects the efficiency of phosphorus absorption by crop roots and the stability of agricultural yield. For a long time, the determination of available phosphorus in soil has mainly relied on chemical extraction methods, with the Olsen method and Bray-1 method being the most common. However, these chemical analysis methods all require multiple steps, including sample air-drying and grinding, reagent preparation, acid-base extraction, colorimetric reaction, and spectrophotometric measurement. The detection cycle for a single sample is usually no less than 24 hours. Furthermore, the extraction and colorimetric processes consume large amounts of chemical reagents such as sulfuric acid, hydrochloric acid, ammonium molybdate, and ascorbic acid, increasing laboratory operating costs and posing potential risks in wastewater treatment and environmental pollution. When facing application scenarios requiring rapid acquisition of soil phosphorus spatial distribution information in batches, such as regional soil fertility surveys or precision agriculture variable fertilization, the limitations of traditional chemical detection methods in terms of timeliness and economy become increasingly prominent. Furthermore, because chemical extraction methods have strict requirements for sample pretreatment conditions, there may be significant systematic biases in the analytical results between different operators. In addition, the waste liquid generated by traditional methods contains heavy metal ions and strong acid and alkali components, which require special waste liquid treatment processes before discharge, further limiting its promotion efficiency and environmental friendliness in large-scale soil surveys.
[0003] In recent years, visible to near-infrared spectroscopy has gained widespread attention in the field of soil nutrient detection due to its significant advantages of being non-destructive, rapid, and reagent-free. Hyperspectral imaging technology can simultaneously acquire spatial morphological and spectral reflectance information of soil samples within a timescale of seconds to minutes, providing a rich data foundation for establishing nutrient content prediction models. Chinese patent CN119779986A discloses an online soil organic carbon detection system based on spectral analysis. This system includes a soil detection module, a spectral acquisition module, a spectral preprocessing module, a spectral resampling module, and a data processing module. In terms of spectral preprocessing, the system denoises the original spectrum using a background noise estimation model; in terms of feature optimization, it interpolates and smooths the original spectral data using a spectral resampling model to reduce redundant information; in terms of quantitative modeling, the data processing module establishes a linear detection model based on wavelength-weighted summation. This system has achieved certain technical effects in spectral preprocessing and data redundancy elimination.
[0004] However, the above-mentioned scheme has the following technical shortcomings: First, the system detects soil organic carbon rather than available phosphorus. Available phosphorus does not have the same significant direct absorption characteristics as organic carbon in the visible to near-infrared bands. Its spectral response mainly comes from the indirect correlation effect between phosphate and iron and aluminum oxides in the soil matrix. Therefore, it places higher demands on the sensitivity and specificity of the preprocessing algorithm. Second, the linear weighted detection model used in this system is difficult to effectively capture the complex nonlinear mapping relationship between the spectral signal and the available phosphorus content. Especially in mixed sample sets with a large range of soil types, the generalization ability of the linear model will decrease significantly. Third, the system relies solely on spectral resampling for dimensionality reduction in the spectral feature extraction stage, failing to fully explore the differentiated information of spectral differential features at different orders, and also failing to consider the impact of the spatial texture heterogeneity of the soil surface on the detection results. Fourth, the system lacks a real-time compensation mechanism for interference factors such as soil moisture content and ambient temperature. In actual field testing, fluctuations in sample moisture content directly alter the intensity and position of the near-infrared water absorption peak, while changes in ambient temperature cause shifts in hydrogen bond vibration frequencies. The combined effect of these two factors leads to a significant systematic bias in the prediction results, severely hindering the widespread application of spectral detection technology from the laboratory to the field. Furthermore, most existing spectral modeling methods only consider one-dimensional spectral information, neglecting the potential auxiliary value of the heterogeneous texture features of soil sample surface spatial distribution for nutrient content prediction. They also lack a quantitative evaluation mechanism for the uncertainty of model prediction results, making it impossible for users to judge the reliability of the predicted values, further limiting the application and promotion of this technology in key agricultural decision-making scenarios. Therefore, how to construct a highly sensitive targeted preprocessing and multi-level feature extraction strategy for weak effective phosphorus signals, while simultaneously establishing a deep regression model with strong nonlinear fitting capabilities and physical constraint environmental compensation functions, has become a key technical problem urgently needing to be solved in the field of rapid spectral detection of effective phosphorus in soil. Summary of the Invention
[0005] To address the technical problems of existing methods for chemical detection of available phosphorus in soil being cumbersome, time-consuming, and requiring large amounts of reagents, as well as the shortcomings of existing spectroscopic detection systems in terms of targeted preprocessing capabilities, multi-level feature extraction, environmental adaptability, and specific capture of weak available phosphorus signals, this invention provides a rapid detection method and system for available phosphorus content in soil using hyperspectral imaging.
[0006] To achieve the above objectives, the present invention provides the following technical solution:
[0007] A rapid detection method for available phosphorus content in soil using hyperspectral imaging includes the following steps: Step S1, acquiring hyperspectral cube data of the soil sample in the visible to near-infrared band, performing adaptive baseline correction on the hyperspectral cube data to eliminate instrument response drift, and calculating the signal-to-noise ratio quality index of each spectral channel; Step S2, sequentially performing target-guided orthogonal signal correction and fractional-order differential transformation on the corrected hyperspectral cube data. Target-guided orthogonal signal correction uses the chemical analysis value of available phosphorus content as the target vector and removes spectral system variation components unrelated to available phosphorus content through orthogonal projection. Fractional-order differential transformation calculates fractional-order differential spectra sequentially within a continuous differential order range and stacks them along the differential order dimension to generate a phosphorus-response-enhanced multi-order differential feature matrix; Step S3, performing sparse Bayesian band selection processing based on mutual information graph Laplace regularization on the phosphorus-response-enhanced multi-order differential feature matrix, constructing a weighted graph of inter-band mutual information and utilizing it in the graph embedding space. Step S4: A sparse Bayesian regression with an automatic correlation determination mechanism is used to screen a subset of sensitive bands that are highly correlated with and complementary to the effective phosphorus content. Step S5: A multi-scale dilated causal convolutional regression network for phosphorus adsorption state perception is constructed. The first branch is a multi-scale dilated causal convolutional branch used to capture long-range spectral sequence dependencies, and the second branch is a deformable convolutional spatial branch used to adaptively extract the spatial distribution features of heterogeneous surface texture of the sample. The outputs of the two branches are fused by a bidirectional cross-attention fusion module to output the initial predicted value of effective phosphorus content. The network is also equipped with a phosphorus adsorption state classification auxiliary task head to impose physicochemical constraints on the shared encoding features by jointly predicting the phosphorus adsorption state type. The encoder's underlying parameters are obtained through pre-training on a large-scale soil spectral database. Step S6: A compensation mapping function based on the physical constraints of the fused Kubelka-Munk diffuse reflectance theory is used to dynamically correct the initial predicted value according to the real-time moisture content and ambient temperature parameters, and outputs the final value of effective phosphorus content, confidence interval, and quality control report. The above five steps not only form a forward data-driven serial processing link, but also form a complete deep-coupled closed-loop collaborative architecture through multiple backward feedback paths, such as the feedback of the band selection result in step S3 to optimize the selection of the differential order in step S2, the feedback of the gradient contribution in step S4 to refine the band subset in step S3, and the feedback of the signal-to-noise ratio evaluation in step S5 to trigger the light source calibration in step S1.
[0008] This invention also provides a rapid detection system for available phosphorus content in soil using hyperspectral imaging, used to execute the above-mentioned method. The system includes: a hyperspectral data acquisition and baseline correction module, an orthogonal signal correction and fractional differential feature extraction module, a graph-regularized sparse Bayesian sensitive band screening module, a phosphorus adsorption state sensing convolutional regression prediction module, and a physical constraint environment compensation and quality control output module. Each module corresponds one-to-one with the steps of the above method. Specifically, the output data of the hyperspectral data acquisition and baseline correction module serves as the input to the orthogonal signal correction and fractional differential feature extraction module. The phosphorus response-enhanced multi-order differential feature matrix output by the orthogonal signal correction and fractional differential feature extraction module is input to the graph-regularized sparse Bayesian sensitive band screening module. The sensitive band subset output by the graph-regularized sparse Bayesian sensitive band screening module is input to the phosphorus adsorption state sensing convolutional regression prediction module. The initial predicted value of available phosphorus content and the adsorption state type determination result output by the phosphorus adsorption state sensing convolutional regression prediction module are input to the physical constraint environment compensation and quality control output module for final correction.
[0009] The beneficial effects of this invention are as follows: First, by employing a three-level preprocessing chain of adaptive baseline correction combined with target-oriented orthogonal signal correction and fractional-order differential transformation, not only are spectral interferences caused by differences in soil sample particle size, moisture content, and instrument status eliminated, but orthogonal signal correction also selectively removes spectral variation components unrelated to available phosphorus content. Furthermore, fractional-order differential transformation captures the differentiated responses of phosphorus-related absorption characteristics at different orders in a continuous differential order space, significantly improving the extraction sensitivity and specificity of weak available phosphorus signals. Second, by using a sparse Bayesian band selection method based on mutual information graph Laplace regularization, the mutual information correlation between bands is modeled using a graph structure, and a joint optimization of band correlation and redundancy is achieved in the graph embedding space through an automatic correlation determination mechanism. Compared with traditional band selection methods, this method has stronger global optimal band combination search capabilities and higher screening robustness. Third, by combining a multi-scale dilated causal convolutional regression network for phosphorus adsorption state perception with a bidirectional cross-attention fusion mechanism and a phosphorus adsorption state classification auxiliary task head, deep collaborative modeling of spectral features and spatial texture features is achieved. The dilated causal convolution expands the spectral receptive field without increasing the number of parameters, the deformable convolution adaptively matches non-uniform soil texture, the bidirectional cross-attention enables full interaction of information from the two modalities, and the auxiliary task head constrains the rationality of feature representation from a physicochemical perspective, significantly improving the accuracy and robustness of effective phosphorus content prediction. Fourth, by fusing a Gaussian process regression compensation model with theoretical physical constraints from Kubelka-Munk diffuse reflectance theory and a transfer learning strategy, the risk of overfitting in small samples and systemic bias caused by environmental factors are effectively mitigated, making the detection system suitable for both rapid field screening and batch laboratory testing. Attached Figure Description
[0010] Figure 1 This is a flowchart illustrating the rapid detection method for available phosphorus content in soil using hyperspectral imaging, as provided in this embodiment of the invention.
[0011] Figure 2 This is a schematic diagram of the architecture of the rapid detection system for available phosphorus content in soil using hyperspectral imaging provided in an embodiment of the present invention. Detailed Implementation
[0012] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0013] See Figure 1 This invention provides a rapid detection method for available phosphorus content in soil using hyperspectral imaging. The method constructs a complete processing chain from raw hyperspectral data acquisition to final available phosphorus content correction output, specifically including five core steps from S1 to S5. These steps form a deeply coupled closed-loop collaborative architecture of forward data-driven and backward parameter feedback. Specifically, step S1 is responsible for acquiring high-quality raw data and eliminating baseline interference; step S2 further purifies and enhances phosphorus response characteristic information through targeted orthogonal correction and multi-order differential transformation; step S3 achieves joint optimal dimensionality reduction of the feature space through graph-structure-constrained sparse Bayesian band selection; step S4 utilizes a deep learning network for phosphorus adsorption state sensing to establish a high-precision nonlinear mapping model between the spectral spatial signal and available phosphorus content; and step S5 ensures the field applicability and reliability of the detection results through physical constraint environmental compensation and uncertainty quantification.
[0014] Step S1: Hyperspectral cube data acquisition and adaptive baseline correction preprocessing.
[0015] In one embodiment of the present invention, a pushbroom hyperspectral imager is first used to scan the soil sample to be tested line by line to acquire hyperspectral cubic data in the visible to near-infrared band. Preferably, the acquisition band range is set to 400nm to 2500nm, and the spectral resolution is 3nm to 10nm. In this embodiment, a spectral resolution of 5nm is preferred, corresponding to approximately 420 spectral channels. The spatial resolution is set to 0.1mm to 0.5mm, and in this embodiment, 0.2mm is preferred. The hyperspectral cubic data acquired in this way can be represented as a three-dimensional tensor X∈R (H×W×B)Where H is the number of spatial rows, W is the number of spatial columns, and B is the number of spectral channels. In the specific configuration of this embodiment, H=256, W=320, and B=420. During the acquisition process, the light source of the imager needs to be preheated and stabilized for no less than 15 minutes to ensure that the fluctuation range of the light source output power is less than 0.5%. In addition, before acquiring each batch of samples, a white reference image Iw and a dark reference image Id need to be acquired using a standard white board and a dark current baffle, respectively, and the reflectance normalization correction is performed on the original acquired data accordingly. The calculation formula is:
[0016] ,
[0017] in: For the first The reflectivity value of the channel is dimensionless and ranges from 0 to 1; The original acquired signal strength is expressed in DN (Digital Number), with a value range of 0 to 65535 (corresponding to a 16-bit quantization depth). White reference signal; This is the dark current signal. The normalization process eliminates the effects of light source non-uniformity and detector response differences.
[0018] After acquiring the raw hyperspectral cubic data, adaptive baseline correction processing is required to eliminate spectral baseline shifts caused by factors such as instrument dark current drift, light source aging attenuation, and detector response inhomogeneity. In this embodiment of the invention, the adaptive baseline correction processing employs an asymmetric least squares (ALS) smoothing algorithm, whose core optimization objective function is:
[0019] ,
[0020] in: The estimated baseline vector has dimension . ; For the first The original reflectance values of each spectral channel; For the first Baseline estimates for each spectral channel; For the first The asymmetric penalty weights for each spectral channel, when hour ,when hour The asymmetric penalty weight parameter The value range is from 0.001 to 0.1, and in this embodiment, it is preferred. This value makes the baseline estimation tend to fit the lower envelope of the spectral signal, thereby effectively separating the useful absorption features; The smoothness parameter controls the smoothness of the baseline curve, and its value ranges from [value range missing]. to In this embodiment, it is preferred that... This value strikes a balance between avoiding excessive baseline oscillations and preserving the characteristics of a wide absorption band. The second-order difference operator for the baseline vector is used to constrain the curvature of the baseline curve. The above optimization problem is solved using the sparse matrix Cholesky decomposition method. It can be solved quickly within the time complexity.
[0021] It is worth noting that the adaptive characteristic in this invention is reflected in the weight iterative update mechanism during the baseline fitting process: after each round of baseline estimation, the penalty weights are automatically updated based on the positive and negative relationships of the current residual signals. The iterations are repeated until the baseline converges or the maximum number of iterations is reached (15 in this embodiment). The corrected spectral signal is represented as follows: Preferably, after baseline correction is completed, the signal-to-noise ratio (SNR) quality index is also calculated for each spectral channel. The signal-to-noise ratio is calculated by using the spectral standard deviation of adjacent spatial pixels in the region of interest as noise estimation and the mean as signal estimation. Channels with a signal-to-noise ratio lower than a preset threshold (200:1 in this embodiment) are marked as low-quality channels, and their selection weight is automatically reduced in the band selection of the subsequent step S3, thereby forming a feedforward quality control path from step S1 to step S3.
[0022] Step S2: Target-guided orthogonal signal correction combined with fractional-order differential transform for multi-order feature extraction.
[0023] After completing the adaptive baseline correction in step S1, the corrected hyperspectral cube data may still contain systematic spectral variations caused by factors such as uneven soil sample particle size, differences in surface roughness, and slight changes in the incident angle of light. These variations include both effective components related to available phosphorus content and interfering components unrelated to available phosphorus content. Traditional multivariate scattering correction (MSC) or standard normal variable transformation (SNV) only corrects based on the statistical distribution characteristics of the spectrum and cannot distinguish between the two types of components, posing a risk of inadvertently damaging the effective signal. To address this, this embodiment of the invention introduces the Orthogonal Signal Correction (OSC) method. Its core advantage lies in using the chemical analysis value of available phosphorus content as the target vector and selectively removing systematic variation components unrelated to the target from the spectral matrix through orthogonal projection, retaining only the spectral information related to the variation of available phosphorus content.
[0024] Specifically, let the corrected spectral matrix be... ,in The number of training samples. The number of spectral channels is ; the effective phosphorus content vector is . The unit is mg / kg. First, the partial least squares (PLS) algorithm is used... and A latent variable space is constructed between them, and the first latent variable score vector is extracted. ,in This is the PLS weight vector. Then calculate... Zhongyu Orthogonal component matrices:
[0025] ,
[0026] in: It is an orthogonal component matrix with dimension . This characterizes the systemic variation components in the spectral matrix that are independent of the available phosphorus content; The first latent variable score vector of PLS has dimensions of Finally, the spectral matrix after target-guided orthogonal signal correction is:
[0027] ,
[0028] Only the spectral information components highly correlated with the variation in effective phosphorus content are retained. Preferably, the extraction of the above orthogonal components can be performed iteratively in multiple rounds (two rounds in this embodiment) to fully remove multi-order orthogonal components. It should be noted that the core technical advantage of OSC lies in its targeting: unlike traditional MSC which only eliminates scattering interference, OSC directly uses effective phosphorus content as the target for orthogonal projection, and its correction effect has a clear chemometric orientation.
[0029] Based on the target-guided orthogonal signal correction, this embodiment of the invention further performs a fractional-order differential transformation to generate phosphorus-response-enhanced multi-order differential features. The core advantage of fractional-order differentiation lies in extending traditional integer-order differentiation (first-order and second-order differentiation) to any real order, enabling the revelation of the gradual changes in spectral absorption characteristics with extremely fine granularity between adjacent integer orders, and capturing intermediate state information neglected by integer-order differentiation. In this embodiment, the fractional-order differentiation is implemented using the Grunwald-Letnikov difference approximation algorithm, and its calculation formula is as follows:
[0030] ,
[0031] in: The value of denoted by is the differential order, which in this embodiment ranges from 0.5 to 2.5, with a step size of 0.1, for a total of 21 differential orders. For the first Each spectral channel wavelength The spectral reflectance value after OSC correction is dimensionless. The coefficients of the generalized binomial are defined as follows: ,in This is a gamma function.
[0032] The differential spectra of the OSC-corrected spectrum at all 21 differential orders are stacked along the differential order dimension to form a phosphorus-response-enhanced multi-order differential characteristic matrix. Each row of this matrix corresponds to the expansion vector of differential coefficients for a sample at 21 differential orders and all wavelength positions. It is worth noting that lower differential orders (e.g., 0.5 to 1.0) primarily enhance the characteristics of broad absorption bands (e.g., the broad absorption band of iron and aluminum oxides in the 800nm to 1100nm range), while higher differential orders (e.g., 1.5 to 2.5) amplify the curvature changes of narrow absorption peaks (e.g., the characteristic absorption peak of phosphate hydrate near 1020nm). The synergistic effect of these two methods provides a richer feature space for subsequent band selection, far exceeding the information dimensions of traditional methods. Particularly noteworthy is that the sensitive band selection results in step S3 can be fed back to the differential order selection in this step: after model training, the frequency of occurrence of the final selected sensitive bands at different differential orders is statistically analyzed, the weight of high-frequency orders is increased, and the differential spectra of these orders are calculated preferentially in subsequent detection batches, thus forming a closed-loop parameter optimization pathway from step S3 to step S2.
[0033] Step S3: Sparse Bayesian sensitive band screening based on mutual information graph Laplace regularization.
[0034] The phosphorus-responsive enhanced multi-order differential characteristic matrix obtained in step S2 The dimensionality is extremely high (in this embodiment it is 10 ... Directly using the effective phosphorus content (dimension 1) as input to a regression model not only incurs enormous computational costs but also easily introduces a large number of noise variables unrelated to the effective phosphorus content. Therefore, this invention proposes a sparse Bayesian band selection method based on mutual information graph Laplace regularization. This method transforms the band selection problem into a sparse regression problem in a graph embedding space, simultaneously optimizing the correlation between bands and the target variable, as well as the redundancy between bands. This overcomes the tendency of traditional sequential elimination methods such as CARS to get trapped in local optima.
[0035] Specifically, firstly, using the multi-order differential characteristic matrix Each column (total) (Column) represents the band nodes, and the calculation is performed for any two band nodes. and Normalized mutual information values between them:
[0036] ,
[0037] in: For band With band The normalized mutual information between the two bands ranges from 0 to 1. The closer it is to 1, the more redundant the information carried by the two bands is. The mutual information value is in units of nat (when using natural logarithms) or bit (when using base-2 logarithms). and bands and band The information entropy, with units consistent with mutual information. As edge weights, construct an inter-band mutual information weighted undirected graph. and the corresponding graph Laplace matrix ,in For degree matrix, It is an adjacency matrix.
[0038] Graph Laplace matrix Perform eigenvalue decomposition: Take the front The smallest non-zero eigenvalues corresponding feature vector Low-dimensional graph embedding representation constituting the band In this embodiment The values range from 30 to 50 dimensions. Within the graph embedding space, the effective phosphorus content is considered. As the target variable, a graph-embedded matrix Using the feature matrix, a sparse Bayesian regression model (SBL) is constructed. The correlation weights of each band are iteratively pruned using an Automatic Relevance Determination (ARD) hyperparameter update mechanism. :
[0039] ,
[0040] in: For the first The precision hyperparameter for each band ranges from 0 to... , The larger the value, the closer the correlation weight of that band is to 0, thus it will be automatically pruned. The posterior covariance matrix is the first... One diagonal element; The posterior mean vector is the first... Each element. A graph Laplace quadratic form regularization term is also introduced. Constraint graph embedding space for weight consistency of adjacent bands, where The graph regularization intensity coefficient has a value range of 1. to In this embodiment, it is preferred that... After 50 to 200 iterations (preferably 100 in this embodiment), the relevance weights are finally retained. Greater than the preset convergence threshold (in this embodiment, it is...) The bands of ) are used as a subset of sensitive bands. Number of sensitive bands Number of original bands 5% to 20%, in this embodiment approximately 10% of that is approximately 880 differential characteristic variables.
[0041] After filtering, based on the sensitive band subset Extract the corresponding spectral feature vectors from the OSC-corrected hyperspectral cube data. and spatial feature blocks centered on each pixel. ,in Each pixel corresponds to a spatial range of approximately 2.2mm × 2.2mm. The number of principal component channels after dimensionality reduction by principal component analysis (in this embodiment) The aforementioned spectral feature vector and spatial feature block are output together to step S4.
[0042] Step S4: Construction and transfer learning training of a multi-scale dilated causal convolutional regression network for phosphorus adsorption state sensing.
[0043] This step is the core innovation of the technical solution of this invention. Unlike existing technologies that employ standard one-dimensional / two-dimensional convolution or simple gating fusion modeling strategies, this invention constructs a multi-scale dilated causal convolutional regression network for phosphorus adsorption state perception. It processes spectral and spatial domain information through multi-scale dilated causal convolution branches and deformable convolutional spatial branches, respectively. A bidirectional cross-attention fusion module enables full bidirectional interaction between the two heterogeneous features. Furthermore, a phosphorus adsorption state classification auxiliary task head applies physicochemical constraints to the shared encoded features. Finally, a fully connected regression head outputs continuous predicted values of effective phosphorus content.
[0044] The input to the multi-scale dilated causal convolution branch is the spectral feature vector corresponding to the sensitive band subset. In one embodiment of the present invention, the network structure of this branch includes three cascaded one-dimensional dilated causal convolutional layers. The first layer has a dilation rate of... The kernel size is 3, the number of output channels is 32, and the stride is 1; the void ratio of the second layer is... The kernel size is 3, and the number of output channels is 64; the porosity of the 3rd layer is... The kernel size is 3, and the number of output channels is 128. The core technical advantage of dilated causal convolution lies in: through the exponential increase of the dilation rate (…). ), effectively experience the wild Speed varies with number of floors Exponential growth allows for coverage with only 3 layers. The receptive field of the [number] bands far exceeds the receptive field of only 7 bands covered by a standard 3-layer network with a kernel size of 3. Meanwhile, causality constraints are implemented by performing left-side zero padding on the left side of the input sequence, ensuring that the [number] bands have a larger receptive field. The output characteristics of the first band depend only on the first band. To the The input information of each band is used to maintain the causality of the spectral sequence. Each dilated causal convolution is followed by layer normalization and Gaussian error linear unit activation function (GELU), the expression of which is:
[0045] ,
[0046] in: The cumulative distribution function of the standard normal distribution; GELU is the Gaussian error function. Compared to ReLU and its variants, GELU provides a smooth, non-zero gradient transition, which helps improve the gradient flow and convergence properties of deep networks. A 1D max-pooling layer (with a pooling kernel size of 2) is applied after each of the first and second convolutional layers to reduce the feature dimension and enhance translation invariance.
[0047] The input to the deformable convolutional spatial branch is the spatial feature block corresponding to the sensitive band subset. In this embodiment, the branch comprises three cascaded two-dimensional deformable convolutional layers. Each deformable convolutional layer is additionally configured with an offset prediction subnetwork (consisting of one...). (Standard convolutional layer composition), used to learn the two-dimensional spatial offset of each sampling point of the convolutional kernel in the horizontal and vertical directions. ,in Let be the side length of the convolution kernel. For the first The offset of each sampling point. The output of deformable convolution is calculated using the following formula:
[0048] ,
[0049] in: To output the target location coordinates on the feature map; For standard The first convolution kernel A fixed offset for each sampling point; The learnable offset is the output of the offset prediction subnetwork, and its value range is in the real number domain. It is sampled at non-integer positions through bilinear interpolation. These are the convolution weights corresponding to the sampling points. The technical advantage of deformable convolution lies in the fact that the sampling positions of standard convolution kernels are fixed on a regular grid, while the particle aggregates and pore distribution on the surface of soil samples are often irregular in shape. Deformable convolution can more accurately match these irregular texture structures by adaptively adjusting the sampling positions, thereby extracting more discriminative spatial features. The output channels of the three deformable convolution layers are 32, 64, and 128, respectively. Each layer is followed by layer normalization and the GELU activation function. The first and second layers are each followed by... Max pooling layer.
[0050] After each branch completes its feature extraction, the two branches are compressed into one-dimensional feature vectors using global average pooling. Let the spectral feature sequence output by the multi-scale dilated causal convolution branch be... (in (where the sequence length is), the spatial features of the deformable convolution spatial branch output are (in and (This refers to the height and width of the spatial feature map). Both are then fed into a bidirectional cross-attention fusion module for full bidirectional information exchange.
[0051] Specifically, in the spectral to spatial direction: spectral features Generate spectral query matrix by linear projection The spatial features after flattening Spatial bond matrices are generated by linear projection. and spatial value matrix Then, the cross-attention output from the spectrum to the spatial direction is calculated by scaling the dot product attention:
[0052] ,
[0053] in In this embodiment, the dimension is the key vector. .
[0054] Symmetrically, in the spatial-to-spectral direction: spatial features are linearly projected to generate a spatial query matrix. The spectral features are linearly projected to generate a spectral bond matrix. and spectral value matrix Similarly, the cross-attention output from the spatial to the spectral direction is calculated by scaling the dot product attention. Finally, the cross-attention outputs from the two directions are concatenated along the feature dimension after being subjected to global average pooling: The fused feature vector is then obtained by reducing the dimensionality to 128 dimensions through a linear projection layer. .
[0055] The technical effect of this bidirectional cross-attention fusion mechanism is that: attention from the spectral to the spatial direction enables the spectral branch to query which texture regions in the spatial branch are most relevant to the current spectral absorption features, thereby enhancing the supplementation of spectral features by spatial context information; attention from the spatial to the spectral direction enables the spatial branch to understand the spectral chemical information corresponding to the current texture pattern, achieving full interaction and synergistic effect between the two modal information.
[0056] Fusion feature vectors Then, two task heads are input simultaneously. The first is the master regression head, containing two fully connected layers (128→64→1). The intermediate layers use the GELU activation function and Dropout layers (with a deactivation probability of 0.2). The output layer does not use an activation function and directly outputs the initial predicted value of the effective phosphorus content. The unit is mg / kg. The second is a phosphorus adsorption state classification auxiliary task head, which contains two fully connected layers (128→64→3). The output layer uses the Softmax activation function. The classification targets include three adsorption state types: calcium-bound phosphorus (Ca-P), iron / aluminum-bound phosphorus (Fe / Al-P), and organic phosphorus (Org-P). The technical significance of the auxiliary task head is that the spectral response mechanisms of phosphorus in different adsorption states in the near-infrared band are fundamentally different (for example, Ca-P is mainly reflected indirectly through the 2340nm absorption band of the calcium carbonate matrix, while Fe / Al-P is indirectly reflected indirectly through the dd electron transition absorption band of iron / aluminum oxide in the 900nm to 1100nm range). By jointly predicting the adsorption state type, the auxiliary task head forces the shared encoder to learn a physicochemically interpretable feature representation, thereby improving the prediction accuracy and generalization ability of the main regression task.
[0057] The entire network is trained using a joint loss function:
[0058] ,
[0059] in: The Huber loss function has a threshold parameter. mg / kg; The cross-entropy loss function; To assist in determining the task weighting coefficients, a dynamic weight balancing strategy is adopted: That is, dynamically adjust based on the ratio of the two losses. This ensures that the training progress of the two tasks remains synchronized.
[0060] In this embodiment of the invention, a transfer learning strategy is also introduced into the training of the network. Specifically, the encoder part of the network (i.e., the first two layers of the multi-scale dilated causal convolution branch and the first two layers of the deformable convolutional spatial branch) is first pre-trained using a large-scale soil spectral database (such as the LUCAS European Soil Spectral Database or the Chinese Soil Spectral Database) containing no less than 5000 soil spectral records. The pre-training task is a multi-class classification task of soil types (covering at least 6 types such as sandy soil, loam, and clay). The Adam optimizer is used for pre-training, with an initial learning rate of... The batch size is 64, and the training epochs are 100. After pre-training, the parameters of the first two layers of the encoder are frozen, and only the parameters of the third layer of the encoder, the bidirectional cross-attention fusion module, the master regression head, and the auxiliary classification head are fine-tuned. The fine-tuning learning rate is... , 50 rounds of training.
[0061] It is worth further explaining that the gradient signal lost by Huber in step S4 can also be back propagated to the band selection process in step S3: after training is completed, by calculating the gradient contribution of each input sensitive band to the network output, the bands with the lowest contribution ranking are removed and step S3 is triggered to perform a round of fine screening again, thus forming a closed-loop optimization path from step S4 to step S3.
[0062] Step S5: Output dynamic compensation correction and confidence interval quality control for temperature and humidity environment, which integrates the physical constraints of Kubelka-Munk diffuse reflection theory.
[0063] After obtaining the initial predicted value of effective phosphorus content output in step S4 Subsequently, in this embodiment of the invention, dynamic compensation correction of temperature and humidity environment with fusion physical constraints is performed to eliminate system prediction bias caused by the deviation of actual soil sample moisture content and detection environment temperature from model training conditions.
[0064] Unlike existing technologies that simply use multivariate linear functions or empirical formulas for compensation, this invention derives the equations governing the influence of moisture content changes on soil spectral scattering and absorption coefficients based on the Kubelka-Munk (KM) two-flow diffuse reflectance theory. The KM theory describes diffuse reflectance... With medium absorption coefficient and scattering coefficient The relationship between them:
[0065] ,
[0066] When soil moisture content As the temperature increases, the water film covering the particle surface reduces the scattering coefficient, while the enhanced absorption of water molecules near 1450 nm and 1940 nm increases the absorption coefficient. Both factors jointly affect the diffuse reflectance. This invention parameterizes the above physical relationships as functions of water content and temperature, and embeds them as prior mean functions into a Gaussian Process Regression (GPR) compensation model:
[0067] ,
[0068] in: The amount of compensation for prediction deviation is expressed in mg / kg. This is a physical prior mean function derived from KM theory, reflecting the water content. (unit %) and temperature (Unit: °C) Systematic physical effects on prediction bias; A zero-mean Gaussian process is used to fit residuals that the physical model fails to explain. The kernel function employs a radial basis function. ,in For signal variance, The length scale parameter is automatically optimized by maximizing the logarithmic marginal likelihood.
[0069] The calibration process of the compensation mapping function is as follows: Under 35 combinations of conditions with moisture content ranging from 5% to 35% (7 levels in total, each 5% level) and temperature ranging from 5℃ to 45℃ (5 levels in total, each 10℃ level), hyperspectral data of standard soil samples were collected, and steps S1 to S4 were performed to obtain initial predicted values. Simultaneously, corresponding chemical analysis reference values were obtained to calibrate the kernel function hyperparameters of the GPR model. This design allows the compensation mapping function to possess both the physical interpretability provided by KM diffuse reflection theory and the data-driven flexibility provided by Gaussian process regression.
[0070] In the actual testing process, the moisture content of the sample is collected in real time using a capacitive soil moisture sensor (measurement range 0% to 50%, accuracy ±2%) and a Pt100 platinum resistance temperature sensor (measurement range -20℃ to 60℃, accuracy ±0.3℃) integrated into the testing system. and ambient temperature Substitute into the compensation mapping function to calculate the deviation compensation amount. Thus, the final value of the corrected effective phosphorus content is obtained:
[0071] ,
[0072] Furthermore, in this embodiment of the invention, the confidence interval of the effective phosphorus content prediction value is calculated using the Monte Carlo random deactivation sampling (MC-Dropout) method: During the inference phase, the Dropout layer in the network is kept active (deactivation probability is 0.2), and at least 30 random deactivation forward inferences are performed on the same test sample to obtain a set of prediction values. ( ), calculate the mean of the set and standard deviation The confidence interval is calculated at a 95% confidence level as follows: .
[0073] Finally, the detection system automatically generates a quality control report, which includes: the spectral signal-to-noise ratio (in this embodiment, it is required to be no less than 200:1), anomaly sample identification (when the confidence interval width exceeds 30% of the predicted mean, it is marked as a high uncertainty sample), model applicability evaluation level (determined based on the Mahalanobis distance between the spectrum of the test sample and the spectral distribution of the training set), and the adsorption state type determination result (Ca-P / Fe / Al-P / Org-P) output by the phosphorus adsorption state classification auxiliary task head. The signal-to-noise ratio evaluation result in the quality control report can also be fed back to the data acquisition stage in step S1: when the signal-to-noise ratio of multiple consecutive samples is detected to be lower than the threshold, the system automatically triggers the light source intensity calibration and dark current recalibration process, thereby forming a closed-loop quality assurance path from step S5 to step S1.
[0074] See Figure 2 This invention also provides a rapid detection system for available phosphorus content in soil using hyperspectral imaging. This system is used to execute the methods described in the above method embodiments, including a hyperspectral data acquisition and baseline correction module, an orthogonal signal correction and fractional differential feature extraction module, a graph regularization sparse Bayes sensitive band screening module, a phosphorus adsorption state sensing convolutional regression prediction module, and a physical constraint environment compensation and quality control output module. The five modules form a sequentially cascaded pipeline architecture according to the data processing flow, and the back-end module dynamically controls the parameters of the front-end module through a feedback path.
[0075] The hyperspectral data acquisition and baseline correction module corresponds to step S1. This module is configured to acquire hyperspectral cubic data of the soil sample in the 400nm to 2500nm band and perform adaptive baseline correction processing on the hyperspectral cubic data using an asymmetric least squares smoothing algorithm. At the hardware level, this module integrates a pushbroom hyperspectral imager, a linear translation stage, a halogen lamp light source, and a standard whiteboard calibration component. Preferably, the imager has a spectral resolution of 5nm, a spatial resolution of 0.2mm, and a frame rate of at least 100 frames / s. At the software level, this module embeds an asymmetric least squares baseline estimation algorithm based on sparse matrix factorization, supporting real-time processing of single samples with a processing latency of no more than 200ms. The output of this module is connected to the input of the orthogonal signal correction and fractional differential feature extraction module via an internal data bus.
[0076] The orthogonal signal correction and fractional differential feature extraction module corresponds to step S2. This module is configured to sequentially perform target-guided orthogonal signal correction and fractional differential transformation processing on the baseline-corrected hyperspectral cubic data, outputting a phosphorus response-enhanced multi-order differential feature matrix. In the specific configuration of this embodiment, the OSC subunit of this module maintains a PLS latent variable space and orthogonal component projection matrix pre-computed based on the training set; the fractional-order micro-unit adopts a parallel computing architecture based on Grunwald-Letnikov difference, achieving a 21st-order differential spectrum calculation speed of less than 500ms per sample on an embedded GPU.
[0077] The graph-regularized sparse Bayesian sensitive band selection module corresponds to step S3. This module is configured to perform sparse Bayesian band selection processing based on mutual information graph Laplace regularization on the phosphorus-responsive enhanced multi-order differential feature matrix, selecting a subset of sensitive bands that are highly correlated with and complementary to the effective phosphorus content. The band selection results of this module are stored in non-volatile memory in the form of an index table. In batch detection mode, only one complete sparse Bayesian optimization process needs to be performed during the first calibration, and subsequent sample detections directly reuse the existing index table. The output of this module is connected to both the phosphorus adsorption state sensing convolutional regression prediction module and the orthogonal signal correction and fractional differential feature extraction module. The latter is a feedback path used to optimize the priority of differential calculations based on the differential order distribution of the sensitive bands.
[0078] The phosphorus adsorption state sensing convolutional regression prediction module corresponds to step S4. This module is configured to utilize a multi-scale dilated causal convolutional regression network for phosphorus adsorption state sensing. It extracts spectral and spatial features through multi-scale dilated causal convolution branches and deformable convolutional spatial branches, respectively. After fusion by a bidirectional cross-attention fusion module, it outputs the initial predicted value of effective phosphorus content and the determination result of phosphorus adsorption state type. The deep learning inference engine of this module is deployed and optimized based on TensorRT or ONNXRuntime, achieving an inference speed of less than 100ms per sample on a detection terminal equipped with an embedded GPU. Model parameters are stored in an INT8 quantized format, and the overall model size does not exceed 5MB. This module also integrates a model version management subunit, supporting remote updates of model parameters via wireless network.
[0079] The physical constraint environment compensation and quality control output module corresponds to step S5. This module is configured to dynamically correct the initial predicted value of available phosphorus content based on the real-time collected moisture content and ambient temperature parameters using a Gaussian process regression compensation mapping function that integrates the physical constraints of Kubelka-Munk diffuse reflection theory. It outputs the corrected final value of available phosphorus content, its corresponding confidence interval, and a quality control report. This module integrates a capacitive soil moisture sensor and a Pt100 platinum resistance temperature sensor, with a sensor acquisition frequency of 1Hz. The quality control report is output to the user terminal via a built-in micro-printer or wireless transmission module. The output of this module also establishes a feedback path with the hyperspectral data acquisition and baseline correction module. When the signal-to-noise ratio of continuously detected samples falls below a preset threshold, it automatically triggers the light source calibration and dark current recalibration procedures.
[0080] In summary, the rapid detection system for available phosphorus content in soil using hyperspectral imaging provided in this invention achieves a fully automated processing flow from raw hyperspectral data acquisition to environmental compensation and correction output through the collaborative work of five functional modules and a closed-loop feedback mechanism. At the system integration level, the five modules are interconnected via a unified data bus and control bus. The data bus is responsible for transmitting data payloads such as hyperspectral cubic data, multi-order differential feature matrices, sensitive band index tables, prediction results, and adsorption state classification labels. The control bus is responsible for transmitting synchronization signals, feedback commands, and status information between modules. The system's main controller employs a heterogeneous computing architecture combining an embedded ARM processor and a field-programmable gate array (FPGA). The entire system consumes no more than 50W of power and supports both AC mains power and lithium battery power supply modes, allowing for continuous operation for at least 4 hours in lithium battery mode. The end-to-end detection time for a single sample is no more than 3 seconds, the detection accuracy determination coefficient R² is no less than 0.88, and the repeatability relative standard deviation is no more than 5%, meeting the dual requirements of rapid field screening and batch laboratory testing.
[0081] To verify the effectiveness of the technical solution of this invention, 286 surface soil samples from three typical agricultural counties in the North China Plain were selected as experimental materials. The soil types covered three main categories: brown soil, alluvial soil, and brown loam. Available phosphorus content was determined by the Olsen method, ranging from 3.2 mg / kg to 128.7 mg / kg, with a mean of 38.6 mg / kg and a standard deviation of 26.3 mg / kg. All samples were randomly divided into a training set (200 samples), a validation set (43 samples), and an independent test set (43 samples) in a ratio of 7:1.5:1.5. The distribution of available phosphorus content among the three subsets showed no significant difference according to the Kolmogorov-Smirnov test. The phosphorus adsorption state was determined by the Hedley sequential extraction method and labeled as Ca-P, Fe / Al-P, and Org-P, with the three types accounting for approximately 42%, 35%, and 23% of the sample sets, respectively. Hyperspectral data acquisition was performed using a push-broom hyperspectral imager with a wavelength range of 400 nm to 2500 nm and a spectral resolution of 5 nm. The scanning speed was 30 lines / s, and the acquisition time for each sample was approximately 1.2 s.
[0082] Regarding preprocessing performance, four preprocessing strategies were compared: (a) direct input without preprocessing, (b) traditional MSC+CWT combined preprocessing, (c) OSC preprocessing alone, and (d) the OSC+FOD three-level preprocessing proposed in this invention. Partial least squares regression was used as a unified modeling method for fair comparison. The results showed that strategy (a) had a coefficient of determination (R²) of 0.52 and a root mean square error (RMSE) of 14.7 mg / kg on the independent test set; strategy (b) had an R² of 0.69 and an RMSE of 10.5 mg / kg; strategy (c) had an R² of 0.75 and an RMSE of 9.1 mg / kg; and strategy (d), i.e., the OSC+FOD three-level preprocessing strategy of this invention, had an R² of 0.82 and an RMSE of 7.5 mg / kg. The gradual superposition of each preprocessing level resulted in a stable improvement in accuracy, fully verifying the necessity of each link in the three-level preprocessing chain and the synergistic gain effect on the effective extraction of weak signals. It is particularly noteworthy that the R² increase from strategy (b) to strategy (c) (0.06) is greater than the increase from (a) to (b) (0.17 at half the level), indicating that the targeted orthogonal correction of OSC is significantly better than the general MSC correction in preserving effective phosphorus-specific signals.
[0083] Regarding band selection, the graph regularized sparse Bayesian method of this invention was compared with the traditional CARS, SPA, and LASSO methods. Under the unified input condition of using the OSC+FOD preprocessing of this invention, the number of sensitive bands retained by the four methods were CARS (62), SPA (28), LASSO (95), and the method of this invention (88), respectively, with corresponding R² values of 0.82, 0.76, 0.81, and 0.85 for the PLS modeling test set. The method of this invention achieved the highest R², while the average mutual information redundancy of the selected bands was only 0.23, significantly lower than CARS (0.41) and LASSO (0.38), verifying the effectiveness of graph Laplacian regularization in reducing band redundancy.
[0084] Regarding modeling methods, partial least squares regression, support vector machine regression, random forest regression, and the phosphorus adsorption state sensing multi-scale dilated causal convolutional regression network of this invention were compared. Under the unified input conditions of OSC+FOD three-level preprocessing and graph regularized sparse Bayesian band screening of this invention, the test set R² of partial least squares regression was 0.85 and RMSE was 6.9 mg / kg; the R² of support vector machine regression was 0.86 and RMSE was 6.5 mg / kg; the R² of random forest regression was 0.84 and RMSE was 7.1 mg / kg; while the phosphorus adsorption state sensing network of this invention had an R² of 0.88 and RMSE of 6.0 mg / kg without using transfer learning, which was further improved to R² of 0.91 and RMSE reduced to 5.3 mg / kg after using the transfer learning strategy. Compared with the best traditional method, support vector machine regression, the R² was improved by about 5.8% and the RMSE was reduced by about 18.5%. The results show that the multi-scale dilated causal convolutional architecture, combined with the bidirectional cross-attention fusion mechanism and the phosphorus adsorption state-assisted task head, can effectively tap the complementary gains of spectral and spatial information, while the transfer learning strategy significantly alleviates the overfitting problem under the condition of 200 training samples.
[0085] Furthermore, the contributions of each core component were verified in ablation experiments: R² was 0.87 when using only the multi-scale dilated causal convolution branch, 0.75 when using only the deformable convolution spatial branch, 0.88 when the two branches were simply spliced together without bidirectional cross-attention fusion, improved to 0.90 after using bidirectional cross-attention fusion, and further improved to 0.91 after adding a phosphorus adsorption state classification auxiliary task head, confirming that the bidirectional cross-attention mechanism and the auxiliary task head each contributed approximately 1 percentage point independently. In addition, replacing the deformable convolution with the standard convolution reduced R² from 0.91 to 0.89, and replacing the dilated causal convolution with the standard one-dimensional convolution reduced R² from 0.91 to 0.88, further verifying the adaptive modeling ability of deformable convolution for non-uniform soil texture and the ability of dilated causal convolution to capture long-range spectral dependencies.
[0086] Regarding the effect of environmental compensation, system robustness tests were conducted under varying conditions of moisture content from 15% to 30% and temperature from 10℃ to 35℃. Without environmental compensation, the standard deviation of the prediction bias was 9.2 mg / kg, and the mean absolute deviation was 7.8 mg / kg. After correction with traditional multiple linear compensation, the standard deviation of the bias decreased to 4.1 mg / kg, and the mean absolute deviation decreased to 3.3 mg / kg. After correction with Gaussian process regression compensation incorporating KM physical constraints as described in this invention, the standard deviation of the bias further decreased to 3.4 mg / kg, and the mean absolute deviation decreased to 2.7 mg / kg, representing further reductions of approximately 17.1% and 18.2% respectively compared to multiple linear compensation. These results indicate that the physical prior mean function provided by KM diffuse reflection theory can effectively supplement the extrapolation capability of pure data-driven models in sparse training data regions.
[0087] In terms of detection efficiency, the end-to-end processing time for a single sample from spectral acquisition to final result output is 2.1s on the embedded GPU platform (NVIDIA Jetson Orin NX) and 0.8s on the desktop GPU platform (NVIDIA RTX 3060). This is four orders of magnitude shorter than the 24 hours or more required for traditional Olsen chemical analysis, fully meeting the timeliness requirements for rapid screening in large-scale fields and high-throughput testing in laboratories. Regarding model lightweighting, the total number of network parameters after INT8 quantization is 1.5M, the model file size is 4.8MB, and the memory usage for a single forward inference on the embedded inference engine does not exceed 128MB. In terms of confidence interval evaluation, uncertainty quantification results based on MC-Dropout show that the coverage of 95% confidence intervals on the test set is 93.0%, close to the theoretical value of 95%, indicating that the confidence interval estimation has good calibration performance. In terms of phosphorus adsorption state classification, the auxiliary task head achieved an overall classification accuracy of 82.3% on the test set. The single-class F1 scores for Ca-P, Fe / Al-P, and Org-P were 0.86, 0.81, and 0.77, respectively, providing supplementary criteria for phosphorus speciation at the precision fertilization level.
[0088] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of the claims of the present invention.
Claims
1. A rapid detection method for available phosphorus content in soil using hyperspectral imaging, characterized in that, Includes the following steps: Step S1: Collect hyperspectral cube data of the soil sample to be tested in the visible to near-infrared band, perform adaptive baseline correction on the hyperspectral cube data to eliminate instrument response drift, and output the corrected hyperspectral cube data to step S2. Step S2: The hyperspectral cubic data after correction in step S1 are sequentially subjected to target-guided orthogonal signal correction and fractional differential transformation. Target-guided orthogonal signal correction uses the effective phosphorus content chemical analysis value as the target vector and removes spectral system variation components unrelated to the effective phosphorus content through orthogonal projection. Fractional differential transformation calculates fractional differential spectra step by step in the continuous differential order range and stacks them along the differential order dimension to generate a phosphorus response-enhanced multi-order differential feature matrix, which is then output to step S3. Step S3: Perform sparse Bayesian band selection processing based on mutual information graph Laplace regularization on the phosphorus response enhanced multi-order differential feature matrix generated in step S2, construct a mutual information weighted undirected graph between bands, and screen a subset of sensitive bands in the graph Laplace embedding space through sparse Bayesian regression with automatic correlation determination mechanism, and output the spectral feature vector and spatial feature block corresponding to the subset of sensitive bands to step S4; Step S4: Construct a multi-scale hollow causal convolutional regression network for phosphorus adsorption state perception. The first branch is a one-dimensional causal convolutional branch with increasing hole rate to capture long-range spectral sequence dependencies. The second branch is a deformable convolutional spatial branch to adaptively extract the spatial distribution features of sample surface texture. The outputs of the two branches are fused by a bidirectional cross-attention fusion module and then input into a fully connected regression head to output the initial predicted value of effective phosphorus content. The network is configured with a phosphorus adsorption state classification auxiliary task head to apply physicochemical constraints to the shared coding features. The encoder's low-level parameters are obtained through pre-training on a large-scale soil spectral database. Step S5: Obtain the real-time moisture content and ambient temperature parameters of the soil sample to be tested. Based on the compensation mapping function that integrates the physical constraints of the Kubelka-Munk diffuse reflection theory, dynamically correct the initial predicted value output in step S4, and output the final value of effective phosphorus content, the corresponding confidence interval, and the quality control report.
2. The rapid detection method for available phosphorus content in soil using hyperspectral imaging according to claim 1, characterized in that, In step S1, the acquisition band range of the hyperspectral cube data is 400nm to 2500nm, the spectral resolution is 3nm to 10nm, and the spatial resolution is 0.1mm to 0.5mm; the adaptive baseline correction processing adopts an asymmetric least squares smoothing algorithm, wherein the asymmetric penalty weight parameter ranges from 0.001 to 0.1, and the smoothness parameter ranges from 10 to the power of 4 to 10 to the power of 7. After baseline correction, the signal-to-noise ratio (SNR) quality index is calculated for each spectral channel. Channels with an SNR lower than a preset threshold are marked as low-quality channels and their weights are reduced in subsequent steps.
3. The rapid detection method for available phosphorus content in soil using hyperspectral imaging according to claim 1, characterized in that, In step S2, the target-guided orthogonal signal correction process is as follows: using the corrected spectral matrix of all training samples and the corresponding effective phosphorus content vector as input, a latent variable space is constructed through the partial least squares algorithm, and the component matrix orthogonal to the effective phosphorus content in the spectral matrix is calculated. The orthogonal component is subtracted from each spectrum to be processed to selectively retain spectral information that is only related to the variation of effective phosphorus content. The differential order of the fractional differential transformation ranges from 0.5 to 2.5, with a step size of 0.1, for a total of 21 differential orders. The fractional differential at each differential order is implemented using the Grunwald-Letnikov difference approximation algorithm. The differential spectra of the corrected spectrum at all 21 differential orders are stacked along the differential order dimension to form a phosphorus response-enhanced multi-order differential feature matrix.
4. The rapid detection method for available phosphorus content in soil using hyperspectral imaging according to claim 1, characterized in that, In step S3, the specific process of sparse Bayesian band selection based on mutual information graph Laplace regularization includes: using each column of the phosphorus response-enhanced multi-order differential feature matrix as band nodes, calculating the normalized mutual information value between any two band nodes as edge weights, and constructing a mutual information weighted undirected graph between bands and the corresponding graph Laplace matrix; performing eigenvalue decomposition on the graph Laplace matrix, and taking the eigenvectors corresponding to the first k smallest non-zero eigenvalues to form a low-dimensional graph embedding representation of the bands; constructing a sparse Bayesian regression model in the graph embedding space with effective phosphorus content as the target variable, iteratively pruning the correlation weights of each band through an automatic correlation determination hyperparameter update mechanism, and introducing a graph Laplace quadratic regularization term to constrain the consistency of weights of adjacent bands in the graph embedding space, and finally retaining bands with correlation weights greater than a preset convergence threshold as a subset of sensitive bands, with the number of sensitive bands being 5% to 20% of the original number of bands.
5. The rapid detection method for available phosphorus content in soil using hyperspectral imaging according to claim 1, characterized in that, In step S4, the multi-scale dilated causal convolution branch contains three cascaded one-dimensional dilated causal convolutional layers with dilation rates of 1, 2, and 4, kernel sizes of 3, and output channels of 32, 64, and 128, respectively. Each causal convolutional layer maintains the causal constraint of the spectral sequence by performing one-sided zero padding on the left side of the input sequence to ensure that the output depends only on information from the current and previous bands. Each layer is followed by a normalization layer and a Gaussian error linear unit activation function. The deformable convolutional spatial branch contains three cascaded two-dimensional deformable convolutional layers. Each deformable convolutional layer is additionally configured with an offset prediction subnetwork to learn the two-dimensional spatial offset of each sampling point of the convolutional kernel in the horizontal and vertical directions. The basic convolutional kernel size is 3×3, and the output channels are 32, 64, and 128, respectively. Each layer is followed by a normalization layer and a Gaussian error linear unit activation function.
6. The rapid detection method for available phosphorus content in soil using hyperspectral imaging according to claim 1, characterized in that, In step S4, the processing procedure of the bidirectional cross-attention fusion module is as follows: the spectral feature sequence output by the multi-scale dilated causal convolution branch is linearly projected to generate a spectral query matrix, the spatial features output by the deformable convolution spatial branch are linearly projected to generate a spatial key matrix and a spatial value matrix, and the cross-attention output from the spectrum to the spatial direction is calculated by scaling dot product attention. Simultaneously, spatial features are linearly projected to generate a spatial query matrix, and spectral features are linearly projected to generate a spectral bond matrix and a spectral value matrix. The cross-attention output from space to spectral direction is calculated by scaling dot product attention. The cross-attention outputs from the two directions are concatenated along the feature dimension and then dimensionality-reduced through a linear projection layer to obtain the fused feature vector.
7. The rapid detection method for available phosphorus content in soil using hyperspectral imaging according to claim 1, characterized in that, In step S4, the transfer learning and multi-task training strategy is executed as follows: the encoder part of the multi-scale hollow causal convolutional regression network is pre-trained using a large-scale soil spectral database containing no less than 5,000 soil spectral records. The pre-training task is soil type multi-classification or organic matter content regression. After pre-training, the parameters of the first two layers of the encoder are frozen, and only the parameters of the subsequent layers of the encoder, the fully connected regression head, and the phosphorus adsorption state classification auxiliary task head are fine-tuned. The classification targets of the phosphorus adsorption state classification auxiliary task head include three adsorption state types: calcium-bound phosphorus, iron-aluminum-bound phosphorus, and organic phosphorus. The auxiliary classification loss and the main regression loss are jointly optimized through a dynamic weight balancing strategy.
8. The rapid detection method for available phosphorus content in soil using hyperspectral imaging according to claim 1, characterized in that, In step S5, the process of establishing the compensation mapping function that integrates the physical constraints of the Kubelka-Munk diffuse reflection theory is as follows: Based on the Kubelka-Munk two-stream diffuse reflection theory, the influence equation of water content change on the soil spectral scattering coefficient and absorption coefficient is derived. This physical equation is then embedded as a prior mean function into the Gaussian process regression compensation model. Under multiple levels of water content (5% to 35%) and temperature (5℃ to 45℃), hyperspectral data and chemical analysis reference values of standard soil samples are collected to calibrate the kernel function hyperparameters of the Gaussian process regression model, so that the compensation mapping function has both the flexibility of data-driven approach and the interpretability of physical mechanism.
9. The rapid detection method for available phosphorus content in soil using hyperspectral imaging according to claim 1, characterized in that, In step S5, the confidence interval is calculated as follows: based on the Monte Carlo random inactivation sampling method of multi-scale dilated causal convolutional regression network, no less than 30 random inactivation forward inferences are performed on the same sample to be tested, and the mean and standard deviation of all inference results are statistically analyzed. The upper and lower limits of the effective phosphorus content prediction value are calculated according to the 95% confidence level. The quality control report includes the spectral signal-to-noise ratio index, abnormal sample identification, model applicability evaluation level, and the adsorption state type determination result output by the phosphorus adsorption state classification auxiliary task head.
10. A rapid detection system for available phosphorus content in soil using hyperspectral imaging, for performing the rapid detection method for available phosphorus content in soil using hyperspectral imaging as described in any one of claims 1 to 9, characterized in that, include: The hyperspectral data acquisition and baseline correction module is configured to acquire hyperspectral cube data of the soil sample to be tested in the visible to near-infrared band, and perform adaptive baseline correction processing on the hyperspectral cube data to eliminate instrument response drift. The orthogonal signal correction and fractional differential feature extraction module is configured to sequentially perform target-guided orthogonal signal correction and fractional differential transformation processing on the baseline-corrected hyperspectral cubic data, and output a phosphorus-response-enhanced multi-order differential feature matrix. The graph-regularized sparse Bayesian sensitive band selection module is configured to perform sparse Bayesian band selection processing based on mutual information graph Laplace regularization on the phosphorus response-enhanced multi-order differential feature matrix, and select a subset of sensitive bands that are highly correlated with and complementary to the effective phosphorus content. The phosphorus adsorption state sensing convolutional regression prediction module is configured to use a multi-scale dilated causal convolutional regression network for phosphorus adsorption state sensing. It extracts spectral and spatial features through multi-scale dilated causal convolutional branches and deformable convolutional spatial branches, respectively. After fusion by the bidirectional cross-attention fusion module, it outputs the initial predicted value of effective phosphorus content and the determination result of phosphorus adsorption state type. The physical constraint environment compensation and quality control output module is configured to dynamically correct the initial predicted value of effective phosphorus content based on the compensation mapping function that integrates the physical constraints of Kubelka-Munk diffuse reflection theory according to the real-time collected moisture content and ambient temperature parameters, and output the corrected final value of effective phosphorus content and its corresponding confidence interval and quality control report.