# Shadow Removal for Enhanced Nighttime Driving Scene Generation
## 3 Proposed Method  
### Partitioned Shadow Removal  
Driving scenes contain objects positioned at various depths. As shown in Figure 1, since the ISTD [8] and SRD [9] datasets, which are commonly used for shadow removal training, only include shadows at the same depth. In other general cases, it is necessary to partition the driving scene based on depth to improve shadow removal performance. The entire process of Partitioned Shadow Removal is summarized in Figure 2. However, if the partitioned regions are too large, the model's ability to detect shadow regions decreases. Conversely, if the regions are too small, noise is introduced during the shadow removal process. To eliminate grid-like patterns caused by brightness differences during the merging of regions, the partitions should be preconfigured to overlap. The driving dataset used in the experiment does not contain shadow masks, necessitating the use of single-image shadow removal methods for shadow elimination. For this purpose, state-of-the-art models such as DHAN [10], DC-ShadowNet [55], and SpA-Former [58] were employed. The DHAN model was applied using an SRD+ pretrained model augmented with Shadow Matting GAN, while DC-ShadowNet and SpA-Former utilized pretrained models based on the SRD dataset. The partition size was adjusted according to the shadow removal model and driving dataset. The Cityscapes dataset [60], containing driving scenes with a resolution of 2048 \(\times\)1024 pixels and fine annotations for 30 classes, was used in the experiment. The dataset includes images captured during daytime in good-to-medium weather conditions across 50 cities, spanning spring, summer, and fall, which provides well-defined shadows due to the varied lighting, weather, and seasonal conditions. For DHAN [10] and SpA-Former [58], each partition was set to 1024 \(\times\) 512 pixels, with partitions overlapping by 50%. A horizontal stride of 512 pixels and a vertical stride of 256 pixels were employed, resulting in a total of 9 partitions. For DC-ShadowNet [55], since the input images are resized into a square format, each partition was set to 512 \(\times\) 512 pixels, and the stride was set to 256 pixels in both horizontal and vertical directions, resulting in 21 partitions. The recognition of shadow regions in single-image shadow removal is still imperfect. Consequently, when the image is divided and processed, brightness variations and noise occur in non-shadow regions due to the differing characteristics of each partition. As shown in Figure 3, noticeable brightness variations arise between separately processed image regions. To eliminate these artifacts during the merging process, continuous blending techniques must be applied to smooth out brightness differences. Since driving scenes typically have consistent depth along the horizontal direction, it is more logical to perform blending first among segments with similar depth horizontally. Therefore, horizontal blending is applied first, followed by vertical blending. The horizontal blending operation is described as follows:  
\[\Omega^{*}(x,y)= \begin{cases}\Omega_{1}(x,y)&\text{if }x<x_{o}\\ (1-\frac{x-x_{o}}{W})\Omega_{1}(x,y)+\frac{x-x_{o}}{W}\Omega_{2}(x-x_{o},y)& \text{if }x_{o}\leq x\leq x_{o}+W\\ \Omega_{2}(x-x_{o},y)&\text{if }x>x_{o}+W\end{cases}  \tag{1}\]  
The equation \(\Omega^{*}\) represents the stitched result of two partitioned images, where \(\Omega_{1}\) denotes the image on the left and \(\Omega_{2}\) denotes the image on the right. \(x_{o}\) signifies the starting point of the overlapping region, and \(W\) indicates the width of the overlapping area. Therefore, the final width of \(\Omega^{*}\) is equal to the widths of \(\Omega_{1}+\Omega_{2}-W\). The coordinates \(x,y\) in the equation are defined with respect to the resultant image \(\Omega^{*}\). Consequently, the right image \(\Omega_{2}\) is positioned such that it is offset by \(x_{0}\) to the right. The weight term \(x-x_{0}\) varies from 0 to \(W\) across the entire overlapping region.