Soil heavy metal hyperspectral remote sensing inversion method and device, system and storage medium

By using a Transformer-based feature band selection method and an XGBoost model, the complexity and computational efficiency issues of feature band selection in soil heavy metal hyperspectral remote sensing inversion were resolved, achieving rapid and effective feature band identification and improved model accuracy.

CN121026989BActive Publication Date: 2026-07-24KUNMING UNIV OF SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
KUNMING UNIV OF SCI & TECH
Filing Date
2025-08-13
Publication Date
2026-07-24

AI Technical Summary

Technical Problem

Existing technologies for the selection of characteristic bands in soil heavy metal hyperspectral remote sensing inversion are computationally complex, unstable, and computationally expensive, making it difficult to quickly and effectively identify the characteristic bands of heavy metals, thus affecting the accuracy and efficiency of the model.

Method used

A Transformer-based feature band selection method was adopted, which uses fractional-order differential spectral transformation and self-attention mechanism, combined with multi-layer Transformer encoder and feature importance estimation, to screen out the hyperspectral feature bands of heavy metals in soil, and then uses XGBoost to build an inversion model.

Benefits of technology

It enables rapid and effective selection of feature bands, improves the accuracy and efficiency of quantitative inversion of soil heavy metal content by hyperspectral remote sensing, and provides technical support for deep learning algorithms in this field.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121026989B_ABST
    Figure CN121026989B_ABST
Patent Text Reader

Abstract

The application discloses a soil heavy metal hyperspectral remote sensing inversion method and device, system and storage medium, and comprises the following steps: acquiring indoor hyperspectral data, heavy metal copper content and hyperspectral remote sensing image spectral data; performing SG spectral smoothing on the indoor hyperspectral data after removing noise bands; correcting the hyperspectral image spectral data according to the indoor hyperspectral data after SG spectral smoothing processing; performing fractional order differential spectral transformation on the corrected hyperspectral image spectral data; inputting the heavy metal copper content as a dependent variable and the fractional order differential spectral transformed hyperspectral image spectral data as an independent variable into a Transformer feature selection framework; and using XGBoost to establish a soil copper content inversion model to verify the effectiveness of the Transformer feature selection. According to the technical scheme, the feature wave of the heavy metal can be quickly and effectively identified and extracted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of hyperspectral remote sensing inversion technology, and particularly relates to a method, apparatus, system, and storage medium for hyperspectral remote sensing inversion of heavy metals in soil. Background Technology

[0002] Heavy metals are highly toxic, non-degradable, and accumulate over long periods, enabling them to be transferred through the food chain and threatening human and ecosystem health. For example, while copper is an essential trace element for the human body, excessive copper accumulation can lead to gastrointestinal reactions such as nausea, abdominal pain, and diarrhea, as well as liver and kidney damage. Therefore, monitoring the concentration of heavy metals in soil is of great significance for pollution management and environmental remediation.

[0003] Hyperspectral remote sensing technology has become one of the effective techniques for rapidly assessing heavy metal pollution in soil due to its advantages such as non-destructive testing, wide coverage, and low cost. Hyperspectral data has nanometer-level spectral resolution and can provide rich spectral information, but this also leads to drawbacks such as spectral redundancy, numerous bands, and large data volume. Therefore, the selection of characteristic bands in hyperspectral data is crucial for improving model accuracy and computational efficiency. Traditional characteristic band selection methods include the Pearson correlation coefficient method (PCC), the competitive adaptive reweighting (CARS) algorithm, the iterative information-preserving variable (IRIV) algorithm, the continuous projection algorithm (SPA), the genetic algorithm (GA), and the Boruta algorithm. These methods have been proven effective in selecting hyperspectral characteristic bands for heavy metals in soil, but PCC struggles to capture nonlinear relationships; CARS is computationally complex and unstable; IRIV has a slow computation time; and the Boruta algorithm has high computational overhead and depends on parameter settings such as the number of iterations and random forest parameters. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a method, device, system and storage medium for the hyperspectral remote sensing inversion of heavy metals in soil, which can quickly and effectively identify and extract the characteristic bands of heavy metals, and provide new technical support for the characteristic band selection step in the hyperspectral remote sensing quantitative inversion process of heavy metal content in soil.

[0005] To achieve the above objectives, the present invention adopts the following technical solution:

[0006] A method for hyperspectral remote sensing inversion of heavy metals in soil includes:

[0007] Based on soil samples, indoor hyperspectral data and heavy metal copper content were obtained; and in-situ hyperspectral remote sensing image spectral data were extracted based on the sampling point coordinates.

[0008] After removing noisy bands from indoor hyperspectral data, SG spectral smoothing is performed.

[0009] The spectral data of the hyperspectral image were corrected based on the indoor hyperspectral data after SG spectral smoothing.

