Remote Sensing Image Building Extraction Method Based on Coordinate Attention and Data-Dependent Upsampling
Through the improved CAD-UNet network model, the coordinate attention and data-related upsampling technology are used to solve the problem of insufficient position information and rough boundaries extracted by buildings in high-resolution remote sensing images, and the building extraction with high-precision and smooth boundaries is achieved, which enhances the generalization ability of the model.
Patent Information
- Application Number
- CN202211270279.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-18
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2042-10-18
AI Technical Summary
In the prior art, when extracting buildings in high-resolution remote sensing images, the location information is insufficient, the boundary extraction is rough, and there is a problem of unbalanced positive and negative samples, resulting in misalignment and blurred boundaries, and weak generalization ability.
The CAD-UNet network model based on coordinate attention and data-related upsampling is adopted, and the UNet encoder is replaced by the VGG16 network, combined with the coordinate attention CA module and the data-related upsampling DUp module, and trained using a joint loss function to optimize building extraction.
It significantly improves the building extraction accuracy, obtains smoother boundaries and complete contours, alleviates the problem of positive and negative samples imbalance, and improves the generalization ability of the network.
Smart Images

Figure CN115631412B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a method for extracting buildings from remote sensing images based on coordinate attention and data-dependent upsampling. Background Art
[0002] Buildings are indispensable places of activity in people's daily lives and a crucial component of urban development. The primary task of building extraction is to identify and extract building areas from remote sensing images. Building extraction is crucial for smart city development, traffic management, population estimation, and land use monitoring. With the rapid advancement of remote sensing technology, remote sensing imagery has begun to transition from low resolution to high resolution, forming a trend characterized by high spatial, spectral, and temporal resolution. While the number of features and information in high-resolution remote sensing images continues to increase, so too does the amount of noise and interference. This presents new challenges for building extraction. Accurately extracting buildings from high-resolution remote sensing imagery has become both a hot topic and a challenging area of research.
[0003] Traditional building extraction methods are typically based on prior knowledge and manual features, followed by clustering and other algorithms. These methods primarily include building feature-based methods and auxiliary information-based methods. Most of these methods utilize features such as building shape and texture, and use auxiliary information to extract buildings. While their implementation principles are relatively simple, they suffer from low recognition rates, high error rates, and a time-consuming and labor-intensive process. These methods have significant limitations in practical applications, and their performance is severely restricted. Specifically, they:
[0004] First, less attention is paid to the location information of buildings. Building location information is extremely important for building extraction tasks. Buildings are usually regularly distributed in a remote sensing image and are often obscured by shadows such as trees. Focusing on the location information of buildings can help obtain the accurate location of buildings in an image and avoid misclassification. Existing technologies do not fully consider the location information of buildings, especially for buildings with shadows or complex adhesions. As a result, misclassification is easily caused by insufficient attention to location information.
[0005] Second, the boundaries of building extraction are rough and fuzzy. Buildings are mostly rectangular and usually have regular boundaries. Boundary information is an important feature that cannot be ignored in building extraction tasks. Ignoring edge information when extracting buildings can easily lead to problems such as rough and fuzzy boundaries, chaotic boundaries, and holes. Existing technologies only perform conventional feature extraction when extracting buildings, failing to fully explore the edge features of buildings, resulting in poor extraction results and problems such as rough and fuzzy boundaries.
[0006] Third, there's an imbalance between positive and negative samples. Building extraction is a binary classification task, primarily distinguishing between buildings and background. However, remote sensing images typically have more background pixels than building pixels, which weakens the model's ability to extract buildings during training. Existing techniques fail to fully account for this imbalance between positive and negative samples, resulting in low building extraction accuracy and weak generalization. Summary of the Invention
[0007] The purpose of the present invention is to provide a remote sensing image building extraction method based on coordinate attention and data-dependent upsampling, which effectively solves the misclassification problem caused by insufficient attention to building location information, optimizes the building boundary extraction effect, alleviates the imbalance problem of positive and negative samples, and improves the generalization ability of the network.
[0008] To achieve the above objectives, the present invention adopts the following technical solution: a method for extracting buildings from remote sensing images based on coordinate attention and data-dependent upsampling, the method comprising the following steps in order:
[0009] (1) Obtain remote sensing data: Download the WHU building dataset and the Massachusetts building dataset;
[0010] (2) Data preprocessing and data enhancement: The preprocessing refers to cropping the large images in the dataset and performing data enhancement on the cropped remote sensing images and label images; the data-enhanced remote sensing images and label images are divided into training set, validation set, and test set in a ratio of 8:1:1 respectively;
[0011] (3) Constructing the CAD-UNet network model: Based on the UNet network, an improvement is made to construct a building extraction network model including an encoder, a coordinate attention CA module, and a data-dependent upsampling DUp module, namely the CAD-UNet network model;
[0012] (4) Model training and evaluation: The CAD-UNet network model is trained based on the training set data, the BCE Loss binary cross entropy loss, and the Focal Loss loss. After the training is completed, the building extraction accuracy and effect of the CAD-UNet network model are evaluated using the test set.
[0013] (5) Automated building extraction: After data preprocessing, the new remote sensing image to be extracted is input into the trained CAD-UNet network model. The CAD-UNet network model outputs the predicted image to obtain the building extraction result.
[0014] The step (2) specifically includes the following steps:
[0015] (2a) Using a sliding window method, the remote sensing large image and the labeled image in the Massachusetts building dataset are cropped into images of size 512×512, and the pixel values of the buildings in the labeled images in the WHU building dataset and the Massachusetts building dataset are marked as 1, and the pixel values of the background are marked as 0;
[0016] (2b) performing data enhancement on the remote sensing images and labeled images in the WHU building dataset and the cropped remote sensing images and labeled images in the Massachusetts building dataset to expand the data volume, wherein the data enhancement includes:
[0017] Horizontal flip: Use the image processing library OpenCV to horizontally flip the remote sensing image and the label image respectively;
[0018] Vertical flip: Use the image processing library OpenCV to vertically flip the remote sensing image and the label image respectively;
[0019] Horizontal and vertical flip: Use the image processing library OpenCV to flip the remote sensing image and the label image horizontally and then vertically;
[0020] Shift, scale, random crop and add noise: perform shift, scale, random crop and add noise operations on remote sensing images and label images respectively;
[0021] (2c) The data-augmented remote sensing images and labeled images are divided into a training set, a validation set, and a test set in a ratio of 8:1:1, respectively. The training set is used to directly participate in the training of the CAD-UNet network model and perform feature extraction; the validation set is used to adjust the hyperparameters of the CAD-UNet network model; and the test set is used to test the accuracy and extraction effect of the CAD-UNet network model after training.
[0022] The step (3) specifically includes the following steps:
[0023] (3a) Replace the UNet network encoder: Replace the UNet network encoder with the VGG16 network module. The VGG16 network module is composed of the VGG16 network without the last pooling layer and the fully connected layer. The VGG16 network module performs downsampling through multiple convolutions and four times of maximum pooling to extract building features in remote sensing images and output feature maps of four different scales.
[0024] (3b) Construct the coordinate attention CA module: embed the coordinate attention CA module into the jump connection of the UNet network obtained in step (3a);
[0025] The coordinate attention CA module captures long-range dependencies and retains position information along two spatial directions, encodes the feature maps separately, and forms two feature maps, which are direction-aware and position-sensitive respectively. C ]∈R C×H×W As input, and output a tensor of the same length Y = [y1, y2, y3..., y C ] Specifically, the input X is encoded using pooling kernels of size (H, 1) and (1, W) along the horizontal and vertical directions for each channel. The c-th channel with a height of H is expressed as follows:
[0026]
[0027] Where H represents the height of the image, W represents the width of the image, C represents the total number of channels in the image, c represents the cth channel, X c Represents the image of the cth channel, i represents the horizontal coordinate of the image, and R represents the intermediate tensor set;
[0028] Similarly, the output of the c-th channel with width W is expressed as follows:
[0029]
[0030] Formulas (1) and (2) are two transformations of feature aggregation, which aggregate along two spatial directions respectively and return two directional perception attention maps; the coordinate attention CA module generates two feature layers before cascading, and then shares a 1×1 convolution operation for transformation, as shown in formula (3):
[0031] f=δ(F1([Z H , Z W ])) (3)
[0032] Where δ is a nonlinear activation function, f is an intermediate feature map, which is the result of feature encoding of spatial information in both horizontal and vertical directions; f is then decomposed into two separate tensors along the spatial dimension, f H ∈R C / r×H and f W ∈R C / r×W , r is used to control the reduction ratio of the number of channels, and then use another two 1×1 convolution transformations F H and F W f H and f W Transformed into two tensors g with the same number of feature layers H and g W :
[0033] g H =σ(FH (f H )) (4)
[0034] g W =σ(F W (f W )) (5)
[0035] Where, F H and F W are two 1×1 convolution transformations, f H and f W are two separate tensors obtained by decomposing f, g H and g W It is the tensor obtained after convolution transformation and activation function, σ is the sigmoid activation function. During the transformation process, the reduction ratio r is used to reduce the number of channels of f, and then the output g is H and g W Expand them and use them as attention weights respectively; the final output of the coordinate attention CA module is shown in formula (6):
[0036]
[0037] (3c) Constructing a data-dependent upsampling (DUp) module: The convolutional layer and the data-dependent upsampling module are combined to construct a data-dependent upsampling (DUp) module, which is used to extract boundary information of high-resolution buildings. For the four input feature maps of different scales, a 3×3 convolutional layer is first passed to reduce the number of channels of the feature map. Then, data-dependent upsampling is performed to directly restore the feature map to a size of 512×512. The four feature maps obtained after upsampling are added and fused point by point and then output from the data-dependent upsampling (DUp) module.
[0038] (4) Obtain the CAD-UNet network model.
[0039] The step (4) specifically includes the following steps:
[0040] (4a) Constructing a joint loss function: Constructing a joint loss function that combines the BCE Loss binary cross entropy loss and the Focal Loss focus loss. The formulas for the BCE Loss binary cross entropy loss and the Focal Loss focus loss are as follows:
[0041] BL(p t ,target)=-ω*(target*ln(p t )+(1-target)*ln(1-p t )) (7)
[0042] Where p tis the predicted value of the CAD-UNet network model, target is the label value, and ω is the weight value;
[0043] FL(p t )=-α(1-p t ) γ log(p t ) (8)
[0044] Where p t is the predicted value of the CAD-UNet network model, α is a balance parameter used to balance the ratio of positive and negative samples, and its value range is (0, 1]; γ is a focusing parameter used to reduce the loss of easy-to-classify samples, and its value range is [0, +∞);
[0045] The joint loss function is shown in formula (9):
[0046] Loss=BL+FL (9)
[0047] (4b) Parameter setting: set ω = 1, α = 0.5, γ = 2;
[0048] (4c) Training strategy: The pre-trained weights of the VGG16 network were used during training. The frozen training method was adopted. The parameters of the backbone network were frozen for the first 100 epochs and then trained normally for the next 100 epochs. Each experiment trained a total of 200 epochs.
[0049] (4d) Model accuracy evaluation: The evaluation indicators Precision and Intersection over Union (IoU) are used to evaluate the accuracy. The evaluation indicator calculation formulas are shown in Equations (10) and (11):
[0050]
[0051] In the formula, TP means the true value is positive and the model judges it as positive; FP means the true value is negative and the model judges it as positive; FN means the true value is positive and the model judges it as negative.
[0052] The step (5) specifically includes the following steps:
[0053] (5a) After data preprocessing, the new remote sensing image to be extracted is resized to 512×512;
[0054] (5b) The adjusted image is input into the trained CAD-UNet network model. After passing through the CAD-UNet network model, the predicted image is output to obtain the building extraction result. The CAD-UNet network model predicts that the pixel value of the building is 255, and the CAD-UNet network model predicts that the pixel value of the background is 0. Therefore, in the predicted image, the white part is the building area, and the black part is the background area.
[0055] It can be seen from the above technical solution that the beneficial effects of the present invention are: first, the building extraction accuracy is high. Compared with other methods, the network designed by the present invention gradually extracts the deep features of the building, performs feature fusion, and then gradually upsamples to the input resolution size, which is more friendly to the building extraction task and significantly improves the building extraction accuracy; second, it has a better building boundary extraction effect. The coordinate attention CA module and data-dependent upsampling DUp module added and constructed by the present invention can effectively capture the location information and boundary information of the building, so that the extracted building can have a smoother boundary and a complete outline; third, the network parameters are small and easy to train. The coordinate attention adopted by the present invention is a plug-and-play lightweight attention, and the CAD-UNet network model of the present invention has fewer channels than the original UNet model, which reduces the network complexity, because the method of the present invention has fewer parameters and is easy to train. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 is a flow chart of the method of the present invention;
[0057] Figure 2 It is a structural diagram of the CAD-UNet network model in the present invention;
[0058] Figure 3 This is the structural diagram of the coordinate attention CA module in the present invention;
[0059] Figure 4 : This is a structural diagram of the data-dependent upsampling DUp module in the present invention;
[0060] Figure 5 is an example of training data in the present invention;
[0061] Figure 6 This is the prediction result diagram in the present invention. DETAILED DESCRIPTION
[0062] like Figure 1 As shown, a method for extracting buildings from remote sensing images based on coordinate attention and data-dependent upsampling is provided, which includes the following steps in sequence:
[0063] (1) Obtain remote sensing data: Download the WHU building dataset and the Massachusetts building dataset; the WHU building dataset is the Wuhan University building dataset, and the Massachusetts building dataset is the Massachusetts building dataset;
[0064] (2) Data preprocessing and data enhancement: The preprocessing refers to cropping the large images in the dataset and performing data enhancement on the cropped remote sensing images and label images; the data-enhanced remote sensing images and label images are divided into training set, validation set, and test set in a ratio of 8:1:1 respectively;
[0065] (3) Constructing the CAD-UNet network model: Based on the UNet network, an improvement is made to construct a building extraction network model including an encoder, a coordinate attention CA module, and a data-dependent upsampling DUp module, namely the CAD-UNet network model;
[0066] (4) Model training and evaluation: The CAD-UNet network model is trained based on the training set data, the BCE Loss binary cross entropy loss, and the Focal Loss loss. After the training is completed, the building extraction accuracy and effect of the CAD-UNet network model are evaluated using the test set.
[0067] (5) Automated building extraction: After data preprocessing, the new remote sensing image to be extracted is input into the trained CAD-UNet network model. The CAD-UNet network model outputs the predicted image to obtain the building extraction result.
[0068] The step (2) specifically includes the following steps:
[0069] (2a) Using a sliding window method, the remote sensing large image and the labeled image in the Massachusetts building dataset are cropped into images of size 512×512, and the pixel values of the buildings in the labeled images in the WHU building dataset and the Massachusetts building dataset are marked as 1, and the pixel values of the background are marked as 0;
[0070] (2b) performing data enhancement on the remote sensing images and labeled images in the WHU building dataset and the cropped remote sensing images and labeled images in the Massachusetts building dataset to expand the data volume, wherein the data enhancement includes:
[0071] Horizontal flip: Use the image processing library OpenCV to horizontally flip the remote sensing image and the label image respectively;
[0072] Vertical flip: Use the image processing library OpenCV to vertically flip the remote sensing image and the label image respectively;
[0073] Horizontal and vertical flip: Use the image processing library OpenCV to flip the remote sensing image and the label image horizontally and then vertically;
[0074] Shift, scale, random crop and add noise: perform shift, scale, random crop and add noise operations on remote sensing images and label images respectively;
[0075] (2c) The data-augmented remote sensing images and labeled images are divided into a training set, a validation set, and a test set in a ratio of 8:1:1, respectively. The training set is used to directly participate in the training of the CAD-UNet network model and perform feature extraction; the validation set is used to adjust the hyperparameters of the CAD-UNet network model; and the test set is used to test the accuracy and extraction effect of the CAD-UNet network model after training.
[0076] The step (3) specifically includes the following steps:
[0077] (3a) Replace the UNet network encoder: Replace the UNet network encoder with the VGG16 network module. The VGG16 network module is composed of the VGG16 network without the last pooling layer and the fully connected layer. The VGG16 network module performs downsampling through multiple convolutions and four times of maximum pooling to extract building features in remote sensing images and output feature maps of four different scales.
[0078] (3b) Construct the coordinate attention CA module: embed the coordinate attention CA module into the jump connection of the UNet network obtained in step (3a);
[0079] The coordinate attention CA module captures long-range dependencies and retains position information along two spatial directions, encodes the feature maps separately, and forms two feature maps, which are direction-aware and position-sensitive respectively. C ]∈R C×H×W As input, and output a tensor of the same length Y = [y1, y2, y3..., y C ] Specifically, the input X is encoded using pooling kernels of size (H, 1) and (1, W) along the horizontal and vertical directions for each channel. The c-th channel with a height of H is expressed as follows:
[0080]
[0081] Where H represents the height of the image, W represents the width of the image, C represents the total number of channels in the image, c represents the cth channel, X c Represents the image of the cth channel, i represents the horizontal coordinate of the image, and R represents the intermediate tensor set;
[0082] Similarly, the output of the c-th channel with width W is expressed as follows:
[0083]
[0084] Formulas (1) and (2) are two transformations of feature aggregation, which aggregate along two spatial directions respectively and return two directional perception attention maps; the coordinate attention CA module generates two feature layers before cascading, and then shares a 1×1 convolution operation for transformation, as shown in formula (3):
[0085] f=δ(F1([Z H , Z W ])) (3)
[0086] Where δ is a nonlinear activation function, f is an intermediate feature map, which is the result of feature encoding of spatial information in both horizontal and vertical directions; f is then decomposed into two separate tensors along the spatial dimension, f H ∈R C / r×H and f W ∈R C / r×W , r is used to control the reduction ratio of the number of channels, and then use another two 1×1 convolution transformations F H and F W f H and f W Transformed into two tensors g with the same number of feature layers H and g W :
[0087] g H =σ(F H (f H )) (4)
[0088] g W =σ(F W (f W )) (5)
[0089] Where, F H and F W are two 1×1 convolution transformations, f H and f W are two separate tensors obtained by decomposing f, g H and g W It is the tensor obtained after convolution transformation and activation function, σ is the sigmoid activation function. During the transformation process, the reduction ratio r is used to reduce the number of channels of f, and then the output g is H and g W Expand them and use them as attention weights respectively; the final output of the coordinate attention CA module is shown in formula (6):
[0090]
[0091] (3c) Constructing a data-dependent upsampling (DUp) module: The convolutional layer and the data-dependent upsampling module are combined to construct a data-dependent upsampling (DUp) module, which is used to extract boundary information of high-resolution buildings. For the four input feature maps of different scales, a 3×3 convolutional layer is first passed to reduce the number of channels of the feature map. Then, data-dependent upsampling is performed to directly restore the feature map to a size of 512×512. The four feature maps obtained after upsampling are added and fused point by point and then output from the data-dependent upsampling (DUp) module.
[0092] (4) Obtain the CAD-UNet network model.
[0093] The step (4) specifically includes the following steps:
[0094] (4a) Constructing a joint loss function: Constructing a joint loss function that combines the BCE Loss binary cross entropy loss and the Focal Loss focus loss. The formulas for the BCE Loss binary cross entropy loss and the Focal Loss focus loss are as follows:
[0095] BL(p t ,target)=-ω*(target*ln(p t )+(1-target)*ln(1-p t )) (7)
[0096] Where p t is the predicted value of the CAD-UNet network model, target is the label value, and ω is the weight value;
[0097] FL(p t )=-α(1-p t ) γ log(p t ) (8)
[0098] Where p t is the predicted value of the CAD-UNet network model, α is a balance parameter used to balance the ratio of positive and negative samples, and its value range is (0, 1]; γ is a focusing parameter used to reduce the loss of easy-to-classify samples, and its value range is [0, +∞);
[0099] The joint loss function is shown in formula (9):
[0100] Loss=BL+FL (9)
[0101] (4b) Parameter setting: set ω = 1, α = 0.5, γ = 2;
[0102] (4c) Training strategy: The pre-trained weights of the VGG16 network were used during training. The frozen training method was adopted. The parameters of the backbone network were frozen for the first 100 epochs and then trained normally for the next 100 epochs. Each experiment trained a total of 200 epochs.
[0103] (4d) Model accuracy evaluation: The evaluation indicators Precision and Intersection over Union (IoU) are used to evaluate the accuracy. The evaluation indicator calculation formulas are shown in Equations (10) and (11):
[0104]
[0105] In the formula, TP means the true value is positive and the model judges it as positive; FP means the true value is negative and the model judges it as positive; FN means the true value is positive and the model judges it as negative.
[0106] The step (5) specifically includes the following steps:
[0107] (5a) After data preprocessing, the new remote sensing image to be extracted is resized to 512×512;
[0108] (5b) The adjusted image is input into the trained CAD-UNet network model. After passing through the CAD-UNet network model, the predicted image is output to obtain the building extraction result. The CAD-UNet network model predicts that the pixel value of the building is 255, and the CAD-UNet network model predicts that the pixel value of the background is 0. Therefore, in the predicted image, the white part is the building area, and the black part is the background area.
[0109] In order to verify the effectiveness of the present invention, Unet is selected as a comparative example, and a standard building dataset is used to compare the results, and the accuracy and intersection-over-union ratio of the algorithms are compared.
[0110] Table 1: Comparison of results of the embodiment and the comparative example on the data set
[0111]
[0112] like Figure 2 As shown in the figure, the CAD-UNet network model in the present invention also adopts an encoding and decoding structure. The encoder is on the left, which is used for downsampling and feature extraction; the solid arrow in the middle represents the coordinate attention CA module, which is used to focus on the location information of the building; the decoder is on the right, which is used for feature fusion and upsampling; the dotted arrow in the lower right corner represents the data-dependent upsampling DUp module, which is used to extract the boundary information of the building; finally, after adjusting the number of channels through 1×1 convolution, the building extraction result is output.
[0113] like Figure 3As shown in the figure, the coordinate attention CA module in the present invention first encodes the channels in the horizontal and vertical directions for the input feature tensor; then, the features in two different directions are aggregated to obtain an intermediate tensor; finally, the intermediate tensor is split along the spatial dimension and passed through the convolution layer and Sigmoid function to obtain the final output.
[0114] like Figure 4 As shown in the figure, the data-dependent upsampling DUp module of the present invention first passes the four input feature maps of different scales through a 3×3 convolution layer to reduce the number of channels; then performs data-dependent upsampling to directly restore the four feature maps to a size of 512×512; finally, the four feature maps are added and fused point by point and output from the DUp module.
[0115] Figure 5 In the figure are examples of the WHU building dataset and the Massachusetts building dataset, with remote sensing images on the left and the corresponding true labels on the right.
[0116] Figure 6 The first column is the remote sensing image, the second column is the corresponding real label, the third column is the prediction result of the CAD-UNet network model of the present invention, and the fourth column is the prediction result of UNet. It can be seen from the figure that the prediction result of the method of the present invention has a smoother and clearer boundary, which is better than the prediction result of UNet.
[0117] In summary, the network designed in the present invention gradually extracts the deep features of the building, performs feature fusion, and then gradually upsamples to the input resolution size, which is more friendly to the building extraction task and significantly improves the building extraction accuracy; the coordinate attention CA module and data-dependent upsampling DUp module added and constructed in the present invention can effectively capture the location information and boundary information of the building, so that the extracted building can have a smoother boundary and a complete outline; the coordinate attention adopted in the present invention is a plug-and-play lightweight attention, and the CAD-UNet network model of the present invention has a reduced number of channels compared to the original UNet model, which reduces the network complexity, because the method of the present invention has fewer parameters and is easy to train.
Claims
1. A method for extracting buildings from remote sensing images based on coordinate attention and data-dependent upsampling, characterized by: The method comprises the following steps in sequence: (1) Obtain remote sensing data: Download the WHU building dataset and the Massachusetts building dataset; (2) Data preprocessing and data enhancement: The preprocessing refers to cropping the large images in the dataset and performing data enhancement on the cropped remote sensing images and label images; The data-augmented remote sensing images and labeled images are divided into training set, validation set and test set in a ratio of 8:1:1 respectively; (3) Constructing the CAD-UNet network model: Based on the UNet network, an improvement is made to construct a building extraction network model including an encoder, a coordinate attention CA module, and a data-dependent upsampling DUp module, namely the CAD-UNet network model; Replace the UNet network encoder with a VGG16 network module. The VGG16 network module consists of a VGG16 network with the last pooling layer and fully connected layer removed. The VGG16 network module performs downsampling through multiple convolutions and four times of maximum pooling to extract building features in remote sensing images and output feature maps at four different scales. Construct the coordinate attention CA module: embed the coordinate attention CA module into the jump connection of the UNet network; Constructing a data-dependent upsampling (DUp) module: The DUp module is constructed by combining the convolutional layer and the data-dependent upsampling module to extract boundary information of high-resolution buildings. For the four input feature maps of different scales, they are first passed through a 3×3 convolutional layer to reduce the number of channels of the feature maps. Then, data-dependent upsampling is performed to directly restore the feature maps to a size of 512×512. The four feature maps obtained after upsampling are added and fused point by point before being output from the DUp module. (4) Model training and evaluation: The CAD-UNet network model is trained based on the training set data, the BCE Loss binary cross entropy loss, and the Focal Loss loss. After the training is completed, the building extraction accuracy and effect of the CAD-UNet network model are evaluated using the test set. (5) Automated building extraction: After data preprocessing, the new remote sensing image to be extracted is input into the trained CAD-UNet network model. The CAD-UNet network model outputs the predicted image to obtain the building extraction result.
2. The method for extracting buildings from remote sensing images based on coordinate attention and data-dependent upsampling according to claim 1, wherein: The step (2) specifically includes the following steps: (2a) Using a sliding window method, the remote sensing large image and the labeled image in the Massachusetts building dataset are cropped into images of size 512×512, and the pixel values of the buildings in the labeled images in the WHU building dataset and the Massachusetts building dataset are marked as 1, and the pixel values of the background are marked as 0; (2b) performing data enhancement on the remote sensing images and labeled images in the WHU building dataset and the cropped remote sensing images and labeled images in the Massachusetts building dataset to expand the data volume, wherein the data enhancement includes: Horizontal flip: Use the image processing library OpenCV to horizontally flip the remote sensing image and the label image respectively; Vertical flip: Use the image processing library OpenCV to vertically flip the remote sensing image and the label image respectively; Horizontal and vertical flip: Use the image processing library OpenCV to flip the remote sensing image and the label image horizontally and then vertically; Shift, scale, random crop and add noise: perform shift, scale, random crop and add noise operations on remote sensing images and label images respectively; (2c) The data-augmented remote sensing images and labeled images are divided into a training set, a validation set, and a test set in a ratio of 8:1:1, respectively. The training set is used to directly participate in the training of the CAD-UNet network model and perform feature extraction; the validation set is used to adjust the hyperparameters of the CAD-UNet network model; and the test set is used to test the accuracy and extraction effect of the CAD-UNet network model after training is completed.
3. The method for extracting buildings from remote sensing images based on coordinate attention and data-dependent upsampling according to claim 1, wherein: The step (3) specifically refers to: The coordinate attention CA module captures long-range dependencies and retains position information along two spatial directions, encodes the feature maps separately, and forms two feature maps, which are direction-aware and position-sensitive respectively. C ]∈R C×H×W As input, and output a tensor of the same length Y = [y1,y2,y3...,y C ] Specifically, the input X is encoded using pooling kernels of size (H, 1) and (1, W) along the horizontal and vertical directions for each channel. The c-th channel with a height of H is expressed as follows: Where H represents the height of the image, W represents the width of the image, C represents the total number of channels in the image, c represents the cth channel, X c Represents the image of the cth channel, i represents the horizontal coordinate of the image, and r represents the intermediate tensor set; Similarly, the output of the c-th channel with width W is expressed as follows: Formulas (1) and (2) are two transformations of feature aggregation, which aggregate along two spatial directions respectively and return two directional perception attention maps; the coordinate attention CA module generates two feature layers before cascading, and then shares a 1×1 convolution operation for transformation, as shown in formula (3): f=δ(F1([Z H ,Z W ])) (3) Where δ is a nonlinear activation function, f is an intermediate feature map, which is the result of feature encoding of spatial information in both horizontal and vertical directions; f is then decomposed into two separate tensors along the spatial dimension, f H ∈R C / r×H and f W ∈R C / r×W , r is used to control the reduction ratio of the number of channels, and then use another two 1×1 convolution transformations F H and F W f H and f W Transformed into two tensors g with the same number of feature layers H and g W : g H =σ(F H (f H )) (4) g W =σ(F W (f W )) (5) Where, F H and F W are two 1×1 convolution transformations, f H and f W are two separate tensors obtained by decomposing f, g H and g W It is the tensor obtained after convolution transformation and activation function, σ is the sigmoid activation function. During the transformation process, the reduction ratio r is used to reduce the number of channels of f, and then the output g is H and g W Expand and use them as attention weights respectively; The final output of the coordinate attention CA module is shown in formula (6): Get the CAD-UNet network model.
4. The method for extracting buildings from remote sensing images based on coordinate attention and data-dependent upsampling according to claim 1, wherein: The step (4) specifically includes the following steps: (4a) Constructing a joint loss function: Constructing a joint loss function that combines the BCE Loss binary cross entropy loss and the Focal Loss focus loss. The formulas for the BCE Loss binary cross entropy loss and the Focal Loss focus loss are as follows: BL(p t ,target)=-ω*(target*ln(p t )+(1-target)*ln(1-p t )) (7) Where p t is the predicted value of the CAD-UNet network model, target is the label value, and ω is the weight value; FL(p t )=-α(1-p t ) γ log(p t ) (8) Where p t is the predicted value of the CAD-UNet network model, α is a balance parameter used to balance the ratio of positive and negative samples, and its value range is (0,1]; γ is a focusing parameter used to reduce the loss of easy-to-classify samples, and its value range is [0,+∞); The joint loss function is shown in formula (9): Loss=BL+FL (9) (4b) Parameter setting: set ω = 1, α = 0.5, γ = 2; (4c) Training strategy: The pre-trained weights of the VGG16 network were used during training. The frozen training method was adopted. The parameters of the backbone network were frozen for the first 100 epochs and then trained normally for the next 100 epochs. Each experiment trained a total of 200 epochs. (4d) Model accuracy evaluation: The evaluation indicators Precision and Intersection over Union (IoU) are used to evaluate the accuracy. The evaluation indicator calculation formulas are shown in Equations (10) and (11): In the formula, TP means the true value is positive and the model judges it as positive; FP means the true value is negative and the model judges it as positive; FN means the true value is positive and the model judges it as negative.
5. The method for extracting buildings from remote sensing images based on coordinate attention and data-dependent upsampling according to claim 1, wherein: The step (5) specifically includes the following steps: (5a) After data preprocessing, the new remote sensing image to be extracted is resized to 512×512; (5b) The adjusted image is input into the trained CAD-UNet network model. After passing through the CAD-UNet network model, the predicted image is output to obtain the building extraction result. The CAD-UNet network model predicts that the pixel value of the building is 255, and the CAD-UNet network model predicts that the pixel value of the background is 0. Therefore, in the predicted image, the white part is the building area, and the black part is the background area.
Citation Information
Patent Citations
Winter wheat planting area image extraction method combining GF-6 and Sentinel-2
CN114842339A
Method and system for computer aided detection of abnormalities in image data
US20210319879A1