Agricultural hyperspectral image classification method based on two-stage wavelet enhancement and attention

By employing a two-stage wavelet enhancement and attention method, and utilizing multi-axis separable convolution and wavelet transform combined with a linear attention mechanism, the problem of feature extraction difficulties in agricultural hyperspectral image classification is solved, thereby improving classification accuracy and computational efficiency.

CN120997679APending Publication Date: 2025-11-21SANYA SCI & EDUCATION INNOVATION PARK WUHAN UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511467370.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-14
Publication Date
2025-11-21

AI Technical Summary

Technical Problem

In agricultural hyperspectral image classification, existing technologies suffer from limitations in data, limited ability to extract coarse-grained features, high computational resource consumption, and weak scene adaptability, resulting in insufficient classification accuracy.

Method used

We employ a two-stage wavelet enhancement and attention-based approach. We extract coarse-grained features through multi-axis separation 3D depth-separable convolution, and combine wavelet transform and a linear attention mechanism guided by a one-dimensional spectral probe to separate fine-grained features, thereby improving classification accuracy.

Benefits of technology

It effectively solves the problem of difficulty in distinguishing spectral and spatial feature similarities in agricultural scenarios, improves classification accuracy, reduces computational load, and enhances the model's generalization ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120997679A_ABST
    Figure CN120997679A_ABST
Patent Text Reader

Abstract

The invention discloses an agricultural hyperspectral image classification method based on dual-stage wavelet enhancement and attention, and belongs to the technical field of agricultural hyperspectral image classification, and the method comprises the steps: obtaining an image construction data set, and dividing the image construction data set into a training set and a test set; after dimensionality reduction is carried out on the images in the training set, a three-dimensional feature cube is obtained through a three-dimensional convolutional layer; the features are extracted in parallel through a 3D depth separable convolution layer and then are spliced; the spliced features are fused and then converted into marks through an MLP layer; outputting image features through wavelet transform convolution operation; outputting a final attention result through a multi-head linear attention layer by taking a one-dimensional spectrum probe as guidance; a classification label is obtained through a linear layer; and training the network by using a cross loss entropy and an Adam optimizer and carrying out a test. On the basis of the optimized coarse-grained extraction method and the extracted fine-grained features, similar ground-space spectrum features are effectively separated, the agricultural hyperspectral image classification precision is improved, and agricultural monitoring and management are assisted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of agricultural hyperspectral image classification technology, specifically relating to an agricultural hyperspectral image classification method based on two-stage wavelet enhancement and attention. Background Technology

[0002] Hyperspectral imaging, as an advanced remote sensing technique, can acquire image data across hundreds of continuous spectral bands, providing far richer spectral information than traditional RGB cameras. In agriculture, hyperspectral images record the continuous spectral characteristics of crops and land surface elements, providing crucial technical support for the accurate identification of different agricultural objects and land types. The application system of this technology mainly comprises two core components: In terms of data acquisition, the hyperspectral imaging system constructs a three-dimensional spectral data cube (space × space × spectral) using high-resolution multi-band sensors, covering the spectral range from visible light to short-wave infrared, and comprehensively recording the spectral and spatial information of farmland scenes. In terms of data processing, spectral analysis technology analyzes the correlation between crop physiological characteristics, distribution patterns, and spectral features, uncovering discriminative spectral response patterns and laying the foundation for classification tasks. The combination of these two approaches allows hyperspectral data to capture subtle spectral differences in crops while preserving the spatial distribution characteristics of farmland, thus significantly improving the discriminative ability of classification models. Agricultural hyperspectral image classification is a key technology system for achieving refined identification of crops and land cover based on hyperspectral imaging technology. Its pixel-level spectral resolution capability enables precise crop identification, playing a crucial role in precision agriculture.

[0003] In recent years, deep learning technology has driven innovation in agricultural hyperspectral classification methods. Based on the structure design of convolutional neural networks, the model can automatically extract fine features in the spectral dimension and texture information in the spatial dimension from raw data, reducing reliance on manual feature engineering. Simultaneously, the introduction of an attention mechanism enables the model to dynamically identify key spectral bands and their interrelationships, improving the discriminative power of feature representation through weighted focusing. This intelligent feature learning approach effectively enhances the classification accuracy of crop types, soil properties, and vegetation status in complex farmland scenarios, providing more reliable data support for precision agriculture management.

[0004] However, unlike general scenarios, in hyperspectral image classification in agricultural settings, the gradual changes in crop physiological states and the complexity of planting structures lead to a high degree of similarity in spectral and spatial features. This results in a dual dilemma of feature dimensional redundancy and diminished inter-class separability, making spatial spectral feature extraction difficult and increasing computational demands. Traditional convolutional neural network-based methods can only obtain relatively coarse-grained spatial spectral features, far from meeting classification accuracy requirements, necessitating further fine-grained feature extraction. Furthermore, the performance of traditional coarse-grained extraction methods is quite limited. Although deep learning methods have made significant progress, they still have some limitations: 1) Data limitations: Hyperspectral datasets are difficult to obtain, have high annotation costs, and may have class sample imbalances on some datasets, resulting in limited training samples and insufficient generalization ability.

[0005] 2) Limited coarse-grained feature extraction capability: Convolutional neural networks are often stacked for preliminary feature extraction, but they lack long-range feature dependencies, and the stacking of convolutions often consumes more computational resources.

[0006] 3) Lack of effective fine-grained feature extraction methods: Deep learning methods such as multi-scale attention and Transformer require more computing resources, but the improvement in accuracy has also reached a bottleneck.