[0010] Perform fractional-order differential spectral transformation on the corrected hyperspectral image spectral data;

[0011] The content of heavy metal copper is used as the dependent variable, and the spectral data of the hyperspectral image after fractional differential spectral transformation is used as the independent variable and input into the Transformer feature selection framework. The Transformer feature selection framework is used to screen the hyperspectral feature bands of heavy metal copper content in soil.

[0012] A soil copper content inversion model was built using XGBoost to verify the effectiveness of Transformer feature selection.

[0013] Preferably, the spectral data of the hyperspectral image is corrected by the direct normalization DS algorithm using the indoor hyperspectral data after SG spectral smoothing as a reference.

[0014] As a preferred approach, the Transformer feature selection framework includes: input projection, positional encoding, multi-layer Transformer encoder, feature selection, feature importance estimation, and region selection; the loss functions of the Transformer feature selection framework include: reconstruction loss function, discriminative loss function, sparsity loss function, region equalization loss function, and diversity loss function.

[0015] The present invention also provides a soil heavy metal hyperspectral remote sensing inversion device, comprising:

[0016] The first processing module is used to obtain indoor hyperspectral data and heavy metal copper content based on soil samples; and to extract in-situ hyperspectral remote sensing image spectral data based on the sampling point coordinates.

[0017] The second processing module is used to perform SG spectral smoothing on indoor hyperspectral data after removing noise bands.

[0018] The third processing module is used to correct the spectral data of the hyperspectral image based on the indoor hyperspectral data after SG spectral smoothing.

[0019] The fourth processing module is used to perform fractional-order differential spectral transformation on the corrected hyperspectral image spectral data;

[0020] The fifth processing module is used to input the heavy metal copper content as the dependent variable and the hyperspectral image spectral data after fractional differential spectral transformation as the independent variable into the Transformer feature selection framework. The Transformer feature selection framework is used to screen the hyperspectral feature bands of soil heavy metal copper content.

[0021] The sixth processing module is used to build a soil copper content inversion model using XGBoost to verify the effectiveness of Transformer feature selection.

[0022] Preferably, the spectral data of the hyperspectral image is corrected by the Direct Normalization (DS) algorithm using the indoor hyperspectral data after SG spectral smoothing as a reference.

[0023] As a preferred approach, the Transformer feature selection framework includes: input projection, positional encoding, multi-layer Transformer encoder, feature selection, feature importance estimation, and region selection; the loss functions of the Transformer feature selection framework include: reconstruction loss function, discriminative loss function, sparsity loss function, region equalization loss function, and diversity loss function.

[0024] The present invention also provides a soil heavy metal hyperspectral remote sensing inversion system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes a soil heavy metal hyperspectral remote sensing inversion method when executed by the processor.

[0025] The present invention also provides a storage medium storing a computer program, which executes a method for hyperspectral remote sensing inversion of heavy metals in soil when running.

[0026] To effectively uncover global dependencies between bands and achieve efficient feature selection, this invention employs a Transformer-based hyperspectral feature band selection method. It utilizes a self-attention mechanism to model global dependencies between bands and automatically identifies the most discriminative band combinations through end-to-end training. This invention provides new technical support for the feature band selection step in the quantitative inversion process of soil heavy metal content using hyperspectral remote sensing, and offers case studies supporting the application of deep learning algorithms in the field of soil heavy metal hyperspectral remote sensing inversion. Attached Figure Description

[0027] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0028] Figure 1 This is a flowchart of the soil heavy metal hyperspectral remote sensing inversion method according to an embodiment of the present invention;

[0029] Figure 2 These are spectral curves before and after correction using the DS algorithm in this embodiment of the invention.

[0030] Figure 3 This is a fractional-order differential transform diagram in an embodiment of the present invention;

[0031] Figure 4 This is a training history diagram of the 1.0-order Transformer feature band selection model in this embodiment of the invention;

[0032] Figure 5 This is a full-spectrum feature importance distribution and region division diagram of the 1.0-order Transformer feature band selection in this embodiment of the invention;

[0033] Figure 6 This is a score map of the top 50 important bands selected for the 1.0 order Transformer feature bands in this embodiment of the invention; Detailed Implementation

[0034] 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. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0035] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0036] Example 1:

