Self-coding hyperspectral anomaly detection method based on local and global double-branch cooperation
Through multi-directional mask convolution and local-global dual-branch collaborative model, the interference of abnormal pixels is destroyed, the background reconstruction capability is enhanced, the problems of missed detection and false alarm in hyperspectral anomaly detection are solved, and more efficient detection effect is achieved.
Patent Information
- Application Number
- CN202510719396.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-09-12
AI Technical Summary
In existing hyperspectral anomaly detection methods, abnormal pixel interference leads to poor detection results, some abnormal samples are reconstructed and missed, and insufficient background sample reconstruction leads to a high false alarm rate.
A multi-directional mask convolution module is designed to destroy the spatial correlation of anomalies. The local and global dual-branch collaborative model is combined with the attention-driven multi-scale grouped convolution and cascaded spatial spectral attention module to enhance the reconstruction ability of background samples and suppress anomaly reconstruction.
The results of hyperspectral anomaly detection are significantly improved, the missed detection rate and false alarm rate in anomaly detection are reduced, and the detection accuracy is improved.
Smart Images

Figure CN120635699A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer vision and machine learning technology, and further relates to hyperspectral anomaly detection. Specifically, it is a self-encoding hyperspectral anomaly detection method based on local and global dual-branch collaboration, which can be applied to environmental monitoring, military exploration, geological exploration and other fields. Background Art
[0002] Hyperspectral anomaly detection is a hyperspectral image processing task. It is defined as capturing pixels in a hyperspectral image that exhibit significant spectral differences from surrounding pixels without prior knowledge. This characteristic is widely used in military, agricultural, geological, and marine applications. In recent years, deep learning models have attracted the attention of hyperspectral researchers, who have applied them to hyperspectral anomaly detection, achieving impressive accuracy.
[0003] In the existing technical literature PDBSNet [Wang D, Zhuang L, Gao L, et al. PDBSNet: Pixel-shuffledownsampling blind-spot reconstruction network for hyperspectral anomaly detection [J]. IEEE Transactions on Geoscience and Remote Sensing, 2023, 61: 1-14.], PDBSNet adopts a blind spot architecture with a receptive field, in which the central pixel is set as a blind spot (i.e., the network cannot see the central pixel), and uses its neighboring pixels to reconstruct the spectral information of the central pixel; the network uses blind spot convolution to reconstruct the central pixel, which is conducive to detecting abnormally small targets; however, abnormal targets with larger spatial sizes may still be well reconstructed because the reconstruction of the anomaly will be interfered by adjacent abnormal pixels. In the prior art paper RSAAE [Wang L, Wang X, Vizziello A, et al. RSAAE: Residual self-attention-based autoencoder for hyperspectral anomaly detection [J]. IEEE Transactions on Geoscience and Remote Sensing, 2023, 61: 1-14.], the method first designs a residual self-attention module, which can effectively extract key features, weaken the subsequent network's ability to reconstruct anomalies, and retain the original features. However, this method is limited in its ability to suppress the reconstruction of anomalous samples using the residual self-attention module. Most existing hyperspectral anomaly detection methods based on autoencoder models have the following problems: First, due to the powerful feature extraction ability of the autoencoder model, some anomalous samples can also be well reconstructed, resulting in missed anomalies; second, due to changes in the background spectrum, complex background samples may not be effectively reconstructed, resulting in a high rate of false alarm detections. Summary of the Invention
[0004] The present invention aims to address the shortcomings of the above-mentioned prior art and propose a self-encoding hyperspectral anomaly detection method based on local and global dual-branch collaboration to solve the problem that the existing method is interfered with by abnormal pixels and causes poor detection effect. The present invention designs a multi-directional masked convolution MDMC (Multi-directional Masked Convolution) module to destroy the spatial correlation of anomalies along the horizontal, vertical, diagonal (main and anti-diagonal) and central block directions, aiming to reduce the interference of the central pixel by the surrounding abnormal pixels during the reconstruction process, thereby effectively suppressing the reconstruction of the anomaly; at the same time, a local and global dual-branch collaborative model is designed to enhance the model's reconstruction ability of background samples by extracting fine-grained local features and global context information in parallel, thereby reducing the false alarm rate in anomaly detection. Specifically, in the local branch, the present invention designs an attention-driven multi-scale grouped convolution AMGC (Attention-driven Multi-scale Grouped Convolution) module to enhance the model's reconstruction ability of fine-grained background features; in the global branch, the present invention designs a cascaded spatial-spectral attention CSSA (Cascaded Spatial-Spectral Attention) module to enhance the model's modeling ability of global background context features. This significantly improves the hyperspectral anomaly detection effect.
[0005] The present invention achieves the above-mentioned purpose by the following specific steps:
[0006] (1) Obtaining the original hyperspectral image Where H, W and B represent the height, width and number of bands of the hyperspectral image;
[0007] (2) Construct an autoencoder hyperspectral anomaly detection model including an encoder, a multi-directional masked convolution (MDMC) module, an attention-driven multi-scale grouped convolution (AMGC) module, a cascaded spatial spectrum attention (CSSA) module, and a reconstruction module. The implementation steps are as follows:
[0008] (2.1) The encoder consists of a 1×1 convolution layer, a batch normalization layer BN and an activation function layer, which is used to encode the encoded features of X
[0009] (2.2) Construct the MDMC module, which includes the multi-directional mask convolution MMConv, the two-dimensional convolution layer with a convolution kernel size of 3, the batch normalization layer BN and the activation function layer. The encoded features are used as the input of the module to generate shallow background features.
[0010] (2.3) Introducing the attention mechanism into the multi-scale group convolutional network and constructing the AMGC module to extract local fine-grained background features
[0011] (2.4) The CSSA module is constructed by cascading the spatial differential adaptive attention SpaDAA and spectral attention SpeA submodules to extract global context background features.
[0012] (2.5) Construct a method for generating reconstructed hyperspectral images The reconstruction module includes a constraint module and a decoder; wherein the constraint module contains a two-dimensional convolution layer with a kernel size of 1 and a Softmax function; the decoder consists of a two-dimensional convolution layer with a kernel size of 1 and an activation function layer;
[0013] (3) Using L1 norm and spectral angle distance L SAD As the joint loss function L, it guides the model training to convergence and obtains the trained final detection model;
[0014] (4) Input the original hyperspectral image X into the final detection model to obtain the reconstructed hyperspectral image according to Calculate with X to obtain the anomaly detection result.
[0015] Compared with the prior art, the present invention has the following advantages:
[0016] First, the present invention designs a multi-directional mask convolution (MDMC) module in the constructed detection model, which destroys the spatial correlation of anomalies along the horizontal, vertical, diagonal (main and anti-diagonal) and center block directions. This can reduce the interference of the central pixel with the surrounding abnormal pixels during the reconstruction process, thereby effectively suppressing the model's ability to reconstruct anomalies.
[0017] Second, the present invention constructs an attention-driven multi-scale grouped convolution AMGC module to model fine-grained local details in complex hyperspectral backgrounds. The network architecture uses grouped convolution for parameter-efficient spectral spatial feature learning and multi-scale mixed kernels for multi-scale context aggregation, enhancing the model's ability to model background samples. The designed CSA module can adaptively activate important spatial regions in the features and suppress potential anomalies by performing average pooling in multiple coordinate directions.
[0018] Third, the present invention improves the model's ability to model global background context features by designing a cascaded spatial spectral attention (CSSA) module. This architecture proposes a novel DAA strategy that adaptively adjusts the attention score by dynamically perceiving feature differences, which can enhance the model's ability to reconstruct background samples and suppress the reconstruction of potential abnormal samples. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1Schematic diagram of the overall implementation process of the method of the present invention;
[0020] Figure 2 Schematic diagram of the multi-directional masked convolution MDMC module in the present invention; (a) is a schematic diagram of the multi-directional masked convolution kernel generation process, and (b) is a schematic diagram of the multi-directional masked convolution module structure;
[0021] Figure 3 Schematic diagram of the structure of the coordinate perception spatial attention CSA module in the present invention;
[0022] Figure 4 Schematic diagram of the structure of the cascaded spatial spectral attention CSSA module in the present invention;
[0023] Figure 5 2 is a comparison chart of the detection effects of the present invention and the existing method. DETAILED DESCRIPTION
[0024] In order to make the purpose and advantages of the present invention more clear, the technical content of the present invention is described in detail below with reference to the accompanying drawings.
[0025] Example 1: Refer to the attached Figure 1 The present invention proposes a hyperspectral anomaly detection method based on adaptive background reconstruction of differential Mamba, which specifically includes the following steps:
[0026] Step 1) Obtain the original hyperspectral image Where H, W and B represent the height, width and number of bands of the hyperspectral image;
[0027] Step 2) Construct an autoencoder hyperspectral anomaly detection model including an encoder, a multi-directional masked convolution (MDMC) module, an attention-driven multi-scale grouped convolution (AMGC) module, a cascaded spatial spectrum attention (CSSA) module, and a reconstruction module. The implementation steps are as follows:
[0028] (2.1) The encoder consists of a 1×1 convolution layer, a batch normalization layer BN and an activation function layer, which is used to encode the encoded features of X
[0029] (2.2) Construct the MDMC module, which includes the multi-directional mask convolution MMConv, the two-dimensional convolution layer with a convolution kernel size of 3, the batch normalization layer BN and the activation function layer. The encoded features are used as the input of the module to generate shallow background features. In this embodiment, three mask matrices in different directions are designed to obtain the mask template of the original convolution kernel; the convolution kernel W is defined as m as follows:
[0030] W m =(m hv⊙m ma ⊙m cb )⊙W o
[0031] Among them, m hv 、m ma and m cb Represents the mask matrices for horizontal / vertical, main diagonal / anti-diagonal, and center block directions, setting gray to 0 and white to 1; W o Represents the original convolution kernel, and ⊙ represents element-wise multiplication.
[0032] (2.3) Introducing the attention mechanism into the multi-scale group convolutional network and constructing the AMGC module to extract local fine-grained background features The AMGC module constructed in this embodiment specifically includes a sub-encoder, a transition layer and a sub-decoder, which obtains local fine-grained background features F L The implementation steps are as follows:
[0033] (2.3.1) Use two grouped convolution blocks in cascade to form a sub-encoder, where the first grouped convolution block consists of a 3×3 grouped convolution, batch normalization, and LeakyReLU activation function; the second grouped convolution block consists of a 5×5 grouped convolution, batch normalization, and LeakyReLU activation function; F B As the input of the sub-encoder, the shallow coding features are obtained after being processed by two grouped convolution blocks and deep encoding features
[0034] (2.3.2) A transition layer is composed of a 1×1 group convolution, batch normalization, and LeakyReLU activation function, which converts the deep coding feature F E2 As input, we get the transition features
[0035] (2.3.3) The sub-decoder is composed of two cascaded attention group convolution blocks, where the first attention group convolution block consists of a coordinate-aware spatial attention CSA module, 3×3 group convolution, batch normalization, and LeakyReLU activation function; the second attention group convolution block consists of a coordinate-aware spatial attention CSA module, 5×5 group convolution, batch normalization, and LeakyReLU activation function; F M With F E2 The sum is used as the input of the sub-decoder and processed by the first attention group convolution block to obtain the decoding features. F D1 With F E1 The sum is used as the input of the second attention group convolution block, and the local fine-grained background features are obtained after being processed by the attention group convolution block.
[0036] The coordinate-aware spatial attention CSA module involved in this step in this embodiment is used to obtain enhanced attention features The implementation steps are as follows:
[0037] (2.3.3a) Input features Perform channel Z-direction averaging and maximum pooling operations to obtain average and maximum pooling spatial features and
[0038] (2.3.3b) Concatenate the average and maximum pooled spatial features and use a two-dimensional convolution with a kernel size of 3 to convert the concatenated features into coupled features
[0039] (2.3.3c) F cou Input two parallel branches, which are composed of an average pooling layer along the width X and height Y directions followed by a one-dimensional convolution layer with a convolution kernel size of 3, which is used to adjust the current position and adjacent features to obtain the X-direction feature. and Y-direction characteristics
[0040] (2.3.3d) Fusion of features F through dot product operation cou 、F xavg and F yavg And the fusion features are generated through the Sigmoid activation function to generate the spatial attention weight map Then W sa Multiply element-wise with the input feature F, and then add it to the original input feature through the residual connection to obtain the enhanced attention feature
[0041] (2.4) The CSSA module is constructed by cascading the spatial differential adaptive attention SpaDAA and spectral attention SpeA submodules to extract global context background features.
[0042] In this embodiment, the differential adaptive attention SpaDAA submodule is implemented according to the following steps:
[0043] (2.4.1a) For the input feature F B Perform dimension reshaping to obtain reshaped features Then the features are normalized by layer normalization LN operation Normalize and generate query vector using linear projection layer The specific calculation process is as follows:
[0044]
[0045] in, Represents the weight parameter, Reshape(·) represents the reshaping operation, LN(·) represents the layer normalization operation, and Split(·) represents the splitting operation along the channel dimension;
[0046] (2.4.1b) Input features Perform LN operation, and then use two-dimensional average pooling with a kernel size of 2 to achieve feature downsampling and obtain dimensionality reduction features Then to F down2× Perform dimension reshaping to obtain reshaped features Finally, the first key vector is generated through the linear projection layer Second key vector With value vector
[0047] (2.4.1c) Calculate the spatially adaptive differential attention matrix
[0048]
[0049] Among them, Softmax(·) represents the Softmax function, exp(·) represents the exponential function, N mm (·) denotes Min-Max normalization, ζ denotes the learning scalar;
[0050] (2.4.1d) Through SpaDAAtt and V spa Matrix multiplication obtains spatial enhancement features;
[0051] (2.4.1e) The spatial enhancement feature F spa With the original input features The fusion feature is obtained by residual connection fusion Then Input LN, feedforward network FFN and residual connection in sequence to obtain spatial attention features
[0052] The spectral attention SpeA submodule is implemented as follows:
[0053] (2.4.2a) Input features Perform LN operation, then compress the spatial dimension by 2D average pooling with kernel 2, and generate the query vector using linear projection operation and key vector Through the characteristics After performing the LN operation, perform linear projection directly to obtain the value vector
[0054] (2.4.2b) Calculate the spectral attention matrix according to the following formula
[0055]
[0056] Where α represents the learnable parameter of spectral attention;
[0057] (2.4.2c) Through SpeAtten and V spe Matrix multiplication to obtain spectral enhancement features
[0058] (2.4.2d) The spectral enhancement feature F spe With the original input features The fusion feature is obtained by residual connection fusion Then Input LN, FFN and residual connection in sequence to obtain spectral attention features Finally, in Perform a reshape operation on it to obtain the global context background features
[0059] (2.5) Construct a method for generating reconstructed hyperspectral images The reconstruction module includes a constraint module and a decoder; the constraint module contains a two-dimensional convolution layer with a kernel size of 1 and a Softmax function; the decoder consists of a two-dimensional convolution layer with a kernel size of 1 and an activation function layer. The module obtains the reconstructed hyperspectral image according to the following steps.
[0060] (2.5.1) Through adaptive fusion F L and F G Get fusion features
[0061] F F =ω1F L +ω2F G
[0062] Among them, ω1 and ω2 represent the learnable parameters corresponding to local background features and global background features;
[0063] (2.5.2) The feature F F Input constraint module to obtain abundance matrix Where R represents the number of end members; in this embodiment, the abundance matrix is obtained in this step Specifically: the feature F F First, the number of channels is reduced from C to R through the convolution layer, and then the Softmax operation is performed along the R dimension to obtain the abundance matrix A that satisfies the abundance non-negative constraint and the abundance sum-one constraint:
[0064] A=Softmax(Conv 1×1 (F F ))
[0065] Among them, Conv 1×1 (·) denotes a 2D convolution with a kernel size of 1.
[0066] (2.5.3) According to the linear mixed model hypothesis, the decoder expands the spectral band of A from R to B through convolution operation to obtain the reconstructed hyperspectral image
[0067]
[0068] in, represents a two-dimensional convolution with a kernel size of 1 without bias, Represents the weight parameters of the convolutional layer.
[0069] Step 3) Use L1 norm and spectral angle distance L SAD As the joint loss function L, the model is trained until convergence to obtain the trained final detection model; in this embodiment, the above loss function L is as follows:
[0070]
[0071] Among them, x i,j ∈X represents the hyperspectral image vector at position (i, j), represents the hyperspectral image vector reconstructed at position (i, j), λ is a hyperparameter that balances the losses of the two, ||·||1 represents the L1 norm, and ||·||2 represents the L2 norm.
[0072] Step 4) Input the original hyperspectral image X into the final detection model to obtain the reconstructed hyperspectral image according to The anomaly detection result is obtained by calculating X. The difference between the corresponding pixel in X and the square of its two-norm is obtained:
[0073]
[0074] Among them, r i,j Represents the anomaly detection result at position (i, j).
[0075] Example 2: Reference Figure 1-5 The overall implementation steps of the hyperspectral anomaly detection method proposed in this embodiment are the same as those in Example 1. Specific parameter settings are now given to further describe the implementation process of the present invention in detail:
[0076] Step 1. Figure 1 As shown, given a hyperspectral image Where 100, 100, and 191 represent the width, height, and number of spectral bands of the image, respectively. The image is input into the designed model to obtain the reconstructed hyperspectral image. The overall process is as follows:
[0077]
[0078] where En(·), MDMC(·), AMGC(·), CSSA(·), ConsM(·) and De(·) represent the encoder, multi-directional masked convolution module, attention-driven multi-scale grouped convolution module, cascaded spatial spectral attention module, constraint module and decoder, respectively. represents the features after the encoder, Represents shallow background features, represents the local fine-grained background features extracted by the local branch, Global context features extracted by the global branch, represents the background abundance matrix, Represents the reconstructed hyperspectral image.
[0079] Step 2. Multi-directional Masked Convolution (MDMC) module:
[0080] like Figure 2 As shown in (a), taking the convolution kernel of size 9×9 as an example, the present invention first designs three mask matrices in different directions to obtain the mask template of the original convolution kernel. Then, the convolution kernel W of the multi-directional masked convolution (MMConv) is m The definition is as follows:
[0081] W m =(m hv ⊙m ma ⊙m cb )⊙W o (2)
[0082] Among them, m hv , m ma and m cb Represents the mask matrices for (horizontal, vertical), (main diagonal, anti-diagonal) and center block directions (grey is set to 0, white is set to 1), W o represents the original convolution kernel, ⊙ represents element-wise multiplication. Finally, Figure 2 As shown in (b), the encoding feature F E Input MDMC module to generate shallow background features FB , the generation process is as follows:
[0083] F B =LeakyReLU(BN(Conv 3×3 (MMConv K×K (F E )))) (3)
[0084] Among them, MMConv 9×9 (·) indicates multi-directional mask convolution with a convolution kernel size of 9, Conv 3×3 (·) denotes a two-dimensional convolution with a kernel size of 3, BN(·) denotes batch normalization, and LeakyReLU(·) denotes the LeakyReLU activation function.
[0085] Step 3. Attention-driven Multi-scale Grouped Convolution (AMGC) module:
[0086] like Figure 1 As shown in (c) of
[15] , AMGC is designed to model fine-grained local details in complex hyperspectral image backgrounds. The architecture uses grouped convolution for parameter-efficient spectral-spatial feature learning, multi-scale mixing kernels for multi-scale context aggregation, and a designed coordinate-aware spatial attention (CSA) module for discriminative background reconstruction. Specifically, Figure 1 As shown in (c), first, F B Input to encoder 1 to obtain encoded features and Second, F E2 Input transition layer to obtain transition features Third, F M Input decoder 1 to obtain decoding features and local fine-grained background features The process can be expressed as:
[0087]
[0088] in, represents the grouped convolution with kernel size k and group g, and CSA(·) represents the CSA module, whose details are as follows:
[0089] like Figure 3 As shown, first, the input features Perform channel (Z) direction averaging and maximum pooling operations to obtain average and maximum pooling spatial features and Second, concatenate the two features and use a two-dimensional convolution with a kernel of 3 to convert the concatenated features into coupled features. Third, F cou Input two parallel branches, each branch contains an average pooling layer along the width (X) or height (Y) direction, followed by a one-dimensional convolution layer with a convolution kernel size of 3 to adjust the current position and adjacent features to obtain the feature and Fourth, fusion feature F cou , F xavg and F yavg , and then generate the spatial attention weight map through the fusion feature Sigmoid activation function The use of average pooling enables the weight map to adaptively activate important spatial regions and suppress abnormal interference. Finally, W sa Multiply the input feature F element by element, and then add it to the original input feature through the residual connection to obtain the enhanced feature The above process formula is expressed as follows:
[0090]
[0091] Among them, P xavg (·), P yavg (·) and P zavg (·) represents the average pooling operation along the width (X), height (Y), and channel (Z) directions, respectively. zmax (·) represents the maximum pooling operation along the channel (Z) direction, Concat(·) represents the concatenation operation along the channel direction, Conv 3×3 (·) represents a two-dimensional convolution with a kernel size of 3, Conv1D3(·) represents a one-dimensional convolution with a kernel size of 3, Sigmoid(·) represents the Sigmoid activation function, and ⊙ represents element-wise multiplication.
[0092] Step 4. Cascaded Spatial-Spectral Attention (CSSA) module:
[0093] Although the local branch can effectively capture the local detail features of the background, it lacks the ability to model global contextual relationships. To address this limitation, the present invention designs a CSSA module to improve the model's ability to model the global context of the background. CSSA is composed of a cascade of spatial difference adaptive attention (SpaDAA) and spectral attention (SpeA) modules. The SpaDAA module uses spatial difference feature modeling and adaptive attention mechanism to enhance the global context representation of the background while suppressing the propagation of potential abnormal reconstruction errors. The SpeA module addresses the disadvantage of existing methods that ignore spectral dependencies, and by paying attention to the channel dimension, it mines the correlation between cross-channel spectra. The details of the SpaDAA and SpeA modules are as follows:
[0094] 1) SpaDAA module design
[0095] like Figure 4 As shown in (a), first, the input feature F M Perform dimension reshaping to obtain reshaped features The features are then normalized by layer normalization (LN). Normalize and generate query vector using linear projection layer The specific calculation process is as follows:
[0096]
[0097] in, Represents the weight parameter, Reshape(·) represents the reshaping operation, LN(·) represents the layer normalization operation, and Split(·) represents the split operation along the channel dimension.
[0098] Second, to reduce computational complexity, we first perform the input feature F M Perform LN operation, and then use two-dimensional average pooling to achieve feature downsampling and obtain dimensionality reduction features Then to F down2× Perform dimension reshaping to obtain reshaped features Finally, the key vector is generated through the linear projection layer and value vector The specific formula is expressed as:
[0099]
[0100] in and Represents the weight parameter, AvgPool2D2×2 (·) represents a 2D average pooling operation with a kernel size of 2.
[0101] Third, we propose a difference adaptive attention (DAA) strategy to adaptively adjust the attention score by dynamically perceiving feature differences, thereby suppressing the reconstruction of potential anomalies.
[0102] Specifically, the spatially adaptive differential attention matrix The calculation process is as follows:
[0103]
[0104] Among them, Softmax(·) represents the Softmax function, exp(·) represents the exponential function, N mm (·) represents Min-Max normalization, ζ represents a learnable scalar, and details can be found in the literature [Ye T, Dong L, Xia Y, et al. Differential transformer[J].arXiv preprint arXiv:2410.05258,2024.].
[0105] Fourth, through SpaDAAtt and V spa Matrix multiplication to obtain spatial enhancement features The formula is as follows:
[0106] F spa =SpaDAAtt·V spa (9)
[0107] Finally, the spatial enhancement feature F spa With the original input features The fusion feature is obtained by residual connection fusion Then Input LN, feed-forward network (FFN) and residual connection in sequence to obtain spatial attention features The process can be expressed as follows:
[0108]
[0109] Here, FFN(·) represents a feed-forward network.
[0110] 2) SpeA module design
[0111] like Figure 4 As shown in (b), first, the input features Perform LN operation, then compress the spatial dimension through 2D average pooling with kernel 2, and generate query vector using linear projection operation and key vector The value vector It is through the characteristics Perform LN operation and then directly perform linear projection to obtain it.
[0112] Second, spectral attention matrix It can be calculated as follows:
[0113]
[0114] Here, α represents a learnable parameter.
[0115] Third, through SpeAtten and V spe Matrix multiplication to obtain spectral enhancement features The formula is as follows:
[0116] F spe =SpeAtt·V spe (12)
[0117] Fourth, the spectrum enhancement feature F spe With the original input features The fusion features are obtained by residual connection fusion Then Input LN, FFN and residual connection in sequence to obtain spectral attention features Finally, in Perform a reshape operation on it to obtain the global context background features The process can be expressed as follows:
[0118]
[0119] Step 5: Reconstruction module construction
[0120] like Figure 1 As shown in (e), the reconstruction module designed by the present invention consists of a feature fusion module, a constraint module and a decoder, which is used to obtain the reconstructed hyperspectral image. Specifically, first, by adaptively fusing F L and F G Get fusion features The calculation process is as follows:
[0121] F F =ω1F L +ω2F G (14)
[0122] Among them, ω1 and ω2 represent learnable parameters.
[0123] Second, the feature F F Input the constraint module to obtain the abundance matrix where 4 represents the number of end members. Specifically, F F First, the number of channels is reduced from 32 to 4 through a convolutional layer, and then a Softmax operation is performed along the 4-dimensional dimension to ensure that the abundance matrix A satisfies the abundance non-negative constraint and the abundance sum-one constraint. The calculation process of this constraint module is as follows:
[0124] A=Softmax(Conv 1×1 (F F )) (15)
[0125] Among them, Conv 1×1 (·) denotes a 2D convolution with a kernel size of 1.
[0126] Finally, according to the linear mixture model hypothesis, the decoder consists of a convolution layer without bias and an activation function. The spectral band of A is expanded from 4 to 191 through convolution operation, and the reconstructed hyperspectral image is finally obtained. The calculation process of the decoder module is as follows:
[0127]
[0128] in, represents a two-dimensional convolution with a kernel size of 1 without bias, represents the weight parameters of the convolutional layer, which are regarded as the endmember matrix of the hyperspectral image. It should be noted that the decoder is initialized by the endmembers extracted by Vertex Component Analysis (VCA).
[0129] Step 6. Model training and testing
[0130] The present invention uses the L1 norm and spectral angle distance (SAD) as the joint loss function L to guide model training. The formula is as follows:
[0131]
[0132] Among them, x i,j ∈X represents the hyperspectral image vector at position (i, j), represents the hyperspectral image vector reconstructed at position (i, j), λ is the parameter that balances the losses of the two, ||·||1 represents the L1 norm, and ||·||2 represents the L2 norm.
[0133] After the model training is completed, X is input into the trained model to obtain the reconstructed hyperspectral image. Then, the test results are obtained by the following formula:
[0134]
[0135] where r ij Represents the anomaly detection result at position (i, j).
[0136] The effects of the present invention will be further described below with reference to experiments.
[0137] 1. Experimental conditions:
[0138] The experiments of the present invention were carried out in a hardware environment with a CPU main frequency of 3.00 GHz, a memory of 48 GB, a Windows 10 operating system, and a software environment of Python 3.7.
[0139] 2. Experimental content:
[0140] The proposed method is qualitatively and quantitatively compared with seven popular algorithms on three public hyperspectral anomaly detection datasets. The public hyperspectral anomaly detection datasets used in the experiment include San Diego-II, Pavia and Salinas datasets; the seven popular algorithms compared are: RX[ISReed,and X.Yu,“Adaptive multiple-bandCFAR detection of an optical pattern with unknown spectral distribution,”IEEETrans.Acoust.Speech Signal Process.,vol.38,no.10,pp.1760-1770.], CRD[W.Li andQ.Du,“Collaborative representation for hyperspectral anomaly detection,”IEEETransactions on Geoscience and Remote Sensing,vol.53,no.3,pp.1463-1474.], LRASR[Xu Y,Wu Z,Li J,et al.Anomaly detection in hyperspectral images based onlow-rank and sparse representation[J].IEEE Transactions on Geoscience andRemote Sensing,2016,54(4):1990-2000.], RGAE[Fan G,Ma Y,Mei Sensing,vol.60,pp.1-18,Sep.,2022.Art no.5538818.], Auto-AD [Wang S, Wang X, Zhang L, et al. Clustering for HyperspectralImage[J]. IEEE Transactions on Geoscience and Remote Sensing, 2024.]. .
[0141] This paper first conducts a qualitative comparison with seven popular comparison algorithms on three public hyperspectral anomaly detection datasets. Figure 5 It can be seen that the detection results of the present invention are better than those of the comparison algorithms. At the same time, the present invention is quantitatively compared with seven popular comparison algorithms on three data sets, and the evaluation index used is the detection rate AUC (P d ,P f ). Among them, the detection rate AUC (P d ,P f ) is larger, the better the performance of detecting abnormal pixels is. As shown in Table 2, the present invention has the best detection rate.
[0142] Table 2 AUC (P d ,P f )Indicator comparison
[0143]
[0144] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0145] The above simulation analysis proves the correctness and effectiveness of the method proposed in the present invention.
[0146] Parts of the present invention that are not described in detail belong to common knowledge among those skilled in the art.
[0147] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Obviously, for professionals in this field, after understanding the content and principles of the present invention, they may make various modifications and changes in form and details without departing from the principles and structure of the present invention. However, these modifications and changes based on the ideas of the present invention are still within the scope of protection of the claims of the present invention.
Claims
1. A method for anomaly detection in hyperspectral spectrum based on local and global dual-branch collaboration, characterized in that: The steps include: (1) Obtaining the original hyperspectral image Where H, W and B represent the height, width and number of bands of the hyperspectral image; (2) Construct an autoencoder hyperspectral anomaly detection model including an encoder, a multi-directional masked convolution (MDMC) module, an attention-driven multi-scale grouped convolution (AMGC) module, a cascaded spatial spectrum attention (CSSA) module, and a reconstruction module. The implementation steps are as follows: (2.1) The encoder consists of a 1×1 convolution layer, a batch normalization layer BN and an activation function layer, which is used to encode the encoded features of X (2.2) Construct the MDMC module, which includes the multi-directional mask convolution MMConv, the two-dimensional convolution layer with a convolution kernel size of 3, the batch normalization layer BN and the activation function layer. The encoded features are used as the input of the module to generate shallow background features. (2.3) Introducing the attention mechanism into the multi-scale group convolutional network and constructing the AMGC module to extract local fine-grained background features (2.4) The CSSA module is constructed by cascading the spatial differential adaptive attention SpaDAA and spectral attention SpeA submodules to extract global context background features. (2.5) Construct a method for generating reconstructed hyperspectral images The reconstruction module includes a constraint module and a decoder; wherein the constraint module contains a two-dimensional convolution layer with a kernel size of 1 and a Softmax function; the decoder consists of a two-dimensional convolution layer with a kernel size of 1 and an activation function layer; (3) Using L1 norm and spectral angle distance L SAD As the joint loss function L, it guides the model training to convergence and obtains the trained final detection model; (4) Input the original hyperspectral image X into the final detection model to obtain the reconstructed hyperspectral image according to Calculate with X to obtain the anomaly detection result.
2. The method according to claim 1, wherein: The multi-directional mask convolution MMConv described in step (2.2) specifically designs three mask matrices in different directions to obtain the mask template of the original convolution kernel; define its convolution kernel W m as follows: W m =(m hv ⊙m ma ⊙m cb )⊙W o Among them, m hv 、m ma and m cb Represents the mask matrices for horizontal / vertical, main diagonal / anti-diagonal, and center block directions, setting gray to 0 and white to 1; W o Represents the original convolution kernel, and ⊙ represents element-wise multiplication.
3. The method according to claim 1, wherein: The AMGC module in (2.3) includes a sub-encoder, a transition layer, and a sub-decoder to obtain local fine-grained background features F L The implementation steps are as follows: (2.3.1) Use two grouped convolution blocks in cascade to form a sub-encoder, where the first grouped convolution block consists of a 3×3 grouped convolution, batch normalization, and LeakyReLU activation function; the second grouped convolution block consists of a 5×5 grouped convolution, batch normalization, and LeakyReLU activation function; F B As the input of the sub-encoder, the shallow coding features are obtained after being processed by two grouped convolution blocks and deep encoding features (2.3.2) A transition layer is composed of a 1×1 group convolution, batch normalization, and LeakyReLU activation function, which converts the deep coding feature F E2 As input, we get the transition features (2.3.3) The sub-decoder is composed of two cascaded attention group convolution blocks, where the first attention group convolution block consists of a coordinate-aware spatial attention CSA module, 3×3 group convolution, batch normalization, and LeakyReLU activation function; the second attention group convolution block consists of a coordinate-aware spatial attention CSA module, 5×5 group convolution, batch normalization, and LeakyReLU activation function; F M With F E2 The sum is used as the input of the sub-decoder and processed by the first attention group convolution block to obtain the decoding features. F D1 With F E1 The sum is used as the input of the second attention group convolution block, and the local fine-grained background features are obtained after being processed by the attention group convolution block.
4. The method according to claim 3, wherein: The coordinate-aware spatial attention CSA module described in (2.3.3) is used to obtain enhanced attention features The implementation steps are as follows: (2.3.3a) Input features Perform channel Z-direction averaging and maximum pooling operations to obtain average and maximum pooling spatial features and (2.3.3b) Concatenate the average and maximum pooled spatial features and use a two-dimensional convolution with a kernel size of 3 to convert the concatenated features into coupled features (2.3.3c) F cou Input two parallel branches, which are composed of an average pooling layer along the width X and height Y directions followed by a one-dimensional convolution layer with a convolution kernel size of 3, which is used to adjust the current position and adjacent features to obtain the X-direction feature. and Y-direction characteristics (2.3.3d) Fusion of features F through dot product operation cou 、F xavg and F yavg And the fusion features are generated through the Sigmoid activation function to generate the spatial attention weight map Then W sa Multiply element-wise with the input feature F, and then add it to the original input feature through the residual connection to obtain the enhanced attention feature 5. The method according to claim 1, wherein: The differential adaptive attention SpaDAA submodule described in (2.4) is implemented according to the following steps: (2.4.1a) For the input feature F B Perform dimension reshaping to obtain reshaped features Then the features are normalized by layer normalization LN operation Normalize and generate query vector using linear projection layer The specific calculation process is as follows: in, Represents the weight parameter, Reshape(·) represents the reshaping operation, LN(·) represents the layer normalization operation, and Split(·) represents the splitting operation along the channel dimension; (2.4.1b) Input features Perform LN operation, and then use two-dimensional average pooling with a kernel size of 2 to achieve feature downsampling and obtain dimensionality reduction features Then to F down2× Perform dimension reshaping to obtain reshaped features Finally, the first key vector is generated through the linear projection layer Second key vector With value vector (2.4.1c) Calculate the spatially adaptive differential attention matrix Among them, Softmax(·) represents the Softmax function, exp(·) represents the exponential function, N mm (·) denotes Min-Max normalization, ζ denotes the learning scalar; (2.4.1d) Through SpaDAAtt and V spa Matrix multiplication obtains spatial enhancement features; (2.4.1e) The spatial enhancement feature F spa With the original input features The fusion feature is obtained by residual connection fusion Then Input LN, feedforward network FFN and residual connection in sequence to obtain spatial attention features 6. The method according to claim 1, wherein: The spectral attention SpeA submodule described in (2.4) is implemented according to the following steps: (2.4.2a) Input features Perform LN operation, then compress the spatial dimension by 2D average pooling with kernel 2, and generate the query vector using linear projection operation and key vector Through the characteristics After performing the LN operation, perform linear projection directly to obtain the value vector (2.4.2b) Calculate the spectral attention matrix according to the following formula Where α represents the learnable parameter of spectral attention; (2.4.2c) Through SpeAtten and V spe Matrix multiplication to obtain spectral enhancement features (2.4.2d) The spectral enhancement feature F spe With the original input features The fusion feature is obtained by residual connection fusion Then Input LN, FFN and residual connection in sequence to obtain spectral attention features Finally, in Perform a reshape operation on it to obtain the global context background features The spectral attention SpeA submodule is implemented according to the following steps: (2.4.2a) Input features Perform LN operation, then compress the spatial dimension by 2D average pooling with kernel 2, and generate the query vector using linear projection operation and key vector Through the characteristics After performing the LN operation, perform linear projection directly to obtain the value vector (2.4.2b) Calculate the spectral attention matrix according to the following formula Where α represents the learnable parameter of spectral attention; (2.4.2c) Through SpeAtten and V spe Matrix multiplication to obtain spectral enhancement features (2.4.2d) The spectral enhancement feature F spe With the original input features The fusion feature is obtained by residual connection fusion Then Input LN, FFN and residual connection in sequence to obtain spectral attention features Finally, in Perform a reshape operation on it to obtain the global context background features 7. The method according to claim 1, wherein: The reconstruction module in (2.5) obtains the reconstructed hyperspectral image according to the following steps: (2.5.1) Through adaptive fusion F L and F G Get fusion features F F =ω1F L +ω2F G Among them, ω1 and ω2 represent the learnable parameters corresponding to local background features and global background features; (2.5.2) The feature F F Input constraint module to obtain abundance matrix Where R represents the number of end members; (2.5.3) According to the linear mixed model hypothesis, the decoder expands the spectral band of A from R to B through convolution operation to obtain the reconstructed hyperspectral image in, represents a two-dimensional convolution with a kernel size of 1 without bias, Represents the weight parameters of the convolutional layer.
8. The method according to claim 7, wherein: Abundance matrix described in step (2.5.2) Specifically: the feature F F First, the number of channels is reduced from C to R through the convolution layer, and then the Softmax operation is performed along the R dimension to obtain the abundance matrix A that satisfies the abundance non-negative constraint and the abundance sum-one constraint: A=Softmax(Conv 1×1 (F F )) Among them, Conv 1×1 (·) denotes a 2D convolution with a kernel size of 1.
9. The method according to claim 1, wherein: The loss function L in step (3) is expressed as follows: Among them, x i,j ∈X represents the hyperspectral image vector at position (i, j), represents the hyperspectral image vector reconstructed at position (i, j), λ is a hyperparameter that balances the losses of the two, ||·||1 represents the L1 norm, and ||·||2 represents the L2 norm.
10. The method according to claim 1, wherein: The abnormality detection result in step (4) is specifically calculated by The difference between the corresponding pixel in X and the square of its two-norm is obtained: Among them, r i,j Represents the anomaly detection result at position (i, j).
Citation Information
Cited By
Hyperspectral change detection method based on joint attention and diffusion model
CN121962933A
Gamma-ray spectrum filtering method and system based on mixed deep learning architecture
CN122042723A
Hyperspectral anomaly detection method based on dual-domain consistency reconstruction network
CN122244624A
Hyperspectral anomaly detection method based on dual-domain consistent reconstruction network
CN122244624B