[0007] Weak scene adaptability: The spectral response of crops is affected by dynamic factors such as growth period and weather conditions, as well as the limitations of the dataset, which makes it difficult for convolutional neural networks and attention mechanisms to show superior performance in different scenarios. Summary of the Invention

[0008] To address the shortcomings of existing technologies, this invention proposes a dual-stage wavelet enhancement and attention-based method for agricultural hyperspectral image classification. This invention divides feature extraction into two stages: a coarse-grained primary spatial-spectral feature extraction stage and a fine-grained spatial-spectral feature extraction stage. In the coarse-grained feature extraction stage, 3D depthwise separable convolution with multi-axis separation is used to extract joint spatial-spectral features from different directions of the 3D hyperspectral data and the cross-band dependence of the spectrum, thus initially extracting coarse-grained spatial and spectral features. Then, wavelet transform-based convolution is used to transform the extracted 2D features to the frequency domain, and different filters are used to separate them into low-frequency subbands (LL) and high-frequency subbands (LH, HL, HH), further enhancing the features at different frequency maps. Finally, based on the one-dimensional characteristics of the spectrum, linear attention guided by a one-dimensional spectral probe is used to capture fine-grained differences between similar spectral features, and finally, a linear layer is used to obtain classification labels. This invention, based on an optimized coarse-grained extraction method and extracted fine-grained features, effectively separates similar spatial-spectral features and obtains accurate classification results.

[0009] The technical solution adopted in this invention: A method for classifying agricultural hyperspectral images based on two-stage wavelet enhancement and attention includes the following steps: Step 1: Acquire agricultural hyperspectral data images, construct a dataset, and divide it into training and test sets; Step 2: Perform dimensionality reduction on the agricultural hyperspectral data images in the training set; Step 3: Pass the dimensionality-reduced agricultural hyperspectral data image through a 3D convolutional layer, adjust the channels, and obtain a 3D feature cube; Step 4: Use a multi-axis separated 3D depth separable convolutional layer to operate on the 3D feature cube, extract local features, global spatial context and cross-band long-range dependencies in parallel, and then stitch the results of each group output according to the channel dimension to obtain the stitched features. Step 5: The spliced ​​features are fused along the channel dimension, passed through the MLP layer, and after reshaping, they are passed through two-dimensional convolution to obtain a two-dimensional feature map. The two-dimensional feature map is unfolded, and two weight matrices initialized from Gaussian distribution are used in sequence to obtain flattened one-dimensional spatial spectral features, which are then converted into labels, each label representing a feature vector. Step 6: After reshaping the markers into 2D features, wavelet transform convolution is used to separate the 2D features into low-frequency and high-frequency components, followed by layer-by-layer decomposition to obtain sub-bands. Then, the following steps are performed in different frequency spaces: Channel and depth separable convolutions enable independent processing of each subband, followed by layer-by-layer inverse transformation to reconstruct the subbands and fuse features to output image features; Step 7: Using a one-dimensional spectral probe as a guide, stitch it onto the flattened image features, calculate the attention through a multi-head linear attention layer, construct global inter-spectral dependence and discriminative band enhancement, and output the attention results; Step 8: Concatenate the attention results and image features, and obtain the classification label after passing through a linear layer; Step 9: Train the overall network constructed in steps 3-8 using cross-loss entropy and the Adam optimizer, and then test it using a test set.

[0010] Preferably, step 3 is performed as follows: The size of the dimensionality-reduced agricultural hyperspectral data image was set to 13×13×30. The number of channels was adjusted using eight 3D convolutional layers with 1×1×1 kernels to generate eight 3D feature cubes of size 13×13×30.

[0011] Preferably, the process of step 4 is as follows; The input 3D feature cube is ,in For batch size, For the number of channels, These are the depth, height, and width of the three-dimensional feature cube, respectively; Grouped along the channel dimension, denoted as , ,in To determine the grouping ratio, the channels are divided into 5 groups, as expressed by formula (1): (1) in, This is the first group of sub-feature cubes. For the second group of sub-feature cubes, This is the third group of sub-feature cubes. This is the fourth group of sub-feature cubes. This is the 5th group of sub-feature cubes. Grouping operations by channel dimension; Each group undergoes depthwise separable convolution operations with different kernels, as expressed by formulas (2)-(6) as follows: (2) (3) (4) (5) (6) in, For depthwise separable convolution, The local features are obtained from the cubic convolution kernel. The cross-band long-range dependence obtained by using a long kernel in the depth direction. , These are long kernels in the width and height directions, respectively, which perceive the global spatial context. This indicates that no operation will be performed on it, and the original sub-feature cube will be used directly; Finally, the outputs of each group after the depthwise separable convolution operation are concatenated, as expressed by formula (7): (7) in Indicates splicing characteristics, This indicates a splicing operation, which splices along the channel dimension.

