# A Building Segmentation Network Based on Improved Spatial Pyramid in Remote Sensing Images
## 2 Proposed Methods
### Widely Adapted Spatial Pyramid (WASP) Module
The proposed SE-Loss, unlike per-pixel loss, is capable of taking the global context into consideration, resulting in context-aware training. The Selective Kernel Network (SENet) [65] proposes a dynamic selection mechanism to adaptively adjust the receptive field size of each neuron, based on multiple scales of the input information, and multiple branches with different kernel sizes are fused using the softmax attention function, guided by the information in these branches. Although these branches can extract receptive fields with different scales in feature maps, they lack global context prior attention to select the features in a channel-wise manner. The Pyramid Attention Network (PAN) [66] exploits the impact of global contextual information to combine an attention mechanism and spatial pyramid to extract precise dense features for pixel labeling, instead of complicated dilated convolutions and artificially designed decoder networks. With Pyramid Attention Network (PAN) [66], we consider how to exploit high-level feature maps to guide low-level features in recovering pixel localization. Global context features and sub-region context are helpful, in this regard, to distinguish among various categories. This global prior is designed to remove the fixed-size constraint of CNNs for image classification. Considering the above observations, the Widely Adapted Spatial Pyramid (WASP) is proposed, as shown in Figure 3. In this module, we concatenate dilated convolution and pooling layers in the Multi-Scale Feature Extraction block. Each branch first uses a global pooling operation to capture global contextual information at the image level, where the contextual information can use spatial statistical data to interpret the entire image scene. Then we use dilated convolution to expand the receptive field of the feature map without reducing the resolution of the feature map, where each pixel belongs to the feature map from the different image levels and corresponds different sub-regions in the orginal image. When the level size of the pyramid is N, we reduce the size of the context representation to 1/N of the original size. Specifically, the design in the pyramid is 1/8, 1/4, 1/2 and 1 of the four branches. Compared with a single branch, this setting can more effectively restore the spatial information damaged by the pooling operation [67], so that objects in the final prediction have a sharper boundary. We use a spatial pyramid structure similar to DeepLabv3, where the dilated convolutions we selected were 6, 12, 18, and 1. This design is based on the formula for the receptive field shown as Equation (1). This structure can avoid the scale of the receptive field obtained by one branch being equal or an integral multiple of that of another branch, under the premise of obtaining a receptive field as large as possible. \[r_{n}=r_{n-1}+(k_{n}-1)\prod_{i=1}^{n-1}S_{i} \tag{1}\]  
where \(n\) represents the number of layers, \(r_{n}\) represents the receptive field size of the \(n\)th layer, \(k_{n}\) represents the convolution kernel size of the \(n\)th layer, \(d\) represents the dilated convolution size of the \(n\)th layer, and \(S_{n}\) represents the convolution stride size of the \(n\)th layer. The calculation formula of the dilated convolutional kernel is:  
\[k_{d}=k_{n}+(k_{n}-1)(d-1) \tag{2}\]  
where \(k_{d}\) represents the equivalent convolution kernel for dilated convolution of the nth layer. In our network design, each branch of the pyramid has a pooling layer and a dilated convolution layer. Then the receptive field of each branch can be calculated as:  
\[r_{n}=r_{n-1}+(k_{p}-1)\prod_{i=1}^{n-1}S_{i}+(k_{d}-1)\prod_{i=1}^{n-1}S_{i+1} \tag{3}\]  
where \(k_{p}\) represents the convolution kernel of pooling layer. In this paper, we set the stride and convolution size in the pooling layer to be equal to the pooling rate.