## 2 Segmentation Model
### Edge Enhancement Attention Module
#### 2.2.1 Edge Feature Extraction  
A key step in the overall design of the Edge Enhancement Attention Module is the extraction of edge features, as shown in Figure 3, where each layer after upsampling is input into this module. The input features are first encoded in two directions, allowing for the full acquisition of the building's location information. Based on this, the boundary differences are enhanced, ensuring that the final output feature map contains rich spatial awareness and strong boundary contours, thus improving the final segmentation results of building remote sensing images. The specific steps are as follows:  
* Step 1. Extraction  
Given an input feature Z with dimensions h \(\times\) w, perform max pooling along both the horizontal and vertical directions to obtain the encoded information on the vertical and horizontal structures of the input feature, respectively, which is represented as follows:  
\[\mathrm{f_{w}}=\underset{0\leq i\leq W}{\max}Z(\mathrm{h},i) \tag{1}\]  
\[\mathrm{f_{h}}=\underset{0\leq i\leq H}{\max}Z(i,\mathrm{w}) \tag{2}\]  
Here, Z denotes the input feature map with dimensions h \(\times\) w, h, w represents the height and width of the feature map Z respectively, and H, W represents the maximum of feature map Z's height and width, respectively.  
* Step 2. Transformation  
After concatenating the features from the two directions, they are passed through a 1 \(\times\) 1 convolution F, resulting in feature maps that capture spatial information from both directions. Additionally, to accelerate the model's convergence and enhance focus on the target region, a non-linear normalization operation is applied to the fused feature map, as follows:  
\[\mathrm{U}=\mathrm{Relu}\Big{(}\mathrm{BN}\Big{(}\mathrm{conv}_{1\times 1} \Big{(}\mathrm{concat}\Big{(}\mathrm{f_{w}^{T},f_{h}}\Big{)}\Big{)}\Big{)} \Big{)} \tag{3}\]  
Here, T denotes the transpose operation, concat represents the concatenation operation, conv refers to the convolution operation, BN stands for batch normalization, ReLU is the non-linear activation function, \(\mathrm{conv}_{1\times 1}\) represents 1 \(\times\) 1 convolution operation, \(\mathrm{f_{w}}\) denotes the max-pooled feature vector along the width dimension (horizontal encoding), and \(\mathrm{f_{h}}\) denotes the max-pooled feature vector along the height dimension (vertical encoding).  
Figure 3: Edge feature extraction. (The black arrows indicate the direction of data flow from one layer to another. Transposition (T) indicates the transposition operation used to rearrange the feature maps. Concatenation (C) represents the concatenation of feature maps. Split (S) shows where the feature maps are split for further processing).  
Step 3. Stimulation  
The fused features are divided into feature vectors for the two directions. A \(1~{}\times~{}1\) convolution is used to obtain the activated directional features \(\mathrm{g_{h}}\) and \(\mathrm{g_{w}}\), and the sigmoid function is applied to map the feature values to weight values within the range \([0,~{}1]\).  
\[(\mathrm{g_{h}},\mathrm{g_{w}})=\mathrm{split(U)} \tag{4}\]  
\[\mathrm{\varphi_{h}}=\mathrm{sigmoid}(\mathrm{conv_{1\times 1}(g_{h})}) \tag{5}\]  
\[\mathrm{\varphi_{w}}=\mathrm{sigmoid}(\mathrm{conv_{1\times 1}(g_{w})}) \tag{6}\]  
By performing a matrix multiplication, the weight information from the horizontal and vertical directions is combined to obtain the weight for each position in the spatial domain. This weight is then applied to the original image to obtain the spatially weighted feature attention, as follows:  
\[\mathrm{V(i,j)}=\mathrm{Z(i,j)}\cdot\mathrm{\varphi_{h}(i,j)}\cdot\mathrm{ \varphi_{w}(i,j)} \tag{7}\]  
where \(\mathrm{\varphi_{h}}\), \(\mathrm{\varphi_{w}}\) refers to spatial attention weights for the height and width directions, respectively, and V represents spatially weighted feature map after applying \(\mathrm{\varphi_{h}}\) and \(\mathrm{\varphi_{w}}\).