[0012] Preferably, the process of step 5 is as follows: The concatenated features are passed through an MLP layer consisting of 3D convolutions with a kernel of 1. First, a 1×1×1 3D convolution is applied to the concatenated features. Channel-level fusion is performed, followed by layer normalization, GELU activation function, and Dropout operation to obtain intermediate features. Then to After performing Dropout and 1×1×1 convolution operations, the output features are obtained after passing through the MLP layer. The formulas (8)-(9) are used to express the following: (8) (9) in, For 3D convolution, layer normalization and Intermediate features of the MLP hidden layer after activation For layer normalization, For activation function, For Dropout operations, For convolution operations, The output features are those obtained after passing through the MLP layer; Output features With three-dimensional feature cube The coarse-grained features are obtained by performing residual joins, and are expressed by formula (10): (10) in, It is characterized by coarse-grainedness; Reshaping coarse-grained features , After a 3×3 2D convolution, a two-dimensional feature map is obtained. The two-dimensional feature map is then unfolded and expressed by formula (11): (11) in, To proceed with the operation, It represents a flattened, one-dimensional spatial spectral feature; The specific process of converting flattened one-dimensional spatial spectral features into labels is as follows: ,and Perform a 1×1 dot product, process it using softmax, and denot the result as follows. Then and Perform the dot product and combine it with... Multiply to obtain the label, and calculate as shown in formulas (12)-(13): (12) (13) in, This is the first weight matrix. This is the second weight matrix. Represents the number of tokens. For marking, This represents a 1×1 dot product operation. For activation function, For attention weights, This is a transpose.

[0013] Preferably, the process of step 6 is as follows: Will Remodeling into two-dimensional features Then, wavelet transform convolution is performed on it. The wavelet transform convolution operation includes multi-scale wavelet decomposition, subband processing, pyramid structure construction, inverse transform reconstruction, and feature fusion. The specific operations are as follows: Multi-scale wavelet decomposition: transforming two-dimensional features Converting to the frequency domain, separating into low and high frequencies, specifically using two-dimensional discrete wavelet transform convolution to obtain four feature sub-bands, expressed by mathematical formula (14): (14) in, It is a low-pass filter. This is a low-pass filter along the horizontal direction. This is a low-pass filter along the vertical direction. For a high-pass filter along the horizontal direction, This is a high-pass filter along the vertical direction; These are the feature sub-bands for horizontal and vertical low-pass filtering, used to extract overall smoothing features; These are feature subbands for horizontal low-pass filtering and vertical high-pass filtering, used to extract vertical edge details; These are feature subbands for horizontal high-pass filtering and vertical low-pass filtering, used to extract horizontal edge details; These are feature sub-bands for horizontal and vertical high-pass filtering, used to extract diagonal details; right conduct The first wavelet decomposition, then the... Wavelet decomposition results This can be expressed using mathematical formula (15): (15) in, For the first Low-frequency subband, For the first High-frequency subband, For the first The height and width of the features after level decomposition, and The tensor dimensions of the decomposed subbands will be downsampled by halving the height and width. The levels of decomposition; Sub-band processing: Merge the four sub-bands into Channel, through Channel and depth separable convolutions enable independent processing of each subband, as expressed by mathematical formula (16): (16) in, It can learn scaling parameters to enhance the adaptability of high-frequency features; For sub-band index, It is a two-dimensional depthwise separable convolution. For element-wise multiplication, The subband features are those after the first level of processing; Pyramid structure construction: only for low-frequency subbands The next level of decomposition is performed to form a pyramid structure, which can be expressed by formula (17): (17) in, Indicates the first Low-frequency subband Conduct the first The result set of wavelet decomposition, Indicates the first Low-frequency subband, Indicates the first High-frequency sub-band; Inverse Transform Reconstruction: After the multi-scale decomposition, subband processing, and pyramid construction operations are completed, inverse transform reconstruction is performed. The inverse transform starts from the deepest level n and reconstructs the low-frequency subbands level by level, as expressed by formula (18): (18) in, Final output ; In the formula For inverse wavelet transform, For the and After processing Sub-band of level, For the first The low-frequency subband of the reconstructed stage, For the low-frequency sub-band of the initial hierarchical reconstruction, The features obtained from the final reconstruction; Feature fusion: The final output is a linear superposition of spatial domain features and wavelet domain features, expressed by mathematical formula (19): (19) in, It is a spatial domain feature. It is a wavelet domain feature. It is a scalar that adjusts the feature weights in the wavelet domain. These are the image features ultimately output by the wavelet transform convolution operation.

[0014] Preferably, step 7 is as follows: Using a one-dimensional zero vector as a spectral probe And stitch them together with the flattened image features The spliced ​​features are obtained from the middle The concatenated features are then projected using the key and value matrices respectively. Projection can be expressed using formulas (20)-(21): (20) (twenty one) in, , These are the projection matrices for the keys and values, respectively. Features after splicing The key vector matrix, It is a value vector matrix; Then, multi-head attention is decomposed into h attention heads, which can be expressed by formula (22): (twenty two) in, For head dimension, For the first The query vector of the size For the first The key vector of the head, For the first A vector of values ​​for each head. For example; By modeling the global spectral relationship through linear attention, the calculation of attention scores and weighting values ​​is expressed by formulas (23)-(25): (twenty three) (twenty four) (25) in, for The original attention score matrix of the head, It is the minimum value. The normalized attention score. For normalization function, To perform normalization on the last dimension, For the first The weighted value of each attention head, for transpose; The results from multiple attention heads are combined and reshaped, and the output of the attention result is expressed by formula (26): (26) in, This is the result of attention.

[0015] Preferably, the attention results and image features are concatenated, and the classification labels are obtained after passing through a linear layer. The calculation is expressed by formula (27) as follows: (27) In the formula This is a linear transformation layer operation.

[0016] Preferably, in step 9, the optimization and testing are as follows: When training the overall network, the loss function is cross-entropy, optimized using the Adam algorithm, with a learning rate of 1×10⁻³ and a batch size of 64. For the WHUHi-HongHu and WHU-Hi-HanChuan datasets, the patch size is set to 13, with 1% of the samples used for training on both datasets and the remaining 99% used for testing. The training epochs are set to 150 for each dataset.

