# OmniSR-M: A Rock Sheet with a Multi-Branch Structure Image Super-Resolution Lightweight Method
## 2 Materials and Methods
### Attention Mechanisms  
Attention mechanisms include the spatial attention mechanism and the channel attention mechanism [23; 24], both of which have been widely used in super-resolution tasks to improve the quality of image reconstruction since they were proposed.  
The channel attention mechanism focuses on measuring the importance of each channel and dynamically adjusting the importance of each channel to highlight the more important ones, thus improving the reconstruction quality. The schematic diagram of the channel attention mechanism is shown in Figure 1. In this process, the model learns to obtain a weight vector that assigns different weights to different channels of the input feature map. These weights can be applied to the feature mapping on each channel to enhance or suppress the information on a particular channel. The implementation of the channel attention mechanism is usually calculated using global average pooling or global maximum pooling [25], and the calculation process can be expressed as follows:  
\[Z(c)=AvgPool(X(c)) \tag{1}\]  
where \(Z(c)\) is the feature statistic of the cth channel, \(AvgPool\) denotes the global average pooling operation, and \(X(c)\) denotes the cth channel of the input feature map.  
\[W(c)=\sigma(F(Z(c))) \tag{2}\]  
where \(W(c)\) is the weight of the cth channel, \(F\) denotes a fully connected layer including the activation function, and \(\sigma\) denotes the activation function.  
\[Y(c)=W(c)\cdot X(c) \tag{3}\]  
where \(Y(c)\) is the adjusted feature map of the cth channel, \(W(c)\) is the weight of the corresponding channel, and \(X(c)\) is the cth channel of the input feature map.  
Spatial attention mechanisms are different from channel attention mechanisms in that they focus more on the \"where?\", which can better capture the dependencies between pixels, provide global contextual information, and provide a larger sensory field. It allows the model to focus on different areas of the input image when generating high-resolution images to better capture details and textures. The structure of the spatial attention mechanism is shown in Figure 2. Different from the channel attention mechanism, the spatial attention mechanism will first calculate the positional energy score then convert the energy score into weights, usually using the SoftMax function to ensure that the sum of the weights is 1, thus forming a probability distribution [26]. The computational process of the spatial attention mechanism can be expressed as follows:  
\[E(i,j)=F(X(i,j)) \tag{4}\]  
where \(E(i,j)\) is the energy fraction at location \((i,j)\) and \(F\) is a learnable function that usually includes a convolutional layer and an activation function.  
\[W(i,j)=\frac{e^{E(i,j)}}{\sum_{k,l}e^{E(k,l)}} \tag{5}\]  
where \(W(i,j)\) is the weight at position \((i,j)\), \(E(k,l)\) is the energy at the corresponding position, and the denominator part is normalized to the energy at all positions.  
\[Y(i,j)=\sum_{k,l}W(k,l)\cdot X(i+k,j+l) \tag{6}\]  
where \(Y(i,j)\) is the generated output, \(W(k,l)\) is the weights in the weight matrix and \(X(i+k,j+l)\) is the corresponding pixel or feature in the input feature map.  
Figure 1: Channel attention mechanism.  
The channel attention mechanism and spatial attention mechanism have different focuses, and the effective integration of their respective features can help to improve the super-resolution quality of thin-film images, which has been effectively demonstrated in BAM and CBAM studies [5; 10; 21; 23; 24].