High-resolution remote sensing image building extraction method of multi-scale mixed Transform model based on boundary refinement
By using a multi-scale hybrid Transformer model based on boundary refinement in remote sensing images to extract and fuse different scale feature maps, the problem of irregular and fuzzy building boundaries is solved and higher extraction accuracy and robustness are achieved.
Patent Information
- Application Number
- CN202410631136.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-21
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-05-21
AI Technical Summary
When extracting buildings from high-resolution remote sensing images, the existing technology has the problems of missing or incorrectly extracting small buildings, as well as irregular and blurred building boundaries, making it difficult to effectively capture the boundary information and local details of buildings.
A multi-scale hybrid Transformer model based on boundary refinement is used to extract different scale feature maps through the multi-scale hybrid Transformer encoder, and the edge enhancement module and group feature alignment fusion module are used in the decoder to enhance the edge representation of low-level features and high-level features. The fusion of semantic information improves the segmentation accuracy of building boundaries.
It improves the accuracy and robustness of building extraction, can segment building boundaries more clearly, reduces the impact of background noise in non-building areas, and enhances the ability to identify building shapes and structures.
Smart Images

Figure CN118570634A
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of remote sensing image recognition and relates to a high-resolution remote sensing image building extraction method based on a multi-scale hybrid Transformer model with boundary refinement. Background Art
[0002] With the continuous development of remote sensing technology and the widespread application of high-resolution remote sensing images, the extraction of buildings from high-resolution remote sensing images has attracted widespread attention in the remote sensing community. Accurately extracting buildings is of great significance for population estimation, disaster assessment, and environmental protection urban planning. However, due to the diversity of building appearance and size, the complexity of the surrounding environment of buildings, as well as occlusion and shadows, accurately extracting buildings from high-resolution remote sensing images remains an important challenge. When facing the problem of multi-scale object segmentation, there are many deep learning-based methods for building extraction. For example, PSPNet uses a spatial pyramid pooling module to inherit multi-scale context, but the extraction of large-scale context comes at the expense of spatial resolution. The Deeplab family integrates the atrous spatial pyramid pooling module into a deep convolutional neural network to capture multi-scale context information without losing resolution.
[0003] In recent years, with the rapid development of convolutional neural networks (CNNs), the task of building extraction has ushered in a favorable breakthrough. The introduction of the fully convolutional network (FCN) applied the fully convolutional network structure to this field for the first time, which aroused the interest of many researchers who focused on designing encoder-decoder architectures to achieve more accurate building extraction. They proposed many CNN-based building extraction frameworks. These methods have improved the extraction accuracy of buildings to a certain extent. However, these methods are limited by the convolution operation of buildings and it is difficult to effectively model global context information. Due to the huge differences in the shapes and sizes of buildings, the surrounding environment may also be very complex, such as the possibility of trees or shadows, which makes it difficult to accurately infer building targets from local context information.
[0004] In recent years, with the rapid development of convolutional neural networks (CNNs), the task of building extraction has ushered in a favorable breakthrough. The introduction of the fully convolutional network (FCN) first applied the fully convolutional network structure to this field. Compared with the CNN-based method, the Transformer has a strong global modeling ability. Although the Transformer has shown advantages in extracting global information, local detail features (such as building edges) are also crucial in the task of building extraction. These details can provide key information about the shape, structure, and boundaries of the building. In this context, introducing CNN methods in the Transformer to enhance the ability to extract local information has become the key to solving the balance between local and global contextual information. By fusing the global modeling ability of the Transformer and the local feature extraction ability of the CNN, the hybrid Transformer can better understand the overall structure of the building in the image, thereby improving the accuracy and robustness of building extraction. Although serial, parallel, or cross-linking the CNN model with the Transformer model can improve the extraction of local and global features, this undoubtedly greatly increases the computational cost.
[0005] In the encoder, low-level features carry local detail information such as the edges of buildings, however, they are also mixed with a large amount of background noise in non-building areas. Directly fusing these low-level features with high-level features in the decoder may lead to semantic ambiguity, and the edge representation becomes weaker, which makes it difficult for the model to distinguish the edge pixels of buildings when recovering spatial detail information, resulting in blurred building edge extraction. In addition, when performing feature aggregation, the high-level feature map needs to be upsampled to the same size as the low-level feature map. However, due to the misalignment problem between feature maps at different levels, the model may not be able to accurately capture the boundary information of the building, thereby affecting the accuracy of building extraction. In addition, small buildings may be blocked by trees, other buildings or sunshade facilities, or cast shadows due to poor lighting conditions, which will cause the model to fail to detect them correctly, affecting the accuracy and robustness of the entire building extraction process. Summary of the invention
[0006] In view of this, the purpose of the present invention is to provide a high-resolution remote sensing image building extraction method based on a multi-scale hybrid Transformer model with boundary refinement, so as to solve the problems of missing or wrong extraction of small buildings and irregular and blurred building boundaries in the current building extraction methods.
[0007] In order to achieve the above object, the present invention provides the following technical solutions:
[0008] A method for extracting buildings from high-resolution remote sensing images based on a multi-scale hybrid Transformer model with boundary refinement, the method comprising:
[0009] S1. Perform data preprocessing and data enhancement on remote sensing optical images;
[0010] S2, input the processed training set data into the hybrid CNN and Transformer encoder to extract feature maps of four different scales in four stages;
[0011] S3, sequentially inputting the encoded features from the fourth stage to the first stage into the decoder for decoding, wherein the low-level features extracted from the first two stages are input into the edge enhancement module for edge refinement, and the decoder combines the low-level features of the encoder of the previous stage step by step and fuses them through the group feature alignment fusion module, and finally obtains the prediction graph;
[0012] S4. The above model is trained by back propagation method and used for building extraction from remote sensing images after training.
[0013] Further, in step S1, in terms of data preprocessing, the acquired remote sensing building dataset image is cropped in an overlapping manner, and the label pixels of the annotated image are converted to 0 or 1, and then the cropped dataset is divided into a training set, a validation set, and a test set according to the proportion;
[0014] In terms of data enhancement, data enhancement is used on the training set, including random size scaling of the data set, random horizontal and vertical flipping, random Gaussian noise, limited contrast adaptive histogram equalization, random rotation and random cropping methods.
[0015] Furthermore, in step S2, the given RGB image is divided into several image blocks of the same size, and then these image blocks are input into the multi-scale hybrid Transformer encoder. After passing through each stage in turn, four feature maps with a resolution of {1 / 4, 1 / 8, 1 / 16, 1 / 32} of the original image are obtained, where the number of feature map channels in each stage is recorded as C1 to C4;
[0016] Among them, the multi-scale hybrid Transformer encoder has four stages, and the feature maps in the encoding of the multi-scale hybrid Transformer encoder in the four stages are recorded as F1, F2, F3, and F4 respectively. Correspondingly, four decoders are set for the four stages, among which the feature map in the decoder of the first stage is D4, the feature map in the decoder of the second stage is D3, the feature map in the decoder of the third stage is D2, and the feature map in the decoder of the fourth stage is D1. Among them, the features F1 and F2 obtained in the first and second stages are low-level features; when decoding, the feature F2 in the fourth stage is decoded first, followed by F3, F2, and F1 in turn;
[0017] The multi-scale hybrid Transformer encoder at each stage consists of an overlapping patch merging layer and multiple Hybridformer Blocks;
[0018] Each overlapping patch merging layer consists of a convolutional layer and a LayerNorm regularization layer, and the feature map vector after the overlapping patch merging layer is passed into the Hybridformer Block; each Hybridformer Block includes: a multi-scale local perception module and a global perception module;
[0019] The multi-scale local perception module MSLP is as follows: first, the feature map is input into the deep convolution IDConv that can adapt to different inputs; the feature map after IDConv is divided into three groups of feature maps according to the channel dimension, where i = 1, 2, 3, and they are input into the deep convolution of 1×1, 3×3 and 5×5 respectively;
[0020] The results are cascaded and fused according to the channel dimension to obtain a feature map with multi-scale information;
[0021] Two fully connected layers and Gaussian error linear unit GELU activation are used to enhance the nonlinear representation of local features and finally generate feature maps. The entire MSLP module is expressed as:
[0022] X1,X2,X3=Channelsplit(IDConv(X in ))
[0023] X′=Concat(DWConv 1×1 (X1),DWConv 3×3 (X2),DWConv 5×5 (X3))
[0024] X local =X in +Linear(GELU(Linear(X′)))
[0025] Among them, IDConv represents the input-dependent deep convolution, ChannelSplit represents the division of the feature map by channel dimension, and GELU represents the Gaussian error linear unit;
[0026] The global perception module is specifically composed of an efficient self-attention layer and a mixed feedforward position encoding Mix-FFN layer. The efficient self-attention layer downsamples K and V in the original Q, K, V; the Mix-FFN layer includes a 3×3 convolution layer; there is a regularization layer before entering the efficient self-attention and Mix-FFN modules, and a residual connection is used after each module.
[0027] Further, in step S3, the following steps are included:
[0028] S31, firstly input the fourth stage feature F4 into the decoder to obtain the decoded high-level feature D1; input the fourth stage decoded high-level feature D1 and the third stage high-level feature F3 together into the group feature alignment fusion module to obtain the third stage alignment feature D2;
[0029] S32, inputting the low-level features F2 of the second stage, the high-level features D1 after decoding of the fourth stage, and the alignment features D2 of the third stage into the edge enhancement module to obtain the low-level features enhanced in the second stage, and inputting the low-level features enhanced in the second stage and the alignment features D2 of the third stage into the group alignment module to obtain the alignment features D3 of the second stage;
[0030] S33, input the low-level features F1 of the first stage, the decoded high-level features D1 of the fourth stage, the aligned features D2 of the third stage, and the aligned features D3 of the second stage into the edge enhancement module to obtain the low-level features enhanced in the first stage, input the low-level features enhanced in the first stage and the aligned features D3 of the second stage into the group feature alignment and fusion module for alignment and fusion, and obtain the final prediction map, which is used as the final building segmentation result.
[0031] Further, in step S31, the process of performing feature alignment and fusion by the group feature alignment and fusion module is as follows:
[0032] Given a decoder high-level feature F high and the low-level features F of the encoder in the previous stage low , F high Perform 1×1 convolution and bilinear upsampling so that F high Dimension and F low Consistently obtain features Then F low and At the same time, 1×1 convolution is used to compress the number of channels to obtain the feature map F l ' ow With Fh ' igh :
[0033]
[0034]
[0035] F l ' ow =Conv 1×1 (F low )
[0036] The two feature maps are concatenated and input into the 3×3 convolutional layer to obtain the predicted semantic flow field Δ low , the semantic flow field is expressed as:
[0037] Δ low =Conv 3×3 (Concat(F h ' igh ,F l ' ow ))
[0038] Then Divide into G groups according to the channel dimension, that is in Each sub-feature is associated with each point p on the spatial grid of the semantic flow field. high Mapped to F by simple addition operation low The new point p in low , and then use the differentiable bilinear sampling mechanism to high Linear interpolation is performed on the four nearest neighbor pixel values to obtain
[0039] Then each set of features after alignment Connect along the channel dimension to generate the final result Specifically expressed as:
[0040]
[0041]
[0042]
[0043] Where N(p high ) indicates F high Middle twist point p high The neighboring points involved, ω p represents the bilinear kernel weights estimated locally by the distorted grid;
[0044] Finally, the concatenation operation and 3×3 convolution are used to fuse the layers. and F low , the specific process is as follows:
[0045]
[0046] in represents the high-level features after alignment, F low Represents the low-level features of the encoder in the previous stage.
[0047] Further, in step S32, the feature map of the second stage among the four stage feature maps generated by the multi-scale hybrid Transformer encoder is input into the boundary enhancement module, and the fused feature maps output by the last two stages of the decoder are input into the boundary enhancement module, wherein the edge enhancement module of the second stage includes:
[0048] Take the feature F2 in the second stage encoder and the features D1 and D2 in the third and fourth stage decoders as input;
[0049] Use three 1×1 convolutions to unify the dimensions of D1 and D2 to be consistent with F2, and upsample them to the same size as F2;
[0050] The unified D1 and D2 are cascaded according to the channel dimension, and then a 3×3 convolution is used to generate a weight matrix W of the same dimension as F2;
[0051] Use the fast Fourier transform (FFT) layer to convert F2 and the weight parameter W to the frequency domain at the same time, then multiply F2 and W element by element, and use the inverse fast Fourier transform (IFFT) to convert F2 from the frequency domain back to the spatial domain to generate the feature map F, and then input F into LN and MLP to generate the final feature F with strong edge information and architectural semantic information. edge ;
[0052] The process of the entire edge enhancement module is expressed as:
[0053]
[0054]
[0055]
[0056] in, Represents C j convolution kernel, MLP stands for multi-layer perceptron, FFT stands for fast Fourier transform, IFFT stands for inverse fast Fourier transform, Up stands for upsampling, and LN stands for LayerNorm regularization.
[0057] Further, in step S33, the feature map of the first stage among the four stage feature maps generated by the multi-scale hybrid Transformer encoder is input into the boundary enhancement module, and the fused feature maps output by the last three stages of the decoder are input into the boundary enhancement module; wherein the process of obtaining enhanced features through the edge enhancement module of the first stage includes:
[0058] Take the feature F1 in the first stage encoder and the features D1, D2, D3 in the second, third, and fourth stage decoders as input;
[0059] Use three 1×1 convolutions to unify the dimensions of D1, D2, and D3 to be consistent with F1, and upsample them to the same size as F1;
[0060] The unified D1, D2, and D3 are cascaded according to the channel dimension, and then a 3×3 convolution is used to generate a weight matrix W of the same dimension as F1;
[0061] Use the fast Fourier transform (FFT) layer to convert F1 and the weight parameter W to the frequency domain at the same time, then multiply F1 and W element by element, and use the inverse fast Fourier transform (IFFT) to convert F1 from the frequency domain back to the spatial domain to generate the feature map F, and then input F into LN and MLP to generate the final feature F with strong edge information and architectural semantic information. edge ;
[0062] The process of the entire edge enhancement module is expressed as:
[0063]
[0064]
[0065]
[0066] in, Represents C j convolution kernel, MLP stands for multi-layer perceptron, FFT stands for fast Fourier transform, IFFT stands for inverse fast Fourier transform, Up stands for upsampling, and LN stands for LayerNorm regularization.
[0067] Further, in step S4, the AdamW optimizer and the poly learning rate adjustment strategy are used, the cross entropy loss function is used to calculate the loss between the predicted image and the true image, and the loss is reduced by back propagation;
[0068] The specific loss calculation method is: calculate the cross entropy loss between the final predicted image obtained in S4 and the real image. The cross entropy loss calculation formula is as follows:
[0069]
[0070] Where N represents the total number of pixels in the image, y i ∈{0,1} represents the true label of pixel i, represents the probability that pixel i belongs to category 1.
[0071] The beneficial effects of the present invention are:
[0072] First, the present invention proposes a high-resolution remote sensing image building extraction framework based on a multi-scale hybrid Transformer model with boundary refinement, which can fully combine the advantages of CNN and Transformer to extract multi-scale local and global information.
[0073] Secondly, the present invention proposes an edge enhancement module to control the information flow from the encoder to the decoder, utilizes the high-level features with rich semantic information in the decoder to enhance the edge representation of the low-level features in the encoder, and suppresses irrelevant background noise in non-building areas, thereby improving the segmentation results of building boundaries.
[0074] Third, the present invention proposes a group alignment feature fusion module to align feature maps of different levels at adjacent levels, so that high-level features containing rich contextual information and low-level features containing rich spatial detail information are effectively fused.
[0075] Other advantages, objectives and features of the present invention will be described in the following description to some extent, and to some extent, will be obvious to those skilled in the art based on the following examination and study, or can be taught from the practice of the present invention. The objectives and other advantages of the present invention can be realized and obtained through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention will be described in detail below in conjunction with the accompanying drawings, wherein:
[0077] Figure 1 It is a flow chart of the method for extracting buildings from high-resolution remote sensing images based on a multi-scale hybrid Transformer model with boundary refinement according to the present invention;
[0078] Figure 2 The model architecture diagram of the high-resolution remote sensing image building extraction method based on the multi-scale hybrid Transformer model with boundary refinement in the present invention;
[0079] Figure 3 Schematic diagram of the Transformer Block module structure in the encoder of the present invention;
[0080] Figure 4 It is a schematic diagram of an example of the building extraction effect of the present invention. DETAILED DESCRIPTION
[0081] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the illustrations provided in the following embodiments only illustrate the basic concept of the present invention in a schematic manner, and the following embodiments and features in the embodiments can be combined with each other without conflict.
[0082] Among them, the drawings are only used for illustrative explanations, and they only represent schematic diagrams rather than actual pictures, and should not be understood as limitations on the present invention. In order to better illustrate the embodiments of the present invention, some parts of the drawings may be omitted, enlarged or reduced, and do not represent the size of actual products. For those skilled in the art, it is understandable that some well-known structures and their descriptions in the drawings may be omitted.
[0083] The same or similar numbers in the drawings of the embodiments of the present invention correspond to the same or similar parts; in the description of the present invention, it should be understood that if the terms "upper", "lower", "left", "right", "front", "rear", etc. indicate the orientation or position relationship, they are based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation. Therefore, the terms describing the position relationship in the drawings are only used for illustrative purposes and cannot be understood as limiting the present invention. For ordinary technicians in this field, the specific meanings of the above terms can be understood according to specific circumstances.
[0084] See also Figure 1 to Figure 4 , which is a high-resolution remote sensing image building extraction method based on a multi-scale hybrid Transformer model with boundary refinement.
[0085] like Figure 1 The flowchart of the method for extracting buildings from high-resolution remote sensing images based on a multi-scale hybrid Transformer model with boundary refinement is shown, which includes:
[0086] S1. Perform data preprocessing and data enhancement on remote sensing optical images;
[0087] S2, input the processed training set data into the hybrid CNN and Transformer encoder to extract feature maps of four different scales in four stages;
[0088] S3, sequentially inputting the encoded features from the fourth stage to the first stage into the decoder for decoding, wherein the low-level features extracted from the first two stages are input into the edge enhancement module for edge refinement, and the decoder combines the low-level features of the encoder of the previous stage step by step and fuses them through the group feature alignment fusion module, and finally obtains the prediction graph;
[0089] S4. The above model is trained by back propagation method and used for building extraction from remote sensing images after training.
[0090] Example
[0091] This embodiment uses the Massachusetts building dataset as a data sample to introduce the extraction method of the present invention in detail.
[0092] Further, in step S1, the acquired remote sensing building dataset image is cropped in an overlapping manner, and the label pixels of the annotated image are converted to 0 or 1, and then the cropped dataset is divided into a training set, a validation set, and a test set in a ratio of 8:1:1, and data enhancement is used in the training process;
[0093] Specifically, the original 5000×5000 images of the Massachusetts building dataset are cropped to 256×256 using a sliding window with a stride of 128. The dataset is divided into three sub-datasets, namely the training set, the validation set, and the test set. The pixel values of the building areas of the label images in the dataset are set to 1, and the other pixels are set to 0.
[0094] During the model training process, data augmentation is applied to the training dataset, including random resizing, random horizontal flipping and vertical flipping, random Gaussian noise, limited contrast adaptive histogram equalization, random rotation, and random cropping. The random resizing ratio is 0.5-2.0. Random horizontal flipping, vertical flipping, random Gaussian noise, limited contrast adaptive histogram equalization, and random rotation are processed with a probability of 50%. The random rotation angle is in the range of (-180, 180). Finally, the processed images are randomly cropped with a crop size of 256×256. All augmentation methods are applied to the training set.
[0095] Further, in step S2, the building features are extracted from the input remote sensing image through a multi-scale hybrid Transformer encoder to obtain feature maps of different scales in four stages;
[0096] Specifically, first, the given 256×256×3 RGB image is divided into 4×4 image blocks, and then these image blocks are input into the multi-scale hybrid Transformer encoder. After passing through each stage in turn, four feature maps with resolutions of {1 / 4, 1 / 8, 1 / 16, 1 / 32} of the original image are obtained, where the number of feature map channels C1~C4 in each stage is {64, 128, 256, 512} respectively.
[0097] Among them, the multi-scale hybrid Transformer encoder has four stages, and the feature maps output by the four-stage multi-scale hybrid Transformer encoder are recorded as F1, F2, F3, and F4 respectively. Correspondingly, four decoders are set for the four stages, among which the feature map in the decoder of the first stage is D4, the feature map in the decoder of the second stage is D3, the feature map in the decoder of the third stage is D2, and the feature map in the decoder of the fourth stage is D1. Among them, the features F1 and F2 obtained in the first and second stages are low-level features. During decoding, the feature F2 in the fourth stage is decoded first, followed by F3, F2, and F1. Figure 2 As shown, each stage includes an overlapping patch merging layer and multiple Hybridformer Blocks, each Hybridformer is a hybrid CNN and Transformer feature extraction module, and the present invention sets the number of Hybridformer Blocks in each stage to {3, 4, 18, 3} respectively;
[0098] Each overlapping patch merging layer consists of a convolution layer with a kernel size of 7, a stride of 4, and a padding of 3, and a LayerNorm regularization layer. The feature map vector after the overlapping patch merging layer is passed into HybridformerBlock, such as Figure 3 As shown, each Hybridformer Block includes: a multi-scale local perception module and a global perception module;
[0099] Specifically, the multi-scale local perception module first inputs the feature map into the input-dependent deep convolution (IDConv) so that it can dynamically adapt to changes in the input.
[0100] In order to capture multi-scale information, the feature maps after IDConv are divided into three groups of feature maps according to the channel dimension, where i = 1, 2, 3, and are input into 1×1, 3×3 and 5×5 deep convolutions respectively;
[0101] The results are then cascaded and fused according to the channel dimension to obtain a feature map with rich multi-scale information.
[0102] Finally, two fully connected layers and Gaussian error linear unit (GELU) activation are used to enhance the nonlinear representation of local features and finally generate feature maps. The entire MSLP module can be expressed as:
[0103] X1,X2,X3=Channelsplit(IDConv(X in ))
[0104] X′=Concat(DWConv 1×1 (X1),DWConv 3×3 (X2),DWConv 5×5 (X3))
[0105] X local =X in +Linear(GELU(Linear(X′)))
[0106] Among them, IDConv represents the deep convolution that depends on the input, ChannelSplit represents splitting the feature map according to the channel dimension, and GELU represents the Gaussian error linear unit.
[0107] The global perception module consists of an efficient self-attention layer and a mixed feedforward position encoding Mix-FFN layer. The efficient self-attention layer downsamples K and V in the original Q, K, V to reduce computational complexity. Mix-FFN includes a 3×3 convolution layer. There is a regularization layer before entering the efficient self-attention and Mix-FFN modules, and a residual connection is used after each module.
[0108] Further, in step S3, the following steps are included:
[0109] S31, firstly input the fourth stage feature F4 into the decoder to obtain the decoded high-level feature D1; input the fourth stage decoded high-level feature D1 and the third stage high-level feature F3 together into the group feature alignment fusion module to obtain the third stage alignment feature D2;
[0110] S32, inputting the low-level features F2 of the second stage, the high-level features D1 after decoding of the fourth stage, and the alignment features D2 of the third stage into the edge enhancement module to obtain the low-level features enhanced in the second stage, and inputting the low-level features enhanced in the second stage and the alignment features D2 of the third stage into the group alignment module to obtain the alignment features D3 of the second stage;
[0111] S33, input the low-level features F1 of the first stage, the decoded high-level features D1 of the fourth stage, the aligned features D2 of the third stage, and the aligned features D3 of the second stage into the edge enhancement module to obtain the low-level features enhanced in the first stage, input the low-level features enhanced in the first stage and the aligned features D3 of the second stage into the group feature alignment and fusion module for alignment and fusion, and obtain the final prediction map, which is used as the final building segmentation result.
[0112] More specifically, in step S31, the high-level features of 8×8×512 dimensions output by the fourth stage of the encoder are first input into the decoder, and the high-level features and the encoder features of the previous stage are simultaneously input into the group feature alignment fusion module for fusion. The group feature alignment fusion module includes:
[0113] First, given the decoder high-level features F high and the low-level features F of the encoder in the previous stage low , F high Perform 1×1 convolution and bilinear upsampling so that F high Dimension and F low Consistently obtain features Then, F low and At the same time, 1×1 convolution is used to compress the number of channels to reduce the amount of calculation, and finally the feature map F is obtained. l ' ow With F h ' igh :
[0114]
[0115]
[0116] F l ' ow =Conv 1×1 (F low )
[0117] Then, the two feature maps are concatenated and the concatenated feature maps are input into the 3×3 convolutional layer to obtain the predicted semantic flow field Δ low , the semantic flow field is expressed as:
[0118] Δ low =Conv 3×3 (Concat(F h ' igh ,F l ' ow ))
[0119] Then, Divide into G groups according to the channel dimension, that is in Each sub-feature is associated with each point p on the spatial grid of the semantic flow field. high Mapped to F by simple addition operation low The new point p in low , and then use the differentiable bilinear sampling mechanism
[13] to high Linear interpolation is performed on the four nearest neighbor pixel values to obtain
[0120]
[0121] Then each set of features after alignment Connect along the channel dimension to generate the final result Specifically expressed as:
[0122]
[0123]
[0124]
[0125] Where N(p high ) indicates F high Middle twist point p high The neighboring points involved, ω p represents the bilinear kernel weight estimated locally by the distorted grid. Finally, this embodiment fuses and F low , the specific process is as follows:
[0126]
[0127] in represents the high-level features after alignment, F low Represents the low-level features of the encoder in the previous stage.
[0128] Then, the features after the group feature alignment fusion module are used as high-level features in the decoder to continue the same operation with the low-level feature maps of the second and first stages of the decoder, and finally a feature map with a dimension of 64×64×64 is obtained. Then, 1×1 convolution is used to classify the feature map, and finally, the image is upsampled to the original image size through bilinear interpolation to obtain the final building segmentation result.
[0129] Furthermore, in step S32, the feature map of the second stage among the four stage feature maps generated by the multi-scale hybrid Transformer encoder is input into the edge enhancement module, and the fused feature map output by the last two stages of the decoder is input into the edge enhancement module. The edge enhancement module of the second stage includes:
[0130] First, the feature F2 in the encoder of the second stage and the features D1 and D2 in the decoders of the second and third stages are used as inputs; for the feature maps D1 and D2, since their dimensions are different from those of F2, this embodiment uses three 1×1 convolutions to unify their dimensions to be consistent with F2, and then uniformly upsamples them to the same size as F2, and then cascades them according to the channel dimension, and then uses 3×3 convolutions to generate a weight matrix W with the same dimension as F2. Then, we use the fast Fourier transform (FFT) layer to convert F2 and the weight parameter W to the frequency domain at the same time, and then multiply F2 and W element by element, and use the inverse fast Fourier transform (IFFT) to convert F2 from the frequency domain back to the spatial domain to generate the feature map F, and then input F into LN and MLP to generate the final feature F with strong edge information and architectural semantic information. edge , the entire edge enhancement module can be expressed as:
[0131]
[0132]
[0133]
[0134] in, Represents C j convolution kernel, MLP stands for multi-layer perceptron, FFT stands for fast Fourier transform, IFFT stands for inverse fast Fourier transform, Up stands for upsampling, and LN stands for LayerNorm regularization.
[0135] Furthermore, in step S33, the feature map of the first stage among the four stage feature maps generated by the multi-scale hybrid Transformer encoder is input into the boundary enhancement module, and the fused feature maps output by the last three stages of the decoder are input into the boundary enhancement module.
[0136] Among them, the edge enhancement module of the first stage includes:
[0137] First, the feature F1 in the encoder of the first stage and the features D1, D2, and D3 in the decoders of the second, third, and fourth stages are used as input; for the feature maps D1, D2, and D3, since their dimensions are different from those of F1, this embodiment uses three 1×1 convolutions to unify their dimensions to be consistent with F1, and then uniformly upsamples them to the same size as F1, and then cascades them according to the channel dimension, and then uses 3×3 convolutions to generate a weight matrix W with the same dimension as F1. Then, we use the fast Fourier transform (FFT) layer to convert F1 and the weight parameter W to the frequency domain at the same time, and then multiply F1 and W element by element, and use the inverse fast Fourier transform (IFFT) to convert F1 from the frequency domain back to the spatial domain to generate the feature map F, and then input F into LN and MLP to generate the final feature F with strong edge information and architectural semantic information. edge , the entire edge enhancement module can be expressed as:
[0138]
[0139]
[0140]
[0141] in, Represents C j convolution kernel, MLP stands for multi-layer perceptron, FFT stands for fast Fourier transform, IFFT stands for inverse fast Fourier transform, Up stands for upsampling, and LN stands for LayerNorm regularization.
[0142] Additionally, in step S4, during the model training process of the present invention, the AdamW optimizer and the poly learning rate adjustment strategy are used, the cross entropy loss function is used to calculate the loss between the predicted graph and the true graph, and the loss is reduced by back propagation;
[0143] Specifically, batch training is adopted, and the batch size is 16. The present invention uses the AdamW optimizer and the Poly learning rate adjustment strategy, the learning rate is set to 0.0006, and the weight decay is 0.00025.
[0144] The specific loss calculation method is: calculate the cross entropy loss between the final predicted image obtained in S4 and the real image. The cross entropy loss calculation formula is as follows:
[0145]
[0146] Where N represents the total number of pixels in the image, y i ∈{0,1} represents the true label of pixel i, represents the probability that pixel i belongs to category 1.
[0147] This embodiment selects OA, Precision, Recall, F1_Score, and Iou as evaluation indicators, inputs the test data into the trained model, and calculates the confusion matrix between the prediction results and the true values. Specifically, the evaluation indicator Precision is the accuracy rate, and the equation is:
[0148] Precision=(TP) / (TP+FP)
[0149] The evaluation index Recall is the recall rate, and the equation is:
[0150] Recall=(TP) / (TP+FN)
[0151] The evaluation index F1_Score is the harmonic mean of precision and recall, and the equation is:
[0152] F1_Score=(2×Presicion×Recall) / (Precision+Recall)
[0153] The evaluation index Iou is the intersection-union ratio, and the equation is:
[0154] Iou=(TP) / (TP+FP+FN)
[0155] Among them, TP, TN, FP, and FN in the equation are respectively expressed as follows: TP is the number of samples correctly predicted as positive; TN is the number of samples correctly predicted as negative; FP is the number of samples incorrectly predicted as positive; FN is the number of samples incorrectly predicted as negative.
[0156] Use the test set data to select four test set images for testing and obtain the final building extraction results, such as Figure 4 As shown, it can be seen that even if there are shadows and other objects blocking the building, the model can still accurately segment the boundary of the building, which can prove the effectiveness of the present invention in extracting building boundary details.
[0157] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution, which should be included in the scope of the claims of the present invention.
Claims
1. A method for extracting buildings from high-resolution remote sensing images based on a multi-scale hybrid Transformer model with boundary refinement, characterized in that: The method comprises: S1. Perform data preprocessing and data enhancement on remote sensing optical images; S2, input the processed training set data into the hybrid CNN and Transformer encoder to extract feature maps of four different scales in four stages; S3, sequentially inputting the encoded features from the fourth stage to the first stage into the decoder for decoding, wherein the low-level features extracted from the first two stages are input into the edge enhancement module for edge refinement, and the decoder combines the low-level features of the encoder of the previous stage step by step and fuses them through the group feature alignment fusion module, and finally obtains the prediction graph; S4. The above model is trained by back propagation method and used for building extraction from remote sensing images after training.
2. The high-resolution remote sensing image building extraction method based on the multi-scale hybrid Transformer model with boundary refinement according to claim 1, characterized in that: In step S1, in terms of data preprocessing, the acquired remote sensing building dataset image is cropped in an overlapping manner, and the label pixels of the annotated image are converted to 0 or 1, and then the cropped dataset is divided into a training set, a validation set, and a test set according to the proportion; In terms of data enhancement, data enhancement is used on the training set, including random size scaling of the data set, random horizontal and vertical flipping, random Gaussian noise, limited contrast adaptive histogram equalization, random rotation and random cropping methods.
3. The high-resolution remote sensing image building extraction method based on the multi-scale hybrid Transformer model with boundary refinement according to claim 1, characterized in that: In step S2, the given RGB image is divided into several image blocks of the same size, and then these image blocks are input into the multi-scale hybrid Transformer encoder. After passing through each stage in turn, four feature maps with a resolution of {1 / 4, 1 / 8, 1 / 16, 1 / 32} of the original image are obtained, where the number of feature map channels in each stage is recorded as C1 to C4; Among them, the multi-scale hybrid Transformer encoder has four stages, and the feature maps in the encoding of the multi-scale hybrid Transformer encoder in the four stages are recorded as F1, F2, F3, and F4 respectively. Correspondingly, four decoders are set for the four stages, among which the feature map in the decoder of the first stage is D4, the feature map in the decoder of the second stage is D3, the feature map in the decoder of the third stage is D2, and the feature map in the decoder of the fourth stage is D1. Among them, the features F1 and F2 obtained in the first and second stages are low-level features; when decoding, the feature F4 in the fourth stage is decoded first, followed by F3, F2, and F1 in turn; The multi-scale hybrid Transformer encoder at each stage consists of an overlapping patch merging layer and multiple Hybridformer Blocks; Each overlapping patch merging layer consists of a convolutional layer and a LayerNorm regularization layer, and the feature map vector after the overlapping patch merging layer is passed into the Hybridformer Block; each Hybridformer Block includes: a multi-scale local perception module and a global perception module; The multi-scale local perception module MSLP is as follows: first, the feature map is input into the deep convolution IDConv that can adapt to different inputs; the feature map after IDConv is divided into three groups of feature maps according to the channel dimension, where i = 1, 2, 3, and they are input into the deep convolution of 1×1, 3×3 and 5×5 respectively; The results are cascaded and fused according to the channel dimension to obtain a feature map with multi-scale information; Two fully connected layers and Gaussian error linear unit GELU activation are used to enhance the nonlinear representation of local features and finally generate feature maps. The entire MSLP module is expressed as: X1,X2,X3=Channelsplit(IDConv(X in )) X′=Concat(DWConv 1×1 (X1),DWConv 3×3 (X2),DWConv 5×5 (X3)) X local =X in +Linear(GELU(Linear(X′))) Among them, IDConv represents the input-dependent depth convolution, ChannelSplit represents the division of the feature map by channel dimension, and GELU represents the Gaussian error linear unit; The global perception module is specifically composed of an efficient self-attention layer and a mixed feedforward position encoding Mix-FFN layer. The efficient self-attention layer downsamples K and V in the original Q, K, V; the Mix-FFN layer includes a 3×3 convolution layer; there is a regularization layer before entering the efficient self-attention and Mix-FFN modules, and a residual connection is used after each module.
4. The high-resolution remote sensing image building extraction method based on the multi-scale hybrid Transformer model with boundary refinement according to claim 3, characterized in that: In step S3, the following steps are included: S31, firstly input the fourth stage feature F4 into the decoder to obtain the decoded high-level feature D1; input the fourth stage decoded high-level feature D1 and the third stage high-level feature F3 together into the group feature alignment fusion module to obtain the third stage alignment feature D2; S32, inputting the low-level features F2 of the second stage, the high-level features D1 after decoding of the fourth stage, and the alignment features D2 of the third stage into the edge enhancement module to obtain the low-level features enhanced in the second stage, and inputting the low-level features enhanced in the second stage and the alignment features D2 of the third stage into the group alignment module to obtain the alignment features D3 of the second stage; S33, input the low-level features F1 of the first stage, the decoded high-level features D1 of the fourth stage, the aligned features D2 of the third stage, and the aligned features D3 of the second stage into the edge enhancement module to obtain the low-level features enhanced in the first stage, input the low-level features enhanced in the first stage and the aligned features D3 of the second stage into the group feature alignment and fusion module for alignment and fusion to obtain the final prediction image, and use this prediction image as the final building segmentation result.
5. The high-resolution remote sensing image building extraction method based on the multi-scale hybrid Transformer model with boundary refinement according to claim 4, characterized in that: In step S31, the process of feature alignment and fusion by the group feature alignment and fusion module is as follows: Given a decoder high-level feature F high and the low-level features F of the encoder in the previous stage low , F high Perform 1×1 convolution and bilinear upsampling so that F high Dimension and F low Consistently obtain features Then F low and At the same time, 1×1 convolution is used to compress the number of channels to obtain the feature map F l ' ow With F h ' igh : F l ′ ow =Conv 1×1 (F low ) The two feature maps are concatenated and input into the 3×3 convolutional layer to obtain the predicted semantic flow field Δ low , the semantic flow field is expressed as: Δ low =Conv 3×3 (Concat(F h ′ igh ,F l ′ ow )) Then Divide into G groups according to the channel dimension, that is in Each sub-feature is associated with each point p on the spatial grid of the semantic flow field. high Mapped to F by simple addition operation low The new point p in low , and then use the differentiable bilinear sampling mechanism to high Linear interpolation is performed on the four nearest neighbor pixel values to obtain Then each set of features after alignment Connect along the channel dimension to generate the final result Specifically expressed as: Where N(p high ) indicates F high Middle twist point p high The neighboring points involved, ω p represents the bilinear kernel weights estimated locally by the distorted grid; Finally, the concatenation operation and 3×3 convolution are used to fuse the layers. and F low , the specific process is as follows: in represents the high-level features after alignment, F low Represents the low-level features of the encoder in the previous stage.
6. The method for extracting buildings from high-resolution remote sensing images using a multi-scale hybrid Transformer model based on boundary refinement according to claim 4, characterized in that: In step S32, the feature map of the second stage among the four stage feature maps generated by the multi-scale hybrid Transformer encoder is input into the boundary enhancement module, and the fused feature maps output by the last two stages of the decoder are input into the boundary enhancement module, wherein the edge enhancement module of the second stage includes: Take the feature F2 in the second stage encoder and the features D1 and D2 in the third and fourth stage decoders as input; Use three 1×1 convolutions to unify the dimensions of D1 and D2 to be consistent with F2, and upsample them to the same size as F2; The unified D1 and D2 are cascaded according to the channel dimension, and then a 3×3 convolution is used to generate a weight matrix W of the same dimension as F2; Use the fast Fourier transform (FFT) layer to convert F2 and the weight parameter W to the frequency domain at the same time, then multiply F2 and W element by element, and use the inverse fast Fourier transform (IFFT) to convert F2 from the frequency domain back to the spatial domain to generate the feature map F, and then input F into LN and MLP to generate the final feature F with strong edge information and architectural semantic information. edge ; The process of the entire edge enhancement module is expressed as: in, Represents C j convolution kernel, MLP stands for multi-layer perceptron, FFT stands for fast Fourier transform, IFFT stands for inverse fast Fourier transform, Up stands for upsampling, and LN stands for LayerNorm regularization.
7. The method for extracting buildings from high-resolution remote sensing images using a multi-scale hybrid Transformer model based on boundary refinement according to claim 4, characterized in that: In step S33, the feature map of the first stage among the four stage feature maps generated by the multi-scale hybrid Transformer encoder is input into the boundary enhancement module, and the fused feature maps output by the last three stages of the decoder are input into the boundary enhancement module; wherein the process of obtaining enhanced features through the edge enhancement module of the first stage includes: Take the feature F1 in the first stage encoder and the features D1, D2, D3 in the second, third, and fourth stage decoders as input; Use three 1×1 convolutions to unify the dimensions of D1, D2, and D3 to be consistent with F1, and upsample them to the same size as F1; The unified D1, D2, and D3 are cascaded according to the channel dimension, and then a 3×3 convolution is used to generate a weight matrix W of the same dimension as F1; Use the fast Fourier transform (FFT) layer to convert F1 and the weight parameter W to the frequency domain at the same time, then multiply F1 and W element by element, and use the inverse fast Fourier transform (IFFT) to convert F1 from the frequency domain back to the spatial domain to generate the feature map F, and then input F into LN and MLP to generate the final feature F with strong edge information and architectural semantic information. edge ; The process of the entire edge enhancement module is expressed as: in, Represents C j convolution kernel, MLP stands for multi-layer perceptron, FFT stands for fast Fourier transform, IFFT stands for inverse fast Fourier transform, Up stands for upsampling, and LN stands for LayerNorm regularization.
8. The method for extracting buildings from high-resolution remote sensing images using a multi-scale hybrid Transformer model based on boundary refinement according to claim 4, characterized in that: In step S4, the AdamW optimizer and the poly learning rate adjustment strategy are used to calculate the loss between the predicted image and the true image using the cross entropy loss function, and the loss is reduced by back propagation; The specific loss calculation method is: calculate the cross entropy loss between the final predicted image obtained in S4 and the real image. The cross entropy loss calculation formula is as follows: Where N represents the total number of pixels in the image, and y i ∈{0,1} represents the true label of pixel i, represents the probability that pixel i belongs to category 1.
Citation Information
Patent Citations
Intelligent forest land and building extraction method for cultivated land protection
CN112132006A
Remote sensing image semantic segmentation method based on double-branch feature fusion
CN115797931A
Remote sensing image building change detection method based on improved Swin Transform
CN117173577A
Transform-based remote sensing image building extraction method
CN117351363A
Deep learning-based multi-scale aggregation Transform remote sensing image semantic segmentation method
CN117576402A
Cited By
Building and road monomer segmentation method, electronic equipment and storage medium
CN119091303A
Remote sensing image feature extraction model pre-training method and system based on frequency domain feature variation
CN119169303A
Wetland carbon reserve estimation method and system based on remote sensing technology
CN119251694A
Remote sensing image change detection method based on edge enhancement
CN119359752A
An edge enhancement-based remote sensing image change detection method
CN119359752B