[0017] Compared with existing technologies, this invention proposes an agricultural hyperspectral image classification method based on two-stage wavelet enhancement and attention. The advantages of this method are: This invention presents an agricultural hyperspectral image classification method based on two-stage wavelet enhancement and attention, which has several significant advantages, as detailed below: 1. In this invention, a two-stage spatial spectral feature extraction method is proposed, which further extracts fine discriminative features on the basis of the original coarse-grained method that cannot meet the classification requirements. Overall, it effectively solves the problem of difficulty in distinguishing the similarity of spectral features and spatial features and the similarity between classes in agricultural scenarios.

[0018] 2. The coarse-grained extraction in this invention is optimized on the traditional convolutional neural network. It extracts spatial spectral features from local three dimensions and long kernels in multiple directions, as well as the cross-band dependence of the spectrum, which more effectively extracts primary features, thereby improving classification accuracy. At the same time, the use of depthwise separable convolution effectively controls the amount of computation.

[0019] 3. The wavelet transform convolution in this invention separates two-dimensional features into low-frequency and high-frequency spaces, and performs depth-wise convolution in different frequency spaces to enhance the sensitivity to edge texture information, thereby improving boundary classification performance to some extent and increasing the discriminativeness of spatial features.

[0020] 4. The linear complexity attention mechanism in this invention uses an empty one-dimensional spectral probe as a guide to build global inter-spectral dependencies and discriminative band enhancement, while significantly reducing the computational cost. Attached Figure Description

[0021] Figure 1 This is a network framework diagram of the agricultural hyperspectral image classification method based on two-stage wavelet enhancement and attention in this invention. Figure 2 This is a diagram illustrating the wavelet transform convolution mechanism of this invention. Figure 3 This is a diagram illustrating the spectral linear attention mechanism based on a one-dimensional spectral probe, as described in this invention. Figure 4 This is a visualization of the classification results and the actual labels of this invention on the WHU-Hi-HanChuan dataset; Figure 5 This is a visualization of the classification results and the actual labels of this invention on the WHU-Hi-HongHu dataset. Detailed Implementation

[0022] The technical solutions of the embodiments of this application will be further described clearly and completely below with reference to the accompanying drawings. It should be noted that the described embodiments are only some embodiments of this application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0023] To make the inventive objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be further described in detail below with reference to the accompanying drawings: In order to better understand the above-mentioned objectives, features, and advantages of this invention, the advantages of this invention will be further illustrated below by comparing the embodiments with the accompanying drawings and specific implementation methods.

[0024] This invention proposes a classification method for agricultural hyperspectral images based on two-stage wavelet enhancement and attention, such as... Figure 1 As shown, the steps of this method are explained in detail: Step 1: Acquire agricultural hyperspectral data images, construct a dataset, and divide it into training and test sets; Step 2: Perform dimensionality reduction on the agricultural hyperspectral data images in the training set; Step 3: Pass the dimensionality-reduced agricultural hyperspectral data image through a 3D convolutional layer, adjust the channels, and obtain a 3D feature cube; Specifically, in step 3, the process of performing a three-dimensional convolutional layer on the dimensionality-reduced agricultural hyperspectral data image, adjusting the channels, and obtaining a three-dimensional feature cube is as follows: The size of the dimensionality-reduced agricultural hyperspectral data image was set to 13×13×30. The number of channels was adjusted using eight 3D convolutional layers with 1×1×1 kernels to generate eight 3D feature cubes of size 13×13×30.

[0025] Step 4: Use a multi-axis separated 3D depth separable convolutional layer to operate on the 3D feature cube, extract local features, global spatial context and cross-band long-range dependencies in parallel, and then stitch the results of each group output according to the channel dimension to obtain the stitched features. Specifically, in step 4, the three-dimensional feature cube is operated on using a multi-axis separated 3D depth separable convolutional layer to obtain the spliced ​​features. The specific process is as follows: The input 3D feature cube is ,in For batch size, For the number of channels, These are the depth, height, and width of the three-dimensional feature cube, respectively; Grouped along the channel dimension, denoted as , ,in To determine the grouping ratio, the channels are divided into 5 groups, as expressed by formula (1): (1) in, This is the first group of sub-feature cubes. For the second group of sub-feature cubes, This is the third group of sub-feature cubes. This is the fourth group of sub-feature cubes. This is the 5th group of sub-feature cubes. Grouping operations by channel dimension; Each group performs depthwise separable convolution operations with different kernels. The first four groups use different kernels: 3×3×3 cubic convolution (extracting joint spatial-spectral local features), 1×1×11 long convolution in the spectral direction (extracting spectral cross-band dependence), 1×11×1 horizontal convolution (extracting long-range spatial context in the horizontal direction along the width), and 11×1×1 vertical convolution (extracting long-range spatial context in the vertical direction along the height). These kernels are used to extract different features. The last group does not perform any operations and retains the original features. These are expressed by formulas (2)-(6) as follows: (2) (3) (4) (5) (6) in, For depthwise separable convolution, The local features are obtained from the cubic convolution kernel. The cross-band long-range dependence obtained by using a long kernel in the depth direction. These are elongated kernels in the width and height directions, respectively, which perceive a large-scale spatial context. This indicates that no operation will be performed on it, and the original sub-feature cube will be used directly; Finally, the outputs of each group after the depthwise separable convolution operation are concatenated, as expressed by formula (7): (7) in, Indicates splicing characteristics, This indicates a splicing operation, which splices along the channel dimension.