[0037] like Figure 1As shown, this invention provides a method for inverting soil heavy metals using hyperspectral remote sensing, including: collecting soil samples in the field, measuring indoor hyperspectral data and copper content of the soil samples, and extracting spectral reflectance data of the in-situ hyperspectral remote sensing image based on the sampling point coordinates. For the indoor hyperspectral data, noise bands are removed and SG spectral smoothing is performed. The hyperspectral image spectrum is corrected using the direct normalization (DS) algorithm with the indoor hyperspectral data as a reference. Subsequently, fractional-order differential spectral transformation is performed on the corrected image spectrum. The copper content is considered as the dependent variable, and the hyperspectral data is considered as the independent variable, inputting into the Transformer feature selection framework. In the Transformer framework, this invention designs modules such as input projection, position encoding, multi-layer Transformer encoder, feature selection, feature importance estimation, and regional selection. In addition, this invention proposes multiple loss functions, including reconstruction loss, discrimination loss, sparsity loss, regional equilibrium loss, and diversity loss function, to jointly optimize model parameters to achieve efficient, balanced, and interpretable feature band selection. Finally, XGBoost is used to establish a soil copper content inversion model to verify the effectiveness of Transformer feature selection. Specifically, the following steps are included:

[0038] Step 1: Collect soil samples in the field, measure the spectral reflectance data of the soil and the content of heavy metal copper in the laboratory, and extract the spectral reflectance data of the in-situ hyperspectral remote sensing image based on the coordinates of the sampling points.

[0039] Step 2: Remove bands with significant noise interference from the hyperspectral reflectance data;

[0040] Step 3: Perform SG convolution smoothing on the soil spectrum after removing noise interference bands. The smoothed data is used as the original spectrum, and the hyperspectral image spectrum is corrected by the Direct Normalization (DS) algorithm with indoor hyperspectral data as a reference.

[0041] Step 4: Perform fractional derivative transform on the corrected spectral data to highlight spectral features;

[0042] Step 5: Use the network framework based on the Transformer algorithm proposed in this invention to screen the hyperspectral characteristic bands of soil heavy metal copper content;

[0043] Step 6: Establish a hyperspectral prediction model for copper content using the XGBoost method, and verify its accuracy and stability.

[0044] As one embodiment of the present invention, Step 1 specifically comprises:

[0045] Several soil samples were collected in the field, and the latitude and longitude coordinates of each point were recorded using GPS. Each sample weighed 500-1000g. The soil samples were transported back to the laboratory and spread out to air dry naturally, avoiding direct sunlight. After air drying, the soil was ground through a 100-mesh nylon sieve, retaining about 100g of soil powder. The processed soil powder was divided into two parts: one part was used for indoor soil spectral reflectance data measurement (using a ground object spectrometer ASD), and the other part was used to determine the content of heavy metal copper (using a handheld fluorescence spectrometer).

[0046] Download concurrent hyperspectral remote sensing images and perform preprocessing such as radiometric correction, atmospheric correction, and orthorectification to remove bad bands from the images. Extract in-situ hyperspectral reflectance data based on GPS coordinates.

[0047] As one embodiment of the present invention, the spectral range with greater noise interference in Step 2 is specifically as follows:

[0048] The spectral range measured by the ASD ground object spectrometer is typically 350-2500 nm. However, noise interference is usually significant in the 350-399 nm and 2451-2500 nm ranges, so spectral reflectance data in these ranges are removed.

[0049] As one embodiment of the present invention, Step 3, which involves SG convolution smoothing of the soil spectrum and correcting the hyperspectral image spectrum using the direct normalization (DS) algorithm with reference to indoor hyperspectral data, specifically includes:

[0050] The Savitzky-Golay (SG) convolution smoothing algorithm was used to process the soil spectral curves. The sliding window number was set to 9, the order of the fitting polynomial was 21, and the data after SG smoothing was used as the original spectral data.

[0051] The spectral resolution of the in-situ hyperspectral remote sensing image was resampled to 1 nm, with a resampled wavelength range of 400-2450 nm. This ensured that the indoor spectrum and the in-situ hyperspectral image spectrum had the same number of bands, band index, and spectral resolution. The KS algorithm was used to select an appropriate number of samples as the transformation set to calculate the transition matrix. The remote sensing image spectral data was then corrected using the direct normalization (DS) algorithm with the indoor spectral data as a reference.

[0052] As one embodiment of the present invention, Step 4, which uses fractional derivatives for transformation, specifically involves:

[0053]

[0054] In the formula, p represents the order of the differential, h represents the step size of the differential, t represents the upper limit of the differential, a represents the lower limit of the differential, and Γ represents the Gamma function.

[0055] Assuming the function f(x) is a one-dimensional hyperspectral signal, and [a,t] represents the wavelength interval x∈[a,t], the band interval can be equally divided according to the differential step size h. Let h=1, The difference expression for the v-th order fractional derivative of the function f(x) can then be derived as follows:

[0056]

[0057] In the formula, v represents the order; v = 0 represents the original spectrum; v = 1 represents the 1.0th order differential of integer order; and v = 2 represents the 2.0th order differential of integer order. The fractional-order differential transform is implemented using Python programming.

