# sRrsR-Net: A New Low-Light Image Enhancement Network via Raw Image Reconstruction
## 3 Methods
### RAWFormer Module  
The design of the RAWFormer module is inspired by the Bayer pattern of R-G-G-B color image arrangement. In digital photography arrangements, the green (G) channel in raw images is twice the number of the red (R) and blue (B) channels due to the human eye's greater sensitivity to green. To accommodate the pixel distribution, each pixel has R and B occupying 1/4 and G occupying 1/2. Based on a Transformer architecture, the RAWFormer module is designed to establish global connections between the RGB domain and the raw domain. Concretely, this module is proposed to transform the input RGB intermediate feature map \(\hat{F}_{r}\) into raw Bayer array format image \(I_{r}\in R^{H\times W\times RGB}\). The \"\(RGB\)\" denotes the red, green, and blue channels, respectively. And the \"\(RGB\)\" channels include an additional green channel. The transform function for the RAWFormer module is the function 3. \[I_{r}=f_{RAWFormer}\left(\hat{F}_{r}\right) \tag{3}\]  
where \(f_{RAWFormer}\) represents the Bayer array fitting function, and \(I_{r}\) represents the reconstructed raw image of our approach, which is the output for RAWFormer module. The detailed structure of the RAWFormer module is depicted in Figure 4. This process transforms the pixels from the pixel arrangement of the RGB domain to the Bayer array in the raw image. The RAWFormer module utilizes the self-attention (SA) mechanism [30] to capture relationships among global pixels. Firstly, the input feature \(\hat{F}_{r}\), divided into its three RGB channels with the G channel remaining unchanged, undergoes downsampling through 3 \(\times\) 3 convolutional kernels, resulting in a corresponding red feature map \(F_{r}\) and blue  
Figure 4: The structure of the RAWFormer module. feature map \(F_{b}\), each occupying half of the G channel. This configuration aligns with the pixel distribution of the R-G-G-B pattern. \[F_{r}=Ds\big{(}\hat{F}_{r}\big{)},\ F_{b}=Ds\big{(}\hat{F}_{r}\big{)},\ F_{g} =\hat{F}_{r} \tag{4}\]  
Here, the downsampling operation \(Ds\) reduces the size of the input feature map by half, by utilizing a Pixel-Unshuffle module [31]. Next, as illustrated in Figure 4, we consider the Multi-head Self-Attention mechanism (MSA) [30]. In MSA, firstly, three linear transformation matrices \(W_{q}\), \(W_{k}\), and \(W_{v}\) (corresponding to the linear layers in the diagram) are applied to generate queries (\(Q\)), keys (\(K\)), and values (\(V\)). After obtaining \(Q,\ K,\ V\) for each RGB channel, the next step is to compute self-attention weights individually. The self-attention mechanism calculates the similarity between each feature and all other features by taking the dot product of the \(Q,\ K\) matrices. This process produces attention weights for RGB channels feature. These weights are then used to perform a weighted sum for each element by multiplying them with the V matrix. The final outcome is the attention vector, corresponding to the Scaled Dot-Product Attention (\(SA\)). \[SA=softmax(\frac{QK^{T}}{\sqrt{d_{k}}})V \tag{5}\]  
In Equation (5), the parameter \(d_{k}\) is a learnable scaling factor used to control the magnitude of the dot product of \(Q\) and \(K\) before applying the softmax function. The softmax function converts a vector of values into a probability distribution. The implementation of self-attention follows previous recommendations, incorporating the use of Depthwise Separable Convolution methods [20; 32]. By employing \(1\times 1\) Pointwise Convolution (PW) and \(3\times 3\) Depthwise Separable Convolution (DW), this approach not only reduces parameters and computational costs but also aggregates information between channels and local features. The MSA combines information learned from different \"heads\" to better capture inter-sequence information. RAWFormer divides the number of self-attention channels into N \"heads\" to simultaneously learn different attention maps.