[0026] Step 5: The spliced ​​features are fused along the channel dimension, passed through the MLP layer, and after reshaping, they are passed through two-dimensional convolution to obtain a two-dimensional feature map. The two-dimensional feature map is unfolded, and two weight matrices initialized from Gaussian distribution are used in sequence to obtain flattened one-dimensional spatial spectral features, which are then converted into labels, each label representing a feature vector. Specifically, in step 5, the stitched features are fused along the channel dimension, processed by an MLP layer, and unfolded into flattened one-dimensional spatial-spectral features. These features are then converted into labels through two weight matrices. The specific process is as follows: The stitched features are passed through an MLP layer composed of 3D convolutions with a kernel of 1, performing linear combination along the channel dimension while maintaining the spatial-spectral dimension. This results in a significantly lower parameter count than fully connected layers, while preserving the three-dimensional structure and adapting to hyperspectral images. The stitched features are first processed by a 1×1×1 three-dimensional convolution. Channel-level fusion is performed, followed by layer normalization, GELU activation function, and Dropout operation to obtain intermediate features. Then to After performing Dropout and 1×1×1 convolution operations, the output features are obtained after passing through the MLP layer. The formulas (8)-(9) are used to express the following: (8) (9) in, For 3D convolution, layer normalization and Intermediate features of the MLP hidden layer after activation For layer normalization, For activation function, For Dropout operations, For convolution operations, The output features are those obtained after passing through the MLP layer; Output features With three-dimensional feature cube The coarse-grained features are obtained by performing residual joins, and are expressed by formula (10): (10) in, It is characterized by coarse-grainedness; Reshaping coarse-grained features , After a 3×3 2D convolution, a two-dimensional feature map is obtained. The two-dimensional feature map is then unfolded and expressed by formula (11): (11) in, To proceed with the operation, It represents a flattened, one-dimensional spatial spectral feature; Flattened one-dimensional spatial spectral features are converted into tags to separate as many different features as possible. Token similarity calculations are used to separate features based on class inconsistency. The specific process is as follows: ,and Perform a 1×1 dot product, apply softmax, and denot the result as A; then... and Perform a dot product and multiply it by A to obtain the label, and calculate as shown in formulas (12)-(13): (12) (13) in, This is the first weight matrix. This is the second weight matrix, where t represents the number of tokens. For marking, This represents a 1×1 dot product operation. For activation function, For attention weights, This is a transpose.

[0027] Step 6: After reshaping the markers into 2D features, wavelet transform convolution is used to separate the 2D features into low-frequency and high-frequency components, followed by layer-by-layer decomposition to obtain sub-bands. Then, the following steps are performed in different frequency spaces: Channel and depth separable convolutions enable independent processing of each subband, followed by layer-by-layer inverse transformation to reconstruct the subbands and fuse features to output image features; Specifically, in step 6, after converting the markers into 2D features, wavelet transform convolution is used to decompose each sub-band layer by layer. C×4 channel and depthwise separable convolution are performed in different frequency spaces to achieve independent processing of each sub-band. Then, the sub-bands are reconstructed level by level and the features are fused to output image features, such as... Figure 2 As shown, the specific process is as follows: Will Remodeling into two-dimensional features Then, wavelet transform convolution is performed on it. The wavelet transform convolution operation includes multi-scale wavelet decomposition, subband processing, pyramid structure construction, inverse transform reconstruction, and feature fusion. The specific operations are as follows: Multi-scale wavelet decomposition: transforming two-dimensional features Converted to the frequency domain, it is separated into low frequency and high frequency. The low frequency represents structural information such as contour background, while the high frequency features represent texture details and edge information. By separating them, crops with similar features can be better distinguished, overcoming the challenge of overlapping frequency components in agricultural HSI. At the same time, the wavelet transform convolution operation function has obvious sensitivity. Specifically, four feature subbands are obtained by using two-dimensional discrete wavelet transform convolution, which can be expressed by mathematical formula (14): (14) in, It is a low-pass filter. For a low-pass filter along the horizontal direction (row), For a low-pass filter along the vertical direction (column), For high-pass filters along the horizontal direction (row), For high-pass filters along the vertical direction (column); These are feature sub-bands for horizontal and vertical low-pass filtering, used to extract overall smoothing features; These are feature subbands for horizontal low-pass filtering and vertical high-pass filtering, used to extract vertical edge details; These are feature subbands for horizontal high-pass filtering and vertical low-pass filtering, used to extract horizontal edge details; These are feature sub-bands for horizontal and vertical high-pass filtering, used to extract diagonal details; right Performing n-level (the total number of levels in the wavelet decomposition) wavelet decomposition, then the nth wavelet... Wavelet decomposition results This can be expressed using mathematical formula (15): (15) in, For the first Low-frequency subband, For the first High-frequency subband, For the first The height and width of the features after level decomposition, and The tensor dimensions of the decomposed subbands will be downsampled by halving the height and width. The levels of decomposition; Sub-band processing: Merge the four sub-bands into Channel, through Channel and depth separable convolutions enable independent processing of each subband to enhance useful information, as expressed by mathematical formula (16): (16) in, It can learn scaling parameters to enhance the adaptability of high-frequency features; For sub-band index, It is a two-dimensional depthwise separable convolution. For element-wise multiplication, The subband features are those after the first level of processing; Pyramid structure construction: only for low-frequency subbands The next level of decomposition is performed to form a pyramid structure, which can be expressed by formula (17): (17) in, Indicates the first Low-frequency subband Conduct the first The result set of wavelet decomposition, Indicates the first Low-frequency subband, Indicates the first High-frequency sub-band; Inverse transform reconstruction: After the multi-scale decomposition, subband processing, and pyramid construction operations are completed, inverse transform reconstruction is performed. The inverse transform starts from the deepest level n and reconstructs the low-frequency subbands level by level to preserve multi-scale information, as expressed by formula (18): (18) in, Final output ; In the formula For inverse wavelet transform, For the and After processing Sub-band of level, For the first The low-frequency subband of the reconstructed stage, For the low-frequency sub-band of the initial hierarchical reconstruction, The features obtained from the final reconstruction; Feature fusion: The final output is a linear superposition of spatial domain features and wavelet domain features, expressed by mathematical formula (19): (19) in, It is a spatial domain feature. It is a wavelet domain feature. It is a scalar that adjusts the feature weights in the wavelet domain. These are the image features ultimately output by the wavelet transform convolution operation.

