# GCBAM-UNet: Sun Glare Segmentation Using Convolutional Block Attention Module
## 3 Proposed Method
### Cbam  
The Convolutional Block Attention Module (CBAM) is based on an attention mechanism designed to enhance the performance of the CNN by focusing on the most informative features [41]. CBAM consecutively applies channel and spatial attention to the input feature maps, enhancing the feature representation to boost performance in tasks like image classification, image segmentation, and object detection. As illustrated in Figure 3, CBAM comprises two consecutive sub-modules: the Spatial Attention Module (SAM) and the Channel Attention Module (CAM). These modules enhance the feature maps by concentrating on the most relevant parts.  
CAM seeks to improve the network's capacity to focus on significant channels (i.e., feature maps). It first uses global average pooling and global max pooling on the input feature map \(F\) to create two distinct context descriptors. These descriptors are then processed through a shared multi-layer perceptron (MLP) to generate channel-wise attention weights \(M_{c}\). These attention weights are applied to the input feature map to highlight the crucial channels \(F_{c}\). Given the input feature map \(F\in\mathbb{R}^{C\times H\times W}\), \(C\) represents the number of channels, and \(H\) and \(W\) denote the height and width of the feature map, respectively. The output feature map \(F_{c}\) is calculated by multiplying the input feature map by the attention weights \(M_{c}\), as shown in Equation (4).  
\[F_{c}=M_{c}(F)\otimes F. \tag{4}\]  
On the other hand, SAM enhances the network's ability to focus on important spatial regions within the feature maps \(F_{c}\). To achieve this, global average pooling and global max pooling are performed along the channel axis to produce two spatial context descriptors. To generate the spatial attention weights \(M_{s}\), the descriptors are concatenated and processed through a convolutional layer. These spatial attention weights are then applied to the feature map to highlight significant spatial regions \(F_{s}\). Let the input to SAM be the channel-refined  
Figure 3: (**a**) Whole CBAM architecture. (**b**) Channel Attention Module. (**c**) Spatial Attention Module.  
feature map \(F_{c}\in\mathbb{R}^{C\times H\times W}\), where \(C\) is the number of channels. The output feature map is obtained by multiplying the channel-refined feature map \(F_{c}\), with the spatial attention weights \(M_{s}\), as shown in Equation (5).  
\[F_{s}=M_{s}(F)\otimes F_{c}. \tag{5}\]  
As shown in Figure 2, the CBAM module operates on the skip connection features before concatenation with the decoder features. This ensures that only the most informative encoder features are passed to the decoder, improving reconstruction quality. In practical terms, this refinement process improves the quality of feature fusion during the decoding stage. The skip connections in a U-Net architecture play a crucial role in restoring spatial details lost during downsampling. However, without attention mechanisms, these connections might also carry irrelevant or misleading information, such as features influenced by glare artifacts or background noise. CBAM mitigates this issue by selectively enhancing informative features, leading to a better reconstruction of the segmentation map. As a result, this targeted refinement improves the delineation of glare-affected regions and ensures more precise segmentation outputs.