# Document Image Shadow Removal Based on Illumination Correction Method
## 3 The Dark Illumination Correction Net
### The Simplified Shadow-Corrected Attention Block  
For removing shadows from document images, the computational efficiency is very important for real-time or mobile device applications. We propose the use of a simplified-shadow corrected attention block (SSCABlock) based on nonlinear activation free block [23; 24] to reduce intra-block complexity, as shown in Figure 3.  
In the original nonlinear activation free block, only channel attention is employed. As a result, it tends to focus exclusively on the global information of feature channels while neglecting local spatial information, which leads to the underutilization of pixel-level detailed information. Consequently, texts in shadowed regions may be compromised during the shadow removal process. To address this issue, we propose a simple spatial attention (SSA) block to capture features of critical regions. It enables the model to focus on global channel and local spatial information at the same time to capture richer and more complete features. By integrating spatial and channel information, DICNet may preserve the detailed information without sacrificing the overall quality.  
In SSCABlock, the SimpleGate [23] first divides the input feature into two same-sized sub-features and inputs them into Simplified Channel Attention (SCA) and SSA, respectively. Then, the output features of SCA and SSA are combined along the channel dimension to finally obtain the feature vector with original size.  
The SSA structure is shown in Figure 4. Firstly, the average pooling on the channel dimension is used to transform the input feature from \(\mathrm{H}\times\mathrm{W}\times\mathrm{C}\) to \(\mathrm{H}\times\mathrm{W}\times 1\), where \(\mathrm{H}\), \(\mathrm{W}\), and \(\mathrm{C}\) denote height, width, and the number of channels, respectively. In other words, the input features are transformed from 3D to 2D by average pooling, as shown in Equation (4).  
\[\mathbf{\hat{F}} =\mathrm{avePool}(\mathbf{F})=\frac{1}{\mathrm{C}}\sum_{i=1}^{ \mathrm{C}}\mathbf{F}_{i} \tag{4}\]  
Figure 3: Simplified shadow-corrected attention block structural diagram.  
where **F** is the input feature of SSA with \(\rm H\times W\times C\), \(\rm\bar{\textbf{F}}\) is a matrix with \(\rm H\times W\), and \(\rm\textbf{F}_{i}\) is the \(i\)-th feature channel of **F**.  
Secondly, the softmax function (as shown in Equation (5)) is used to obtain the effective 2D probability distribution  
\[\rm softmax(\rm\bar{\textbf{F}})_{(x,y)}=\frac{e^{\rm\bar{F}_{(x,y)}}}{\sum \limits_{x}\sum\limits_{y}e^{\rm\bar{F}_{(x,y)}}} \tag{5}\]  
where the subscript \((x,y)\) and \(\rm\bar{F}_{(x,y)}\) denote the pixel location and the corresponding pixel value, respectively.  
Lastly, the original input features are weighted according to the attention score of each position with 2D probability distribution and transformed back to the 3D space again. The calculation process is described in Equation (6)  
\[\rm\textbf{F}^{*}=(softmax(avePool(\rm\textbf{F}))\otimes\rm\textbf{F} \tag{6}\]  
where \(\rm\textbf{F}^{*}\) is the output feature of SSA with \(\rm H\times W\times C\).  
The simplified spatial attention includes three operations: average pool, softmax, and weighting, which is simple to calculate. Moreover, it is able to capture the probabilistic information reflecting which pixel is the shadow by using the softmax function. This information contributes to establishing a more accurate soft shadow mask.