[0028] Step 7: Using a one-dimensional spectral probe as a guide, stitch it onto the flattened image features. Through a multi-head linear attention layer, calculate the attention, construct global inter-spectral dependence and discriminative band enhancement, and output the attention results. At the same time, its linear complexity is greatly reduced and the amount of computation is reduced. Specifically, in step 7, a one-dimensional spectral probe is used as a guide to stitch the probe onto the flattened image features. A multi-head linear attention layer is then used to calculate attention, constructing global inter-spectral dependence and discriminative band enhancement, and outputting the attention result, such as... Figure 3 As shown, the specific steps are as follows: Using a one-dimensional zero vector as a spectral probe And stitch them together with the flattened image features The spliced ​​features are obtained from the middle The concatenated features are then projected using the key and value matrices respectively. Projection can be expressed using formulas (20)-(21): (20) (twenty one) in, These are the projection matrices for the keys and values, respectively. Features after splicing The key vector matrix, It is a value vector matrix; The projected features are decomposed into h attention heads using multi-head attention decomposition, as expressed by formula (22): (twenty two) in, For head dimension, For the first The query vector of the size For the first The key vector of the head, For the first A vector of values ​​for each head. For example; By modeling the global spectral relationship through linear attention, the calculation of attention scores and weighting values ​​is expressed by formulas (23)-(25): (twenty three) (twenty four) (25) in, for The original attention score matrix of the head, It is the minimum value. The normalized attention score. For normalization function, To perform normalization on the last dimension, For the first The weighted value of each attention head, for transpose; The results from multiple attention heads are combined and reshaped, and the final attention output is expressed by formula (26): (26) in, This is the result of attention.

[0029] Step 8: Concatenate the attention results and image features, and obtain the classification label after passing through a linear layer; Specifically, step 8 is as follows: The attention results and image features are concatenated, and after passing through a linear layer, the classification labels are obtained. The calculation is expressed by formula (27) as follows: (27) In the formula For linear transformation layer operations; Step 9: Train the overall network constructed in steps 3-8 using cross-loss entropy and the Adam optimizer, and then test it using a test set; Specifically, in step 9, the optimization and testing are as follows: When training the overall network, the loss function is cross-entropy, optimized using the Adam algorithm, with a learning rate of 1×10⁻³ and a batch size of 64. For the WHUHi-HongHu and WHU-Hi-HanChuan datasets, the patch size is set to 13, with 1% of the samples used for training on both datasets and the remaining 99% used for testing. The training epochs are set to 150 for each dataset.

[0030] The specific simulation experiments of this invention are described in detail with reference to the technical solutions and accompanying drawings, such as... Figure 4 As shown, the details are as follows: The environment used in this embodiment is a server with an Intel Xeon(R) Silver 4210R CPU, 64GB RAM, and an NVIDIA Quadro RTX 5000 16GB GPU, which provides efficient parallel computing support for the task of hyperspectral image classification; at the same time, the method of this invention is implemented using the PyTorch framework. The retrieval accuracy was calculated and tested, as detailed below: The network trained above was used to perform calculations on samples in the test set, and the classification results were evaluated using the following three key evaluation metrics: overall accuracy (OA), average accuracy (AA), and Kappa coefficient. The higher the values ​​of these three indicators, the better the classification result; To evaluate the effectiveness of the method proposed in this invention, two agricultural hyperspectral classification datasets (WHU-Hi-HongHu dataset and WHU-Hi-HanChuan dataset) were used, and several representative methods were selected for comparative experiments on the two agricultural hyperspectral classification datasets. The representative methods are: ContextualNet, SSRN, A2S2KResNet, SSFTT, LSFAT, SANet, SPTNet, CSCANet, and the DSW-LAN method proposed in this invention. For ContextualNet, SSRN, A2S2KResNet, SSFTT, LSFAT, SANet, SPTNet, CSCANet, and DSW-LAN methods, in order to eliminate the interference of parameter setting differences on experimental results and ensure that the performance of the method of this invention can be compared with other methods under fair conditions, the experimental parameter settings are kept consistent with the parameter settings in the content of this invention. Thus, a comparison table of experimental results for two agricultural hyperspectral classification datasets is obtained (as shown in Table 1 and Table 2) to facilitate a fairer comparison of performance. At the same time, while ensuring the performance of the method, the parameter size of the network model is minimized as much as possible. Table 1