[0058] As one embodiment of the present invention, Step 5, the design of the network framework and loss function based on the Transformer algorithm, specifically includes:

[0059] Step 5.1: The Transformer feature extraction framework mainly includes modules such as input projection, positional encoding, multi-layer Transformer encoder, feature selection, feature importance estimation, and region selection.

[0060] First, let the input remote sensing sample be... Where B represents the batch size and D represents the number of bands. Each band serves as a one-dimensional feature input. To improve feature representation, each band feature is first linearly projected onto a higher-dimensional space:

[0061] H0 = Linear(X) T )

[0062] in, This represents the projected features, where d is the dimension of the Transformer hidden layer. Linear represents a linear projection layer that maps each band feature (scalar) to d dimensions.

[0063] To preserve the order information of the bands, a sine-cosine position code is further added to each band position: H0 = H0 + PE. The formula for calculating the position code PE is:

[0064]

[0065] Where pos is the band index (ranging from 0 to D-1), and i is the feature dimension index (ranging from 0 to d-1). Note that in the formula, i ranges from 0 to d / 2-1 because the encoding of each position pos has d dimensions, where even dimensions use sine and odd dimensions use cosine.

[0066] Subsequently, the features encoded by projection and position are input into a stacked L-layer Transformer encoder: H l =TransformerLayer(H l-1 Let l = 1, ..., L, where each Transformer layer contains a multi-head self-attention mechanism and a feedforward network. The self-attention is calculated as follows:

[0067]

[0068] Where Q, K, and V are the query, key, and value matrices, respectively, and H is output from the previous layer. l-1 It is obtained through a linear transformation. d is the hidden layer dimension, which is used for scaling in scaled dot product attention to prevent the softmax gradient from vanishing due to an excessively large inner product.

[0069] After multi-layer Transformer encoding, a high-dimensional feature representation H for each band is obtained. L To achieve feature selection, a multilayer perceptron (MLP) is used to score the importance of each band output, resulting in the raw importance score (logits) for each sample in each band:

[0070] s = MLP(H L )

[0071]

[0072] Here, MLP stands for Multilayer Perceptron, which maps the d-dimensional features of each band to a scalar, and s represents the original importance score (logits), with a shape of B×D.

[0073] Considering the physical spatial distribution of hyperspectral bands, this paper divides all bands into R regions, and performs Top-k soft selection independently in each region. For the r-th region, the logits of that region are first extracted: s r =s[:,start r :end r Then, determine the number of Top-k numbers based on the set selection ratio ρ: Among them, start r end r This represents the start and end indices of the r-th region. ρ represents the selection ratio (e.g., 0.15, meaning 15% of the bands in each region are selected). Indicates rounding down. k r It must be at least 1. The formula for calculating the Top-k threshold for this region is as follows:

[0074] thresholdr =topk(s r ,k r [-1]

[0075] Where topk represents the largest k among the logits of each sample in that region. r [-1] represents the minimum value among these values ​​(i.e., the k-th value). r Large values ​​are used as thresholds.

[0076] Finally, a differentiable sigmoid function is used to implement soft selection, yielding a normalized importance score for each band:

[0077]

[0078] Where T represents the temperature parameter, controlling the steepness of the sigmoid function (stepwise annealing during training makes the selection sparser and more deterministic), and σ represents the sigmoid function. The results from all regions are concatenated to obtain the final feature importance score a = concat(a1,...,a2). R ), Used for subsequent feature selection and loss calculation.

[0079] Step 5.2: This invention proposes multiple loss functions, including reconstruction loss, discriminative loss, sparsity loss, regional equalization loss, and diversity loss function, to jointly optimize model parameters and achieve efficient, balanced, and interpretable feature band selection.

[0080] The reconstruction loss encourages the selected bands to restore the original input to the greatest extent possible, thus improving the representativeness of feature selection. Specifically, the importance score 'a' is weighted and input into X, then fed into the reconstruction network to obtain the reconstruction result. Where ⊙ represents element-wise multiplication, and X⊙a denotes weighting the original input with importance scores (i.e., feature selection). Reconstructor represents a network reconstruction (e.g., a multilayer perceptron), reconstructing the weighted input to the original input dimension. 2 Let represent the squared error. The reconstruction loss can be defined as:

[0081]

[0082] The discriminative loss uses the global features output by the Transformer to predict downstream task objectives (such as land cover categories or regression values), ensuring that the selected bands have discriminative power. For each sample b, the feature vectors of all its band positions (from the 1st to the Dth) are averaged to obtain a global feature vector.

[0083] H L,d,bThis represents the feature representation of the d-th band position of the b-th sample after passing through L layers of Transformers. The global feature vector g of sample b is... b The input is fed into the prediction network to obtain the predicted value. In the formula, f pred This represents a prediction network (usually a multilayer perceptron) whose input is the global feature vector g. b The output is the predicted value. Let represent the model's predicted value for the b-th sample (e.g., Cu content). Then, the discriminant loss can be defined as:

[0084]

[0085] To encourage the model to select only a few key bands, the sparsity loss is defined as the mean of all importance scores:

[0086]

[0087] To improve the uniformity of selection across different band regions, the regional uniformity loss is defined as the coefficient of variation of the number of highly important bands in each region:

[0088]

[0089] Where region_high_count is the number of high-importance bands in each region, and ∈ is a small constant to prevent the denominator from being zero.

[0090] Diversity loss encourages the spatial dispersion of important features across bands, preventing feature concentration in a specific band region. It is defined as the sum of the reciprocals of the regional mean variance and the weighted band location variance:

[0091]

[0092] Among them, region means The weighted average importance of each region. positions This represents the weighted band position.

[0093] The final total loss function is obtained by summing all loss terms with weights.

[0094]

[0095] Wherein, α1, α2, λ1, λ2, λ3 are the weights of each loss term, which are obtained through experimental optimization.

[0096] Example 2:

[0097] In this embodiment of the invention, soil samples were collected from Kuangshan Town, Huize County, Qujing City, Yunnan Province, covering an area of ​​225 square kilometers. A total of 310 soil samples were collected, and the remote sensing images were hyperspectral remote sensing images from the same period of China's Gaofen-5 (GF-5) satellite. The terrain of Kuangshan Town is predominantly mountainous, with significant elevation changes, generally trending from west to east. The area is characterized by towering mountains, deep ravines, and significant elevation differences, exhibiting typical high-mountain and canyon landforms. Kuangshan Town belongs to the northern subtropical monsoon climate zone, and due to the influence of the plateau and mountainous terrain, the climate exhibits a distinct vertical distribution. The average annual rainfall is relatively abundant, generally around 900 to 1200 millimeters. The region is particularly rich in lead-zinc mineral resources with a long history, making it one of the most important lead-zinc mining areas in Yunnan Province and even nationwide. The mineral deposits are of high grade and have significant mining value.

[0098] like Figure 1 As shown, the soil heavy metal hyperspectral remote sensing inversion method of this invention includes the following steps:

[0099] Step 1: Collect soil samples in the field, measure the spectral reflectance data of the soil and the content of heavy metal copper in the laboratory, and extract the spectral reflectance data of the in-situ hyperspectral remote sensing image based on the coordinates of the sampling points.

[0100] Specifically, the study area covers a total area of ​​225 square kilometers. Using 91 Satellite Map Assistant and ArcGIS software, 204 samples were planned using a 1×1 kilometer grid, avoiding areas with vegetation cover. Easily accessible areas were selected for sampling, and samples were taken within the planned grid as much as possible. A total of 310 soil samples were collected in the field. The latitude and longitude coordinates of each point were recorded using GPS. Each sample weighed 500-1000g. The soil samples were transported back to the laboratory, spread out, and allowed to air dry. After drying, the soil was ground through a 100-mesh nylon sieve, retaining approximately 100g of soil powder. The processed soil powder was divided into two portions: one for indoor soil spectral reflectance data measurement (using an ASD ground object spectrometer), and the other for determining the heavy metal copper content (using a handheld fluorescence spectrometer). The statistical results of the heavy metal Cu content are shown in Table 1.

[0101] Table 1

[0102]

[0103]

[0104] Downloaded GF-5 hyperspectral remote sensing images from the same period, performed radiometric, atmospheric, and orthorectification preprocessing, and removed bad bands from the images. Subsequently, in-situ spectral reflectance data of 310 samples were extracted from the images based on GPS coordinates.

[0105] Step 2: Remove bands with significant noise interference from the hyperspectral reflectance data;

[0106] Specifically, noisy spectral ranges in the soil hyperspectral data measured in Step 1 were removed. The wavelength range for ASD measurements was 350nm-2500nm, with a sampling interval of 1nm. During spectral acquisition, due to instrument limitations, the 350nm-399nm and 2451nm-2500nm ranges exhibited significant noise; therefore, spectral data in these two ranges were removed. Furthermore, the GF-5 image bands were cropped based on the spectral range of the indoor spectral data, retaining bands within the 400-2450nm range.

[0107] Step 3: Perform SG convolution smoothing on the soil spectrum after removing noise interference bands. The smoothed data is used as the original spectrum, and the hyperspectral image spectrum is corrected by the Direct Normalization (DS) algorithm with indoor hyperspectral data as a reference.

[0108] Specifically, the spectral data after removing noise interference in Step 2 were processed using the Savitzky-Golay (SG) convolution smoothing algorithm. The sliding window number was set to 9, the order of the fitting polynomial was 21, and the SG smoothed data was used as the original spectral data. This was implemented using Matlab programming.

[0109] The in-situ spectrum was resampled to a resolution of 1 nm and a wavelength range of 400-2450 nm, ensuring that the indoor spectrum and the in-situ hyperspectral image spectrum had the same number of bands, band index, and spectral resolution. The KS algorithm was used to select an appropriate number of samples as the transformation set to calculate the transition matrix. The remote sensing image spectral data was then corrected using the direct normalization (DS) algorithm with the original indoor spectral data as a reference. DS correction was implemented using Python programming. The spectral curves before and after DS correction are shown below. Figure 2 As shown.

[0110] Step 4: Perform fractional derivative transform on the corrected spectral data to highlight spectral features;

[0111] The fractional-order differential transformation is specifically as follows:

[0112]

[0113] In the formula, p represents the order of the differential, h represents the step size of the differential, t represents the upper limit of the differential, a represents the lower limit of the differential, and Γ represents the Gamma function.

[0114] Assuming the function f(x) is a one-dimensional hyperspectral signal, and [a,t] represents the wavelength interval x∈[a,t], the band interval can be equally divided according to the differential step size h. Let h = 1, The difference expression for the v-th order fractional derivative of the function f(x) can then be derived as follows:

[0115]

[0116] In the formula, v represents the order; v = 0 represents the original spectrum; v = 1 represents the 1.0th order differential; and v = 2 represents the 2.0th order differential. The fractional-order differential transform is implemented using Python programming, with an order of 0.2. The result is as follows: Figure 3 As shown.

[0117] Step 5: Use a network framework based on the Transformer algorithm to screen the hyperspectral characteristic bands of heavy metal copper content;

[0118] Specifically, such as Figure 1 As shown, the Transformer network framework includes modules for input projection, positional encoding, multi-layer Transformer encoder, feature selection, feature importance estimation, and region selection. Furthermore, this invention proposes multiple loss functions, including reconstruction loss, discriminative loss, sparsity loss, and region equalization loss, to jointly optimize model parameters, achieving efficient, balanced, and interpretable feature band selection.

[0119] Specifically, the model configuration parameters are as follows: Transformer dimension (d_model) controls the feature representation capability; the higher the dimension, the larger the model capacity, so it is set to 64; Number of attention heads (nhead) controls the model's ability to process different feature relationships in parallel, so it is set to 4; Number of Transformer layers (num_layers) controls the feature extraction depth; the more layers, the stronger the feature abstraction capability, so it is set to 2; Random neuron inactivation rate (dropout) prevents overfitting and improves the model's generalization ability, so it is set to 0.1.

[0120] Specifically, the training configuration parameters are as follows: the number of training iterations (epochs) controls the convergence of the model, set to 100; the learning rate (lr) controls the optimization speed, the larger the value, the faster the convergence but the oscillation may occur, set to 1e-4; the number of training samples per batch (batch_size) balances memory usage and gradient stability, set to 16.

[0121] Specifically, the key parameters for feature selection are as follows: the number of spectral regions (num_regions) corresponds to different physical bands (visible light / near-infrared / shortwave infrared), and is set to 5; the selection ratio for each region (region_top_k_ratio) controls the proportion of features retained in each region, and is set to 0.15; the initial temperature of Gumbel-Softmax (temperature) controls the "softness" or "hardness" of feature selection, and is set to 5.0; the minimum temperature (min_temperature) is set to 0.5; and the temperature decay rate (temperature_decay) controls the speed at which feature selection transitions from exploration to utilization during training, and is set to 0.99.

[0122] Specifically, the weight parameters of the loss function are as follows: Reconstruction loss (reconstruction_loss) ensures that the selected features can reconstruct the original spectrum, set to 0.8; Discrimination loss (target_loss) ensures that the selected features can predict the Cu content, set to 0.5; Sparsity loss (sparsity_weight*sparsity_loss) controls the number of selected features, set to 0.005; Region balance loss (region_balance_loss) ensures that features are balanced across different spectral regions, set to 0.3; Diversity loss (diversity_weight*diversity_loss) ensures that features are dispersed in the band space, set to 0.1.

[0123] With the above parameter settings, using soil spectrum as the independent variable and copper content as the dependent variable, the relevant results obtained using the Transformer algorithm-based feature band selection method are as follows: Figure 4 , Figure 5 and Figure 6 As shown.

[0124] Step 6: Establish a hyperspectral inversion model for copper content using the XGBoost method, and verify its accuracy and stability;

[0125] Specifically, the characteristic bands selected based on the Transformer algorithm were used as independent variables, and copper content was used as the dependent variable. A hyperspectral inversion model for copper content was established using the XGBoost method, and the coefficient of determination (R²) was used. 2 The accuracy and stability were verified using root mean square error (RMSE) and mean absolute error (MAE) to validate the reliability and effectiveness of the Transformer algorithm in selecting feature bands. The XGBoost modeling results are shown in Table 2. Under fractional differential spectral transform, the 0.8th order fractional modeling performed best among the feature bands selected based on the Transformer algorithm, with the training set R... C 2RMSE C MAE C The values ​​are 0.905, 26.598, and 18.412 respectively, for the test set R. V 2 RMSE V MAE V The values ​​are 0.656, 55.534, and 40.801, respectively, indicating that the feature bands selected based on the Transformer algorithm are effective and reliable, and have high prediction accuracy.

[0126] Table 2

[0127] 0.0 level _XGBoost 0.777 40.679 28.203 0.549 60.009 42.076 0.2-order XGBoost 0.745 43.527 29.044 0.507 62.707 45.776 0.4-order XGBoost 0.746 43.415 31.683 0.551 59.852 41.588 0.6-order XGBoost 0.984 10.78 8.458 0.603 56.251 41.380 0.8-order XGBoost 0.905 26.598 18.412 0.656 55.534 40.801 1.0 level _XGBoost 0.970 15.014 10.682 0.586 57.462 43.428 1.2-order XGBoost 0.977 13.094 9.319 0.564 58.976 41.557 1.4-order XGBoost 0.993 6.974 4.239 0.535 60.904 43.892 1.6-stage XGBoost 0.918 24.679 14.246 0.526 61.473 44.073 1.8-level XGBoost 0.797 38.777 26.759 0.533 61.034 47.764 2.0 level _XGBoost 0.925 23.594 14.114 0.576 58.146 41.119

[0128] Example 3:

[0129] This invention also provides a soil heavy metal hyperspectral remote sensing inversion device, comprising:

[0130] The first processing module is used to obtain indoor hyperspectral data and heavy metal copper content based on soil samples; and to extract in-situ hyperspectral remote sensing image spectral data based on the sampling point coordinates.

[0131] The second processing module is used to perform SG spectral smoothing on indoor hyperspectral data after removing noise bands.

[0132] The third processing module is used to correct the spectral data of the hyperspectral image based on the indoor hyperspectral data after SG spectral smoothing.

[0133] The fourth processing module is used to perform fractional-order differential spectral transformation on the corrected hyperspectral image spectral data;

[0134] The fifth processing module is used to input the heavy metal copper content as the dependent variable and the hyperspectral image spectral data after fractional differential spectral transformation as the independent variable into the Transformer feature selection framework. The Transformer feature selection framework is used to screen the hyperspectral feature bands of soil heavy metal copper content.

[0135] The sixth processing module is used to build a soil copper content inversion model using XGBoost to verify the effectiveness of Transformer feature selection.

[0136] As one embodiment of the present invention, the spectral data of the hyperspectral image is corrected by the Direct Normalization (DS) algorithm using indoor hyperspectral data after SG spectral smoothing as a reference.

[0137] As one embodiment of the present invention, the Transformer feature selection framework includes: input projection, position encoding, multi-layer Transformer encoder, feature selection, feature importance estimation and region selection; the loss function of the Transformer feature selection framework includes: reconstruction loss function, discriminant loss function, sparsity loss function, region equalization loss and diversity loss function.

[0138] Example 4:

[0139] This invention also provides a soil heavy metal hyperspectral remote sensing inversion system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes a soil heavy metal hyperspectral remote sensing inversion method when executed by the processor.

[0140] Example 5:

[0141] This invention also provides a storage medium storing a computer program that executes a soil heavy metal hyperspectral remote sensing inversion method during runtime.

[0142] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made to the technical solutions of the present invention by those skilled in the art without departing from the spirit of the present invention should fall within the protection scope defined by the claims of the present invention.

Claims

1. A method for hyperspectral remote sensing inversion of heavy metals in soil, characterized in that, include: Based on soil samples, indoor hyperspectral data and heavy metal copper content were obtained; and in-situ hyperspectral remote sensing image spectral data were extracted based on the sampling point coordinates. After removing noisy bands from indoor hyperspectral data, SG spectral smoothing is performed. The spectral data of the hyperspectral image were corrected based on the indoor hyperspectral data after SG spectral smoothing. Perform fractional-order differential spectral transformation on the corrected hyperspectral image spectral data; The content of heavy metal copper is used as the dependent variable, and the spectral data of the hyperspectral image after fractional differential spectral transformation is used as the independent variable and input into the Transformer feature selection framework. The Transformer feature selection framework is used to screen the hyperspectral feature bands of heavy metal copper content in soil. A soil copper content inversion model was built using XGBoost to verify the effectiveness of Transformer feature selection. Using indoor hyperspectral data smoothed by SG as a reference, the hyperspectral image spectral data is corrected by direct normalization DS algorithm; The Transformer feature selection framework includes: input projection, positional encoding, multi-layer Transformer encoder, feature selection, feature importance estimation, and region selection. First, let the input remote sensing sample be... ,in Indicates batch size. This represents the number of bands; each band is used as a one-dimensional feature input, and the feature of each band is linearly projected onto a high-dimensional space: in, Represents the projected features. It is the dimension of the hidden layer of the Transformer; Represents a linear projection layer that maps the features of each band to... dimension; Add sine-cosine position coding to each band position: Where PE stands for location code; The projected and position-encoded features are then fed into a stacked L-layer Transformer encoder: Each Transformer layer contains a multi-head self-attention mechanism and a feedforward network; After multi-layer Transformer encoding, a high-dimensional feature representation of each band is obtained. The importance score for each band output is obtained by using a multilayer perceptron (MLP) to assign importance scores to each sample for each band. in, This represents a multilayer perceptron, which converts each band... The dimensional feature map is converted into a scalar. Represents the original importance score, in shape [formula missing]. ; All bands are divided into R Each of the regions performs a Top-k soft selection independently; for the region... r For each region, extract its logits: According to the set selection ratio ρ Determine the number of Top-k items: ;in, Indicates the first The start and end indexes of each region; Indicates the selection ratio; Indicates rounding down; The value must be at least 1; the formula for calculating the Top-k threshold for this region is as follows: in, This indicates that the maximum logits among all samples in that region should be returned. One value; This means taking the minimum value among these values ​​as the threshold; Soft selection is achieved using a differentiable sigmoid function, yielding a normalized importance score for each band: in, This represents the temperature parameter, which controls the steepness of the sigmoid function. This represents the sigmoid function; the results from all regions are concatenated to obtain the final feature importance score. , Used for subsequent feature selection and loss calculation; The Transformer feature selection framework uses loss functions including: reconstruction loss function, discriminative loss function, sparsity loss function, regional equalization loss function, and diversity loss function. These functions jointly optimize model parameters to achieve efficient, balanced, and interpretable feature band selection. To improve the balance of selection across different band regions, the regional balance loss is defined as the coefficient of variation of the number of highly important bands in each region: in, Let ϵ be the number of high-importance bands for each region, and let ϵ be a small constant to prevent the denominator from being zero. Diversity loss encourages the spatial dispersion of important features across bands, preventing features from concentrating in a particular band region. It is defined as the sum of the reciprocals of the regional mean variance and the weighted band location variance. in, This represents the average importance of each region. Weighted band position; The weighted sum of all loss terms yields the final total loss function.

2. A soil heavy metal hyperspectral remote sensing inversion device for implementing the soil heavy metal hyperspectral remote sensing inversion method of claim 1, characterized in that, include: The first processing module is used to obtain indoor hyperspectral data and heavy metal copper content based on soil samples; and to extract in-situ hyperspectral remote sensing image spectral data based on the sampling point coordinates. The second processing module is used to perform SG spectral smoothing on indoor hyperspectral data after removing noise bands. The third processing module is used to correct the spectral data of the hyperspectral image based on the indoor hyperspectral data after SG spectral smoothing. The fourth processing module is used to perform fractional-order differential spectral transformation on the corrected hyperspectral image spectral data; The fifth processing module is used to input the heavy metal copper content as the dependent variable and the hyperspectral image spectral data after fractional differential spectral transformation as the independent variable into the Transformer feature selection framework. The Transformer feature selection framework is used to screen the hyperspectral feature bands of soil heavy metal copper content. The sixth processing module is used to build a soil copper content inversion model using XGBoost to verify the effectiveness of Transformer feature selection; Using indoor hyperspectral data smoothed by SG as a reference, the hyperspectral image spectral data is corrected by direct normalization DS algorithm; The Transformer feature selection framework includes: input projection, positional encoding, multi-layer Transformer encoder, feature selection, feature importance estimation, and region selection; the loss functions of the Transformer feature selection framework include: reconstruction loss function, discriminative loss function, sparsity loss function, region equalization loss function, and diversity loss function.

3. A soil heavy metal hyperspectral remote sensing inversion system, characterized in that, include: The system includes a memory and a processor, wherein the memory stores a computer program that is executed by the processor, and the computer program, when executed by the processor, performs the soil heavy metal hyperspectral remote sensing inversion method as described in claim 1.

4. A storage medium, characterized in that, The storage medium stores a computer program, which executes the soil heavy metal hyperspectral remote sensing inversion method as described in claim 1 when it runs.