A farmland plot segmentation method combining a polymeric multi-layer attention mechanism and edge features
Patent Information
- Application Number
- CN202311491921.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-09
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2043-11-09
AI Technical Summary
然而对于场景复杂的农业环境,尤其是耕地和其他地物(如林地、草地)易混分的区域,仅从单一的空间特征提取角度就容易导致耕地提取的误差增加,从而降低算法的准确性
[0038]本发明技术效果:本发明针对传统深度学习网络中边缘定位模糊的问题,充分融合语义特征以及边缘轮廓特征,提出了一种聚合多层注意力机制与边缘特征的耕地地块分割方法;首先,采用多层次结构对耕地地块进行特征提取,并针对不同层次分辨率精度不同的情况,采用不同的特征融合方法:针对低层网络分别提取边缘信息和自注意力特征,进行通道融合;针对高层网络由于经过多层卷积,边缘信息弱化,则提取深度语义信息;然后在解码器部分,采用一种空间增强方法进一步加强语义特征和边缘特征之间的融合,并将解码器与编码器对应输出进行跨越连接;最后将测试数据集输入到训练好的模型中得到耕地地块的提取结果。
Smart Images

Figure CN117523396B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of land use monitoring technology, and in particular relates to a method for dividing cultivated land parcels by aggregating multi-layer attention mechanisms and edge features. Background Technology
[0002] Arable land is the most basic material condition for agricultural production, bearing multiple functions such as food supply, energy cycling, and ecological regulation. Arable land plot extraction is the process of dividing arable land into multiple plots, each containing the same crop. In order to make rational use of arable land resources, it is necessary to accurately and efficiently extract arable land crop plots. However, traditional plot extraction methods usually require a lot of manpower, material resources, and time, and often cannot guarantee the accuracy and real-time nature of the extraction results.
[0003] Traditional methods for land parcel extraction commonly rely on remote sensing imagery. These methods interpret satellite remote sensing images to extract land cover information and then delineate individual land parcels. Traditional methods often require remote sensing image analysis, soil testing, and manual surveys, consuming significant manpower, resources, and time. Furthermore, they are cumbersome and struggle to guarantee extraction accuracy. Different regions and crop types may require different characteristics, making these methods less universally applicable. Simultaneously, due to the complexity of remote sensing imagery and the diversity of land use changes, conventional methods often fail to meet practical needs, exhibiting certain shortcomings.
[0004] Machine learning is a technology that builds models based on data and automatically performs pattern recognition and prediction, which can help improve the accuracy and efficiency of farmland plot extraction. Currently, many machine learning methods are applied to farmland plot extraction, such as support vector machines, random forests, and convolutional neural networks. However, traditional machine learning algorithms mainly rely on manually designed features for classification, which has certain subjectivity and limitations in feature selection and classifier design. To address these issues, using deep learning for farmland crop plot extraction has become a research hotspot. Deep learning can learn from large amounts of remote sensing imagery and farmland data to obtain relatively accurate plot extraction models. However, in complex agricultural environments, especially areas where farmland is easily confused with other land features (such as woodland and grassland), relying solely on single spatial feature extraction can easily lead to increased errors in farmland extraction, thus reducing the accuracy of the algorithm. Summary of the Invention
[0005] To address the aforementioned technical problems, this invention proposes a method for segmenting farmland plots that integrates multi-layer attention mechanisms and edge features, thereby improving the accuracy of farmland plot segmentation.
[0006] To achieve the above objectives, this invention provides a method for farmland parcel segmentation that integrates multi-layer attention mechanisms and edge features, comprising:
[0007] Acquire the original image, preprocess the original image, and obtain the preprocessed original image;
[0008] A deep learning model integrating multi-layer attention mechanism and edge features is constructed. The preprocessed original image is input into the deep learning model and an encoder is used for hierarchical processing to extract edge feature maps and self-attention feature maps.
[0009] The edge feature map and the self-attention feature map are enhanced by a decoder to obtain a spatial feature map;
[0010] The mapping between the spatial feature map and the preprocessed original feature map is weighted and summed to obtain a weighted fused feature map;
[0011] The decoder performs cross-connections on the weighted fused feature map to obtain a spatially enhanced feature map;
[0012] Based on the spatially enhanced feature map, the channel dimension is adjusted by a single convolution function to obtain the farmland segmentation result;
[0013] The weighted sum of the cross-entropy function and the Dice function is used to evaluate the farmland segmentation results to obtain the evaluation results.
[0014] Optionally, preprocessing the original image to obtain a preprocessed original image includes:
[0015] The original image is randomly divided into pixel blocks of size h×w, which are divided into m blocks in total;
[0016] Each pixel block has three RGB channels, and the dimensions of each pixel block are h×w×3;
[0017] The training set, test set, and validation set are divided in a 3:1:1 ratio.
[0018] Optionally, the preprocessed original image is input into the deep learning model and subjected to hierarchical processing using an encoder to extract edge feature maps and self-attention feature maps, including:
[0019] The entire network has four layers, corresponding to four different resolutions. The input to each layer is f. i (i = 1, 2, 3, 4), f i The self-attention feature module (SAM) and edge feature module (EFM) of each layer are input to obtain the attention feature map and edge feature map of that layer, respectively. and The output feature dimensions of each network layer are 128×128×32, 64×64×64, 32×32×128, and 16×16×256, respectively.
[0020] Optionally, feature enhancement is performed on the edge feature map and the self-attention feature map using a decoder to obtain a spatial feature map, including:
[0021]
[0022]
[0023] Where Conc is the concatenation function, representing the concatenation of the attention feature map along the channel dimension. and edge feature map Then, the parts are assembled.
[0024] Optionally, the mapping between the spatial feature map and the preprocessed original feature map is weighted and summed to obtain a weighted fused feature map, including:
[0025]
[0026] Among them, Conv 1 This represents a convolution operation with a kernel size of 1×1. Represents spatial feature map, This represents the weighted fusion feature map.
[0027] Optionally, the decoder performs cross-connections on the weighted fused feature map to obtain a spatially enhanced feature map, including:
[0028]
[0029] Among them, Conv 1 This represents a convolution operation with a kernel size of 1×1. Represents the weighted fusion feature map, ω i For spatial enhancement feature maps.
[0030] Optionally, based on the spatially enhanced feature map, the channel dimension is adjusted through a single convolution function to obtain the farmland segmentation result, including:
[0031]
[0032] Among them, y pre Indicates the result of farmland partitioning, Conv 1 This represents a convolution operation with a kernel size of 1×1. This indicates the output of the decoder.
[0033] Optionally, the weighted sum of the cross-entropy function BCE and the Dice function is used to evaluate the farmland partitioning results, and the evaluation results include:
[0034]
[0035]
[0036] L SPA =β1·L BCE +β2·L Dice
[0037] in, Let y represent the predicted probability of the i-th pixel. i L represents the true label value of the i-th pixel, N represents the total number of pixels, and L represents the true label value of the i-th pixel. SPA Let β1 and β2 represent the loss function and the weighting factors, respectively.
[0038] Technical effects of this invention: This invention addresses the problem of ambiguous edge localization in traditional deep learning networks by fully integrating semantic features and edge contour features. It proposes a method for farmland segmentation that integrates multi-layer attention mechanisms and edge features. First, a multi-layer structure is used to extract features from farmland plots. Different feature fusion methods are employed to address the varying resolution and accuracy at different levels: for lower-layer networks, edge information and self-attention features are extracted separately, followed by channel fusion; for higher-layer networks, where edge information is weakened due to multiple convolutions, deep semantic information is extracted. Then, in the decoder section, a spatial enhancement method is used to further strengthen the fusion between semantic and edge features, and cross-connections are established between the decoder and encoder outputs. Finally, the test dataset is input into the trained model to obtain the extracted farmland plots. Attached Figure Description
[0039] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0040] Figure 1 This is a flowchart illustrating a method for segmenting farmland plots that integrates multi-layer attention mechanisms and edge features, according to an embodiment of the present invention.
[0041] Figure 2 This is a schematic diagram of a method for segmenting farmland plots that integrates multi-layer attention mechanisms and edge features according to an embodiment of the present invention.
[0042] Figure 3 This is a schematic diagram of the structure of the self-attention feature module (SAM) and the edge feature module (EFM) in an embodiment of the present invention;
[0043] Figure 4 This is an image showing the results of farmland extraction in an embodiment of the present invention, where the black portion represents farmland and the white portion represents the background;
[0044] Figure 5The graph shows the changes in loss function and accuracy during the training process of the model in this embodiment of the invention. Detailed Implementation
[0045] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0046] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0047] like Figure 1 As shown in the figure, this embodiment provides a method for segmenting cultivated land parcels by aggregating multi-layer attention mechanisms and edge features. Its structural schematic diagram is shown below. Figure 2 As shown, it specifically includes:
[0048] Step 1: Dataset Construction: The original dataset has an image resolution of 8000. px ×8000 px To meet the input requirements of the model, the image was randomly divided into m pixel blocks of size h×w. Each pixel block has three RGB channels, so the dimension of each pixel block is h×w×3. Data augmentation techniques were used to improve generalization ability, such as flipping, rescaling, cropping, Gaussian blurring, and introducing noise. The training, test, and validation sets were divided in a 3:1:1 ratio. In the experiments, the resolution of each pixel block was set to h = w = 128, the batch size was set to 32, and the number of training epochs was set to 100. To save time and computational resources, the model was validated every 5 epochs, with weight decay set to 0.99 and learning rate set to 0.001.
[0049] Step 2: Input the training set data into the constructed model for training. A deep learning model that integrates multi-layer attention mechanism and edge features is proposed. Unet is used as the backbone network. In the encoder part, a hierarchical processing method is used to obtain semantic features and edge features. In the decoder part, the fusion of the two feature maps is strengthened to achieve effective segmentation of farmland images.
[0050] The entire network has four layers, corresponding to four different resolutions. The input to each layer is f. i (i = 1, 2, 3, 4), f i The inputs are fed into the Self-Attention Feature Module (SAM) and Edge Feature Module (EFM) of each layer (see structural diagram). Figure 3(As shown) The attention feature map and edge feature map of this layer are obtained respectively. and The output feature dimensions of each network layer are 128×128×32, 64×64×64, 32×32×128, and 16×16×256, respectively.
[0051] Step 3: Generate Spatial Feature Maps: The self-attention features and edge features obtained in Step 2 are fused. Since the resolution decreases significantly with increasing network layer count, hindering edge feature acquisition, different strategies are used to process different network layer counts to enable faster network convergence and generate more representative features. This yields edge-enhanced spatial feature maps at layers 1 and 2. The spatial resolution of the output from layers 3 and 4 of the network is low, making it difficult to capture farmland edge features. Therefore, a method is adopted. As a spatial feature map:
[0052]
[0053]
[0054] Where Conc is the concatenation function, representing the concatenation along the channel dimension. and Then, the parts are assembled.
[0055] Step 4: Generate a weighted fusion feature image: Combine the spatial feature map obtained in Step 3 with the fusion image. The weighted sum of the mappings to the original image is used to obtain the weighted output feature map:
[0056]
[0057] Where Conv 1 This represents a convolution operation with a kernel size of 1×1.
[0058] Step 5: Process the feature image in the decoder section. The feature matrix g is obtained by performing multiple convolutions. i (i = 1, 2, 3, 4), and sequentially perform cross-connections between the convolution results and the output spatial feature maps of the corresponding encoder modules. To preserve richer detail features and avoid spatial feature loss, a feature enhancement mechanism is proposed in the cross-connection part to better aggregate spatial and edge features. First, the spatial weight matrix ω of the encoder output results of each layer is obtained. i :
[0059]
[0060] The upsampled feature map g iMultiplying with the spatial weight matrix yields the spatial augmented feature G. i Then, the enhanced feature map is fused with the current upsampling result, and finally, the dimension of the decoder result is reconstructed through a convolutional block to obtain the output of the current layer decoder.
[0061] Step 6: Obtain the output result through 4 upsampling operations. Will The final segmentation result y is obtained by adjusting the channel dimensions through a single convolution function. pre .
[0062]
[0063] Step 7: Use the weighted sum of the cross-entropy function and the dice function as the loss function L. SPA To evaluate the segmentation results.
[0064]
[0065]
[0066] L SPA =β1·L BCE +β2·L Dice
[0067] in, y represents the true value label (0 or 1) of the i-th pixel. i Let L represent the predicted probability of the i-th pixel, and N represent the total number of pixels. This is achieved through the construction of L... SPA The loss function can simultaneously consider both contextual semantic information and edge structure information. Weighting factors β1 and β2 are used to balance these two aspects. Therefore, the semantic results of the image can maintain higher accuracy and clearer boundaries.
[0068] Step 8: Input the test set data into the trained deep learning model, evaluate the model training results, and observe how the loss function and accuracy change during the training process. Figure 5 As shown.
[0069] Step 9: Finally, the farmland in the experiment is divided, and the visualization results are as follows. Figure 4 As shown, accuracy, recall, Kappa coefficient, and intersection-over-union ratio (IoU) were selected as evaluation metrics to assess model performance.
[0070] To explain this method in detail, the specific implementation of the key steps is given first. Step 2 includes the following steps:
[0071] Step 2.1: For the input f of each layer of the networki Perform a linear transformation to obtain the query vector Q. i Key vector K i Value vector V i :
[0072]
[0073]
[0074]
[0075] In the above formula These are the linear transformation coefficients of vectors Q, K, and V, respectively. These are the linear transformation biases of vectors Q, K, and V, respectively.
[0076] Step 2.2: Then, calculate the self-attention feature map of the current layer using the scaling dot product formula:
[0077]
[0078] Step 2.3: For the input f of each layer of the network i The edge feature extraction module obtains the convolution results of the current input at different dilation rates, thereby acquiring multi-view spatial perception information.
[0079]
[0080] Step 2.4: Reconstruct the dimensions of the multi-view feature information through a convolutional module to obtain weighted edge features.
[0081]
[0082] In the above formula, ConBlock is a convolution block function that includes a 1×1 convolution operation, a BatchNorm operation, and a sigmoid function:
[0083] ConBlock 1 =Sigmoid{BN[Conv 1 (·)]}
[0084] Step 2.5: Fuse the current input feature map with the weighted edge features to obtain the edge feature map.
[0085]
[0086] In the above formula This represents the Hadman product operation.
[0087] Step 5 specifically includes the following steps:
[0088] Step 5.1: Obtain the spatial weight matrix of each encoder layer through convolution operations:
[0089]
[0090] Step 5.2: Upsample the feature map g. i Multiplying with the spatial weight matrix yields the spatial augmented feature G. i :
[0091]
[0092] Step 5.3: Enhance the feature map G i Compared with the current upsampling result g i The results are fused together, and finally, the dimensionality of the decoder result is reconstructed through a convolutional block to obtain the output of the current layer's decoder.
[0093]
[0094] Step 6 specifically includes the following steps:
[0095] Step 6.1: Upsample the result of step 5.3 and use it as the input for the next upsampling module:
[0096]
[0097] The feature map dimensions obtained after upsampling are: 16×16×256, 32×32×128, 64×64×64, and 128×128×32.
[0098] Step 6.2: The result of the last layer is adjusted for channel dimensions using a convolution function to obtain the final segmentation result y. pre .
[0099]
[0100] In the above formula, y pre The dimensions are: 128×128×1.
[0101] Step 9 specifically includes the following steps:
[0102] Step 9.1: Select accuracy, recall, Kappa coefficient, and intersection-over-union ratio (IoU) as evaluation metrics to assess model performance.
[0103] Accuracy=(TP+TN) / (TP+TN+FP+FN)
[0104] Recall = TP / (TP + FN)
[0105] Kappa = (P o -P e ) / (1-P e )
[0106] IoU = TP / (FN + FP + TP)
[0107] In the above formula, TP represents a true positive, TN represents a true negative, FP represents a false positive, and FN represents a false negative. o It refers to accuracy, P. e It is the sum of the products of the actual and predicted quantities for each category, divided by the square of the total number of samples.
[0108] After model training, the accuracy, recall, Kappa coefficient, and crossover ratio of farmland extraction under the model of this invention were 92.3%, 90.78%, 89.33%, and 85.2%, respectively.
[0109] This invention utilizes a Unet network framework that integrates multi-layer attention mechanisms and edge features to extract features from farmland plots and segment the farmland. First, the encoder performs multi-layer feature extraction on the original image, employing different feature extraction methods at different resolution levels. Lower-layer networks construct edge information modules and self-attention feature modules, highlighting local contour features while preserving global information, followed by feature fusion. Higher-layer networks primarily extract deep semantic information. Image features are obtained through layer-by-layer encoding. Then, a feature enhancement mechanism is employed in the decoder to strengthen the fusion of multi-source features, and the final model output is obtained through layer-by-layer decoding.
[0110] The above are merely preferred embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for segmenting cultivated land parcels by integrating multi-layer attention mechanisms and edge features, characterized in that, Includes the following steps: Acquire the original image, preprocess the original image, and obtain the preprocessed original image; A deep learning model integrating multi-layer attention mechanism and edge features is constructed. The preprocessed original image is input into the deep learning model and an encoder is used for hierarchical processing to extract edge feature maps and self-attention feature maps. A spatial feature map is obtained by performing feature enhancement on the edge feature map and the self-attention feature map using an encoder; The mapping between the spatial feature map and the preprocessed original feature map is weighted and summed to obtain a weighted fused feature map; The decoder performs cross-connections on the weighted fused feature map to obtain a spatially enhanced feature map; Based on the spatially enhanced feature map, the channel dimension is adjusted by a single convolution function to obtain the farmland segmentation result; The weighted sum of the cross-entropy function and the Dice function is used to evaluate the farmland segmentation results to obtain the evaluation results.
2. The method for farmland parcel segmentation by aggregating multi-layer attention mechanisms and edge features as described in claim 1, characterized in that, Preprocessing the original image to obtain the preprocessed original image includes: The original image is randomly segmented into The pixel blocks of size are divided into: indivual; Each pixel block has three RGB channels, and the dimension of each pixel block is... ; The training set, test set, and validation set are divided in a 3:1:1 ratio.
3. The method for farmland plot segmentation based on the aggregation of multi-layer attention mechanisms and edge features as described in claim 1, characterized in that, The preprocessed original image is input into the deep learning model and subjected to hierarchical processing using an encoder to extract edge feature maps and self-attention feature maps, including: The entire network has four layers, corresponding to four different resolutions. The input to each layer is... ,Will The self-attention feature module (SAM) and edge feature module (EFM) of each layer are input to obtain the attention feature map and edge feature map of that layer, respectively. and The output feature dimensions of each network layer are respectively , , , .
4. The method for farmland parcel segmentation by aggregating multi-layer attention mechanisms and edge features as described in claim 1, characterized in that, The spatial feature map is obtained by performing feature enhancement on the edge feature map and the self-attention feature map using an encoder, including: in, The concatenation function represents the concatenation of attention feature maps along the channel dimension. and edge feature map Then, the parts are assembled.
5. The method for farmland parcel segmentation by aggregating multi-layer attention mechanisms and edge features as described in claim 1, characterized in that, The mapping between the spatial feature map and the preprocessed original feature map is weighted and summed to obtain a weighted fused feature map, including: in, This indicates that the kernel size is 1. Convolution operation of 1, Represents spatial feature map, This represents the weighted fusion feature map.
6. The method for farmland parcel segmentation by aggregating multi-layer attention mechanisms and edge features as described in claim 1, characterized in that, The decoder performs cross-connections on the weighted fused feature map to obtain a spatially enhanced feature map, including: The spatial weight matrix of each encoder layer is obtained through convolution operations: ; in, This indicates that the kernel size is 1. Convolution operation of 1, This represents the weighted fusion feature map. This is the spatial weight matrix; Weighted fusion feature map Perform multiple upconvolutions to obtain upsampled feature maps. Upsampled feature map Multiplying with the spatial weight matrix yields the spatial augmentation feature. : ; spatial augmentation feature map Compared with the current upsampled feature map The fusion process involves reconstructing the dimension of the decoder result using a convolutional block to obtain the output of the current layer's decoder. : 。 7. The method for farmland parcel segmentation by aggregating multi-layer attention mechanisms and edge features as described in claim 1, characterized in that, Based on the spatially enhanced feature map, the farmland segmentation results are obtained by adjusting the channel dimension through a single convolution function, including: in, This indicates the result of farmland partitioning. This indicates that the kernel size is 1. Convolution operation of 1, This indicates the output of the decoder.
8. The method for farmland parcel segmentation by aggregating multi-layer attention mechanisms and edge features as described in claim 1, characterized in that, The weighted sum of the cross-entropy function BCE and the Dice function is used to evaluate the farmland partitioning results, and the evaluation results include: in, Indicates the first i The true value label of each pixel, Indicates the first i The predicted probability of a pixel, where N represents the total number of pixels. Represents the loss function. and This represents the weighting factor.
Citation Information
Patent Citations
High-resolution remote sensing image land coverage classification method based on local detail enhancement and edge constraint
CN113343789A
Cultivated land extraction method based on collaborative edge detection and space attention mechanism
CN116844042A