[0031] Table 1 shows the comparative experimental results of this invention and other methods on the WHU-HI-HONGHU dataset; as can be seen from Table 1, the DSW-LAN method of this invention achieves better overall accuracy (OA), average accuracy (AA), and Kappa coefficient (A). In all three evaluation metrics, the results are superior to those of ContextualNet, SSRN, A2S2KResNet, SSFTT, LSFAT, SANet, SPTNet, and CSCANet, which fully demonstrates the superior classification performance of the method in this invention on this dataset. Table 2

[0032] Table 2 shows the comparative experimental results of this invention with other methods on the WHU-HI-HANCHUAN dataset; as can be seen from Table 2, on the WHU-HI-HANCHUAN dataset, the DSW-LAN method of this invention achieves better overall accuracy (OA), average accuracy (AA), and Kappa coefficient. In terms of [specific aspects], it is also significantly superior to other comparative methods, further verifying the effectiveness and generalization ability of the method of the present invention; Experiments demonstrate that the agricultural hyperspectral image classification method of this invention exhibits state-of-the-art performance on two challenging agricultural hyperspectral classification datasets (WHU-Hi-HongHu dataset and WHU-Hi-HanChuan dataset). Statistical analysis through repeated experiments (ten experiments) reveals that the proposed DSW-LAN method has the smallest standard deviation compared to other comparative methods. Furthermore, the proposed method achieves state-of-the-art accuracy on most land cover categories in both datasets.

[0033] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0034] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method for classifying agricultural hyperspectral images based on two-stage wavelet enhancement and attention, characterized in that, include: Step 1: Acquire agricultural hyperspectral data images, construct a dataset, and divide it into training and test sets; Step 2: Perform dimensionality reduction on the agricultural hyperspectral data images in the training set; Step 3: Pass the dimensionality-reduced agricultural hyperspectral data image through a 3D convolutional layer, adjust the channels, and obtain a 3D feature cube; Step 4: Use a multi-axis separated 3D depth separable convolutional layer to operate on the 3D feature cube, extract local features, global spatial context and cross-band long-range dependencies in parallel, and then stitch the results of each group output according to the channel dimension to obtain the stitched features. Step 5: The spliced ​​features are fused along the channel dimension, passed through the MLP layer, and after reshaping, they are passed through two-dimensional convolution to obtain a two-dimensional feature map. The two-dimensional feature map is unfolded, and two weight matrices initialized from Gaussian distribution are used in sequence to obtain flattened one-dimensional spatial spectral features, which are then converted into labels, each label representing a feature vector. Step 6: After reshaping the markers into 2D features, wavelet transform convolution is used to separate the 2D features into low-frequency and high-frequency components, followed by layer-by-layer decomposition to obtain sub-bands. Then, the following steps are performed in different frequency spaces: Channel and depth separable convolutions enable independent processing of each subband, followed by layer-by-layer inverse transformation to reconstruct the subbands and fuse features to output image features; Step 7: Using a one-dimensional spectral probe as a guide, stitch it onto the flattened image features, calculate the attention through a multi-head linear attention layer, construct global inter-spectral dependence and discriminative band enhancement, and output the attention results; Step 8: Concatenate the attention results and image features, and obtain the classification label after passing through a linear layer; Step 9: Train the overall network constructed in steps 3-8 using cross-loss entropy and the Adam optimizer, and then test it using a test set.

2. The agricultural hyperspectral image classification method based on two-stage wavelet enhancement and attention as described in claim 1, characterized in that, The process of step 3 is as follows: The size of the dimensionality-reduced agricultural hyperspectral data image was set to 13×13×30. The number of channels was adjusted using eight 3D convolutional layers with 1×1×1 kernels to generate eight 3D feature cubes of size 13×13×30.

3. The agricultural hyperspectral image classification method based on two-stage wavelet enhancement and attention as described in claim 1, characterized in that, The specific process of step 4 is as follows; The input 3D feature cube is ,in For batch size, For the number of channels, These are the depth, height, and width of the three-dimensional feature cube, respectively; Grouped along the channel dimension, denoted as , ,in To determine the grouping ratio, the channels are divided into 5 groups, as expressed by formula (1): (1) in, This is the first group of sub-feature cubes. For the second group of sub-feature cubes, This is the third group of sub-feature cubes. This is the fourth group of sub-feature cubes. This is the 5th group of sub-feature cubes. Grouping operations by channel dimension; Each group undergoes depthwise separable convolution operations with different kernels, as expressed by formulas (2)-(6) as follows: (2) (3) (4) (5) (6) in, For depthwise separable convolution, The local features are obtained from the cubic convolution kernel. The cross-band long-range dependence obtained by using a long kernel in the depth direction. , These are long kernels in the width and height directions, respectively, which perceive the global spatial context. This indicates that no operation will be performed on it, and the original sub-feature cube will be used directly; Finally, the outputs of each group after the depthwise separable convolution operation are concatenated, as expressed by formula (7): (7) in, Indicates splicing characteristics, This indicates a splicing operation, which splices along the channel dimension.

4. The agricultural hyperspectral image classification method based on two-stage wavelet enhancement and attention as described in claim 1, characterized in that, The specific process of step 5 is as follows: The concatenated features are passed through an MLP layer consisting of 3D convolutions with a kernel of 1. First, a 1×1×1 3D convolution is applied to the concatenated features. Channel-level fusion is performed, followed by layer normalization, GELU activation function, and Dropout operation to obtain intermediate features. Then to After performing Dropout and 1×1×1 convolution operations, the output features are obtained after passing through the MLP layer. The formulas (8)-(9) are used to express the following: (8) (9) in, For 3D convolution, layer normalization and Intermediate features of the MLP hidden layer after activation For layer normalization, For activation function, For Dropout operations, For convolution operations, The output features are those obtained after passing through the MLP layer; Output features With three-dimensional feature cube The coarse-grained features are obtained by performing residual joins, and are expressed by formula (10): (10) in, It is characterized by coarse-grainedness; Reshaping coarse-grained features , After a 3×3 2D convolution, a two-dimensional feature map is obtained. The two-dimensional feature map is then unfolded and expressed by formula (11): (11) in, To proceed with the operation, It represents a flattened, one-dimensional spatial spectral feature; The specific process of converting flattened one-dimensional spatial spectral features into labels is as follows: ,and Perform a 1×1 dot product, apply softmax, and denot the result as A; then... and Perform a dot product and multiply it by A to obtain the label, as shown in formulas (12)-(13): (12) (13) in, This is the first weight matrix. This is the second weight matrix, where t represents the number of tokens. For marking, This represents a 1×1 dot product operation. For activation function, For attention weights, This is a transpose.

5. The agricultural hyperspectral image classification method based on two-stage wavelet enhancement and attention as described in claim 1, characterized in that, The process of step 6 is as follows: Will Remodeling into two-dimensional features Then, wavelet transform convolution is performed on it. The wavelet transform convolution operation includes multi-scale wavelet decomposition, subband processing, pyramid structure construction, inverse transform reconstruction, and feature fusion. The specific operations are as follows: Multi-scale wavelet decomposition: transforming two-dimensional features Converting to the frequency domain, separating into low and high frequencies, specifically using two-dimensional discrete wavelet transform convolution to obtain four feature sub-bands, expressed by mathematical formula (14): (14) in, It is a low-pass filter. This is a low-pass filter along the horizontal direction. This is a low-pass filter along the vertical direction. For a high-pass filter along the horizontal direction, This is a high-pass filter along the vertical direction; These are the feature sub-bands for horizontal and vertical low-pass filtering, used to extract overall smoothing features; These are feature subbands for horizontal low-pass filtering and vertical high-pass filtering, used to extract vertical edge details; These are feature subbands for horizontal high-pass filtering and vertical low-pass filtering, used to extract horizontal edge details; These are feature sub-bands for horizontal and vertical high-pass filtering, used to extract diagonal details; right Performing n-level wavelet decomposition, then the... Wavelet decomposition results This can be expressed using mathematical formula (15): (15) in, For the first Low-frequency subband, For the first High-frequency subband, For the first The height and width of the features after level decomposition, and The tensor dimensions of the decomposed subbands will be downsampled by halving the height and width. The levels of decomposition; Sub-band processing: Merge the four sub-bands into Channel, through Channel and depth separable convolutions enable independent processing of each subband, as expressed by mathematical formula (16): (16) in, It can learn scaling parameters to enhance the adaptability of high-frequency features; For sub-band index, It is a two-dimensional depthwise separable convolution. For element-wise multiplication, The subband features are those after the first level of processing; Pyramid structure construction: only for low-frequency subbands The next level of decomposition is performed to form a pyramid structure, which can be expressed by formula (17): (17) in, Indicates the first Low-frequency subband Conduct the first The result set of wavelet decomposition, Indicates the first Low-frequency subband, Indicates the first High-frequency sub-band; Inverse Transform Reconstruction: After the multi-scale decomposition, subband processing, and pyramid construction operations are completed, inverse transform reconstruction is performed. The inverse transform starts from the deepest level n and reconstructs the low-frequency subbands level by level, as expressed by formula (18): (18) in, Final output ; In the formula For inverse wavelet transform, For the and After processing Sub-band of level, For the first The low-frequency subband of the reconstructed stage, For the low-frequency sub-band of the initial hierarchical reconstruction, The features obtained from the final reconstruction; Feature fusion: The final output is a linear superposition of spatial domain features and wavelet domain features, expressed by mathematical formula (19): (19) in, It is a spatial domain feature. It is a wavelet domain feature. It is a scalar that adjusts the feature weights in the wavelet domain. These are the image features ultimately output by the wavelet transform convolution operation.

6. The agricultural hyperspectral image classification method based on two-stage wavelet enhancement and attention as described in claim 1, characterized in that, The specific steps of step 7 are as follows: Using a one-dimensional zero vector as a spectral probe And stitch them together with the flattened image features The spliced ​​features are obtained from the middle The concatenated features are then projected using the key and value matrices respectively. Projection can be expressed using formulas (20)-(21): (20) (21) in, , These are the projection matrices for the keys and values, respectively. Features after splicing The key vector matrix, It is a value vector matrix; Then, multi-head attention is decomposed into h attention heads, which can be expressed by formula (22): (22) in, For head dimension, For the first The query vector of the size For the first The key vector of the head, For the first A vector of values ​​for each head. For example; By modeling the global spectral relationship through linear attention, the calculation of attention scores and weighting values ​​is expressed by formulas (23)-(25): (23) (24) (25) in, for The original attention score matrix of the head, It is the minimum value. The normalized attention score. For normalization function, To perform normalization on the last dimension, For the first The weighted value of each attention head, for transpose; The results from multiple attention heads are combined and reshaped, and the output of the attention result is expressed by formula (26): (26) in, This is the result of attention.

7. The agricultural hyperspectral image classification method based on two-stage wavelet enhancement and attention as described in claim 1, characterized in that, Step 8 is described in detail below: The attention results and image features are concatenated, and after passing through a linear layer, the classification label is obtained. The calculation is expressed by formula (27) as follows: (27) In the formula This is a linear transformation layer operation.