Shadow Feature Refinement Network: Progressive Feature Refinement based on Knowledge Distillation for Effective Shadow Removal

Donghyun Han1, Byoung-dai Lee1*
1Kyonggi University, Korea
Multimedia Systems 31, 449 (2025)
*Corresponding author
Network architecture of SFR-Net

Figure 1. Network architecture of the proposed shadow feature refinement network.

Abstract

In the field of deep learning, has seen significant advancements; however, shadow removal remains a persistent challenge owing to the variable sizes and colors of shadows influenced by lighting conditions. This study proposes a novel shadow feature refinement network (SFR-Net), which leverages supervised learning, feature refinement loss, and knowledge distillation to enhance shadow removal performance. A dedicated post-processing algorithm is further introduced to restore natural color consistency in the generated shadow-free images. We evaluated our method on two public datasets: the adjusted image shadow triplet dataset (ISTD+) and the shadow removal dataset (SRD), which demonstrate strong generalization capabilities under diverse conditions. On ISTD+, our model achieved a root mean square error (RMSE) of 3.4627 and structural similarity index measure (SSIM) of 0.9382 across the entire image. On SRD, it recorded an RMSE of 4.3781 and an SSIM of 0.9341. These comprehensive results show that our approach performs competitively across both shadow and non-shadow regions while setting a promising direction for robust and perceptually natural shadow removal.

Introduction

Shadows cause non-uniform lighting that changes the texture and colors of the shadowed region, and the penumbra makes the shadow boundary hard to define. Shadow removal therefore has to estimate and restore the colors of the shadowed region from those of the non-shadowed region. Image inpainting models are good at this kind of context-aware reconstruction, and a pretrained inpainting network that receives the shadow-free image produces features that describe what the shadowed region should look like.

SFR-Net builds on this observation with two image generation networks derived from an inpainting model. The guided network \(G_S\) receives the shadow image \(I_S\) and its shadow mask \(M_S\) and removes the shadow. The guiding network \(G_I\) has the same structure, receives the ground-truth image \(I_{gt}\) with an empty mask \(M_{gt}\), and reconstructs \(I_{gt}\). The features generated at each layer of \(G_I\) supervise the corresponding layer of \(G_S\).

The main contributions of this study are as follows.

  • A supervised shadow removal model that combines image inpainting and knowledge distillation, with two inpainting-based generator architectures and loss functions for efficient learning.
  • A post-processing step that learns the correlation between the pixels of the shadow image and the shadow-removed image in the non-shadow region and corrects the pixel values of the entire image, so the overall colors match those of the original image.
  • Extensive experiments on the public ISTD+ and SRD datasets, showing performance comparable to state-of-the-art methods.

Method

Shadow Feature Refinement Network

SFR-Net is a generative adversarial network with two generators and one discriminator. The pretrained \(G_I\) takes \(I_{gt}\) and the empty mask \(M_{gt}\) and reconstructs \(I'_{gt}\); \(G_S\) takes \(I_S\) and \(M_S\) and generates the shadow-free image \(I_{sf}\) while comparing its intermediate features with those of \(G_I\). Both generators are LaMa networks built from fast Fourier convolution (FFC) blocks, which let the network use image-wide context from the first layers. The discriminator is the patch-based discriminator of Pix2PixHD. Finally, a post-processing step restores the colors of \(I_{sf}\) to produce the final output \(I_{sf\text{-}pp}\).

Architecture of the FFC block and spectral transform

Figure 2. Architecture of the FFC block and spectral transform. The Fourier unit (FU) captures global structure in the frequency domain, and the local Fourier unit (LFU) splits the feature map into four quadrants to enhance local detail.

The guided network \(G_S\) consists of four FFC-based downscale layers, two FFC layers, 18 FFC residual blocks with skip connections, and four FFC-based upscale layers.

Loss Function

The overall objective combines five losses and an R1 gradient penalty:

$$\mathcal{L} = \alpha\,\mathcal{L}_{Adv} + \beta\,\mathcal{L}_{HRFPL} + \gamma\,\mathcal{L}_{fm} + \delta\,\mathcal{L}_{mix} + \lambda_{fr}\,\mathcal{L}_{fr} + \zeta\,R_1 \tag{1}$$

with \(\alpha = 10\), \(\beta = 30\), \(\gamma = 100\), \(\delta = 10\), \(\lambda_{fr} = 100\), and \(\zeta = 0.001\).

Adversarial loss

The patch discriminator is supervised separately inside and outside the shadow. Each image is divided into \(N\) patches, and \(M_{S,i} \in \{0, 1\}\) indicates whether patch \(i\) belongs to the shadow region. Shadow patches are expected to be changed by the generator and are classified as fake, while non-shadow patches should match the target and are classified as real. A non-saturating adversarial loss with stop gradients \(\mathrm{sg}\) minimizes both the discriminator and generator losses:

$$\mathcal{L}_D = \frac{1}{N}\sum_{i=1}^{N}\Big[-\log D_i(I_{gt}) - M_{S,i}\log\big(1 - D_i(I_{sf})\big) - (1 - M_{S,i})\log D_i(I_{sf})\Big] \tag{2}$$ $$\mathcal{L}_G = -\mathbb{E}\big[\log D(I_{sf})\big] \tag{3}$$ $$\mathcal{L}_{Adv} = \mathrm{sg}_\theta(\mathcal{L}_D) + \mathrm{sg}_\xi(\mathcal{L}_G) \longrightarrow \min_{\theta,\xi} \tag{4}$$

High receptive field perceptual loss and discriminator feature matching

\(\mathcal{L}_{HRFPL}\) compares features of a pretrained ResNet with a high receptive field, \(\phi^{HRF}_j\), and \(\mathcal{L}_{fm}\) compares the intermediate features \(D_j\) of the discriminator, which is trained on the same data domain:

$$\mathcal{L}_{HRFPL} = \sum_{j \in \mathcal{L}} \frac{1}{C_j H_j W_j}\big\lVert \phi^{HRF}_j(I_{gt}) - \phi^{HRF}_j(I_{sf}) \big\rVert_2 \tag{5}$$ $$\mathcal{L}_{fm} = \sum_{j \in \mathcal{L}} \frac{1}{C_j H_j W_j}\big\lVert D_j(I_{gt}) - D_j(I_{sf}) \big\rVert_2 \tag{6}$$

Mix loss

L1 compares pixels independently, while the human visual system is more sensitive to luminance, contrast, and structure. The mix loss combines MS-SSIM, computed per \(35 \times 35\) patch \(P\) around its center pixel \(\tilde{p}\) with Gaussian filters of \(\sigma_G \in \{0.5, 1, 2, 4, 8\}\), with a Gaussian-weighted L1 loss:

$$\mathcal{L}_{ms\text{-}ssim}(P) = 1 - \text{MS-SSIM}(\tilde{p}) = 1 - l_M^{\alpha}(\tilde{p})\cdot\prod_{j=1}^{M} cs_j^{\beta_j}(\tilde{p}) \tag{10}$$ $$\mathcal{L}_{mix} = \gamma_{mix}\cdot\mathcal{L}_{ms\text{-}ssim} + (1 - \gamma_{mix})\cdot G_{\sigma_G^M}\cdot\mathcal{L}_{1} \tag{11}$$

with \(\alpha = \beta_j = 1\) and \(\gamma_{mix} = 0.025\), which is distinct from the loss weight \(\gamma\) in Eq. (1).

Feature refinement loss

The guided network learns the image representation that the guiding network uses to reconstruct \(I_{gt}\). The activations of \(G_S\) and \(G_I\) at a set of target layers \(\mathcal{L}\) are compared with the L2 distance:

$$\mathcal{L}_{fr} = \frac{1}{N}\sum_{l \in \mathcal{L}} \frac{1}{C_l H_l W_l}\big\lVert G_I^{l}(I_{gt} \oplus M_{gt}) - G_S^{l}(I_S \oplus M_S) \big\rVert_2 \tag{12}$$

where \(N\) is the number of target layers and \(\oplus\) denotes channel concatenation. With \(\mathcal{L}_{fr}\), the feature maps of \(G_S\) carry more diverse and richer information (Figure 3).

Feature maps of the 20th FFC block without and with the feature refinement loss

Figure 3. Feature maps of the 20th FFC block of SFR-Net (a) without and (b) with \(\mathcal{L}_{fr}\).

Post-Processing for Color Restoration

The shadow and ground-truth images of a dataset are captured under slightly different conditions, so the model also learns global color changes and alters the overall color of its output. Because \(I_S\) is \(I_{gt}\) with a shadow cast on it, the non-shadow region of \(I_{sf}\) should have the colors of \(I_S\). SFR-Net therefore fits a per-image linear regression on the non-shadow pixels, separately for R, G, and B, and applies it to the whole image:

$$I_S \odot (1 - M_S) = \beta_0 + \beta_1 \cdot \big(I_{sf} \odot (1 - M_S)\big) \tag{13}$$ $$I_{sf\text{-}pp} = \beta_0 + \beta_1 \cdot I_{sf} \tag{14}$$

Experiments

Experimental Setup

  • ISTD+: 1,330 training and 540 test triplets (shadow image, shadow-free image, mask) at 640×480.
  • SRD: 3,088 image pairs without ground-truth masks; images are resized to 640×480 and masks predicted by DHAN are used for training and evaluation.
  • Metrics: RMSE in LAB color space, and PSNR and SSIM in RGB, for the shadow, non-shadow, and whole image regions, computed with the widely used MATLAB evaluation code.
  • Implementation: PyTorch 2.0, one NVIDIA Tesla A100 GPU, batch size 4, Adam and Lion optimizers, learning rate \(10^{-3}\) for the generator and \(10^{-4}\) for the discriminator.

Comparison with State-of-the-Art Methods

On ISTD+, SFR-Net achieves the lowest shadow-region RMSE among the compared methods, reducing it from 5.0098 (HomoFormer) to 4.9750, and ranks second in shadow-region PSNR, non-shadow SSIM and PSNR, and whole-image RMSE and PSNR. All baseline numbers are the official results of the respective studies; SP+M+I Net and FusionNet output \(256 \times 256\) images, which are resized to \(640 \times 480\). On SRD, it records an RMSE of 3.5184 in the shadow region and 4.3781 on the whole image. Bold and underline mark the best and second-best results.

Table 1. Quantitative comparison on the ISTD+ dataset.

MethodShadow RegionNon-Shadow RegionAll
RMSE↓SSIM↑PSNR↑RMSE↓SSIM↑PSNR↑RMSE↓SSIM↑PSNR↑
Shadow Image30.48310.926520.80953.14930.955233.885512.40800.874720.2209
ShadowDiffusion5.86670.978235.81923.28920.925332.81633.87680.899530.3881
HomoFormer5.00980.984037.48623.12820.935033.33003.52450.916131.3985
Inpaint4Shadow6.52030.962135.21364.46830.823429.80084.91240.778328.2474
ShadowFormer5.07550.986438.06922.86630.955035.14633.34610.938732.7827
BMNet5.54770.986536.80702.97910.957634.47253.53750.941031.8521
SG-ShadowNet6.02830.984435.96203.79690.950332.76444.26510.930430.5036
FusionNet (resize)6.60840.960534.74924.63870.803829.10785.04450.756727.6059
SP+M+I Net (resize)6.20190.977435.79714.36150.907130.86974.76500.880029.1754
DHAN8.67840.983332.45356.78800.943326.21587.22240.924424.8628
InstanceShadowDiffusion5.07350.986537.73543.12690.951434.30063.53420.935632.1079
SFR-Net (Ours)4.97500.986537.87473.06310.955034.57933.46270.938232.3872
Qualitative comparison on ISTD+

Figure 4. Qualitative results on ISTD+. (a) Input, (b) ShadowDiffusion, (c) HomoFormer, (d) ShadowFormer, (e) BMNet, (f) Ours, (g) InstanceShadowDiffusion, (h) GT, from left to right.

Table 2. Quantitative comparison on the SRD dataset.

MethodShadow RegionNon-Shadow RegionAll
RMSE↓SSIM↑PSNR↑RMSE↓SSIM↑PSNR↑RMSE↓SSIM↑PSNR↑
Shadow Image17.38590.869418.78692.76570.968330.270416.31930.820618.0297
ShadowDiffusion4.16360.966231.72642.53400.965131.27355.37630.922227.8394
HomoFormer3.42170.967633.10202.23440.950231.95454.56350.898828.8686
Inpaint4Shadow3.88280.971332.22222.13700.973932.71094.83680.932428.7194
ShadowFormer3.58330.973933.00571.96170.975833.70104.43660.937429.6462
BMNet3.69520.965632.30862.35870.944931.08334.88480.888927.9986
SG-ShadowNet3.71240.973332.54601.96590.974833.96314.49260.934029.6179
FusionNet (resize)4.27530.956931.41842.90920.927729.75855.81870.860626.9399
InstanceShadowDiffusion6.19590.970534.11673.64980.961132.44894.41950.925929.4738
DHAN3.98670.962231.64252.51060.940530.63785.22740.882127.5300
SFR-Net (Ours)3.51840.974433.19091.96650.972733.73994.37810.934129.8287
Qualitative comparison on SRD

Figure 5. Qualitative results on SRD. (a) Input, (b) ShadowDiffusion, (c) HomoFormer, (d) ShadowFormer, (e) BMNet, (f) Ours, (g) InstanceShadowDiffusion, (h) GT, from left to right.

Table 3 measures how well each method preserves the non-shadow region of the original shadow image \(I_S\). SFR-Net has the highest SSIM on both datasets and the best RMSE and PSNR on SRD, while InstanceShadowDiffusion achieves the best RMSE and PSNR on ISTD+.

Table 3. Reconstruction of the non-shadow region of the original shadow image \(I_S\).

MethodISTD+SRD
RMSE↓SSIM↑PSNR↑RMSE↓SSIM↑PSNR↑
ShadowDiffusion2.4950.942434.48692.70200.975530.3506
HomoFormer1.63340.986338.76593.03850.945728.8426
Inpaint4Shadow3.88850.823730.24852.55660.961730.0065
ShadowFormer1.29620.990941.09362.40800.964930.6063
BMNet1.46130.992840.00632.62610.963329.9894
SG-ShadowNet2.53360.988936.68162.53680.963330.5528
FusionNet (resize)4.42630.803329.19793.43630.925428.0174
SP+M+I Net (resize)3.97650.919931.1807–––
DHAN6.12790.982427.50922.80480.9585229.4690
InstanceShadowDiffusion1.23650.993342.97164.95130.964129.4994
SFR-Net (Ours)1.62810.994141.80932.33070.985932.8520

Ablation Study

Where to Apply Knowledge Distillation

The 18 FFC residual blocks are divided into shallow, middle, and deep stages, and \(\mathcal{L}_{fr}\) is applied to different combinations of them. Every configuration outperforms training without \(\mathcal{L}_{fr}\), and applying it to the deep stage gives the best results. In early layers, the features of \(I_S\) and \(M_S\) have not yet converged, so refinement with the ground-truth features helps little; in deep layers they have, and the features of \(G_S\) gradually become similar to those of the ground-truth image.

Division of the FFC residual blocks into three stages

Figure 6. Division of layers into three stages for analyzing the effectiveness of knowledge distillation.

Table 4. \(\mathcal{L}_{fr}\) applied to each stage (ISTD+, without post-processing).

ConfigurationShadow RegionNon-Shadow RegionAll
RMSE↓SSIM↑PSNR↑RMSE↓SSIM↑PSNR↑RMSE↓SSIM↑PSNR↑
Config. #1 (Shallow Only)6.04790.985235.97763.64490.951532.56044.17220.933230.2424
Config. #2 (Middle Only)5.50840.985836.86163.47960.954233.77873.92290.936931.4653
Config. #3 (Deep Only)5.21070.986237.43213.25020.954234.07113.66750.937231.8471
Config. #4 (Shallow & Middle)5.61300.984936.56513.31700.954533.64163.82530.936031.3321
Config. #5 (Middle & Deep)5.47610.985737.12883.32110.951834.00833.76880.934131.7260
Config. #6 (All Stages)5.44300.985436.87793.38610.954033.68653.82860.936131.3961
Without \(\mathcal{L}_{fr}\)6.09750.984935.48673.77470.953331.76734.28550.934729.6694

Contribution of Each Loss

\(\mathcal{L}_{LaMa}\) is the original LaMa objective (adversarial, HRFPL, feature matching, and L1 losses). Adding \(\mathcal{L}_{mix}\), which compares luminance and contrast, mainly reduces the color difference in the non-shadow region, while adding \(\mathcal{L}_{fr}\) gives a higher PSNR in the shadow region and over the whole image. Combining both achieves the best performance in all regions and metrics.

Table 5. Effect of \(\mathcal{L}_{mix}\) and \(\mathcal{L}_{fr}\) (Config. #3, ISTD+).

\(\mathcal{L}_{LaMa}\)\(\mathcal{L}_{mix}\)\(\mathcal{L}_{fr}\)Shadow RegionNon-Shadow RegionAll
RMSE↓SSIM↑PSNR↑RMSE↓SSIM↑PSNR↑RMSE↓SSIM↑PSNR↑
✓7.43660.977434.01905.10190.924929.75305.61610.897627.8767
✓✓6.09750.984935.48673.77470.953331.76734.28550.934729.6694
✓✓6.42030.982735.63434.16850.947231.56454.63110.926329.7403
✓✓✓5.21070.986237.43213.25020.954234.07113.66750.937231.8471
Shadow image Result with the feature refinement loss Result without the feature refinement loss Ground truth Matte of the shadow image Matte with the feature refinement loss Matte without the feature refinement loss Matte of the ground truth
(a) \(I_S\)
(b) With \(\mathcal{L}_{fr}\)
(c) Without \(\mathcal{L}_{fr}\)
(d) \(I_{gt}\)

Figure 7. Matte images of the residuals with respect to the ground truth. With \(\mathcal{L}_{fr}\), the residual left by the shadow is smaller and more consistent with the ground-truth structure.

Post-Processing Analysis

We compare six algorithms (linear regression, polynomial regression, histogram matching, color transfer, gradient boosting, and gamma correction) in the BGR and LAB color spaces. Post-processing in BGR space generally works better than in LAB space. Linear regression in BGR space, our default, reduces the whole-image RMSE from 3.6675 to 3.4627 and the shadow-region RMSE from 5.2107 to 4.9750; similar improvements are observed on SRD. Gradient boosting in BGR space scores slightly higher, but on SRD it takes about 2.517 s per image compared with 0.046 s for linear regression, a 54-fold increase in processing time, so linear regression offers the best trade-off between performance and efficiency.

Table 6. Post-processing techniques on the ISTD+ dataset.

MethodShadow RegionNon-Shadow RegionAllTime (s)
RMSE↓SSIM↑PSNR↑RMSE↓SSIM↑PSNR↑RMSE↓SSIM↑PSNR↑
SFR-Net (default)5.21070.986237.43213.25020.954234.07113.66750.937231.8471–
BGR space
+ Linear regression4.97500.986537.87473.06310.955034.57933.46270.938232.38720.068
+ Polynomial regression5.24440.986037.64923.23860.955334.37123.65990.938032.19190.187
+ Histogram matching10.83980.969832.92783.22080.954134.23245.03660.918529.90320.050
+ Color transfer9.27680.97633.69433.22080.954134.23244.56610.926030.36460.056
+ Gradient boosting5.07410.986237.77672.91270.956335.07493.37000.939032.65782.513
+ Gamma correction8.42500.980634.84133.22080.954134.23244.35240.930030.90870.043
LAB space
+ Linear regression5.00130.985737.79633.16210.950534.35753.54820.932632.22540.054
+ Polynomial regression5.12810.985337.63233.31480.950134.03003.69710.931931.95820.158
+ Histogram matching11.53960.967232.30563.28340.952334.10945.21680.913929.54620.059
+ Color transfer9.47520.975533.57193.28340.952334.10944.66910.922730.24660.059
+ Gradient boosting5.07530.986237.77662.91270.956235.07533.37120.939032.65741.937
+ Gamma correction8.56740.979234.72923.28340.952334.10944.43380.926730.78790.048

Table 7. Post-processing techniques on the SRD dataset.

MethodShadow RegionNon-Shadow RegionAllTime (s)
RMSE↓SSIM↑PSNR↑RMSE↓SSIM↑PSNR↑RMSE↓SSIM↑PSNR↑
SFR-Net (default)3.78400.971932.92932.51290.969033.57975.28070.926629.4810–
BGR space
+ Linear regression3.51840.974433.19091.96650.972733.73994.37810.934129.82870.046
+ Polynomial regression3.87510.971932.82502.40200.970333.63605.15420.927729.49650.146
+ Histogram matching6.81710.944528.22361.97610.974333.71976.90810.903726.43550.030
+ Color transfer6.02440.951529.04681.97540.974333.72066.24670.910627.07940.036
+ Gradient boosting3.41890.973133.42041.77510.975434.85694.12690.934630.48122.517
+ Gamma correction5.41260.957929.92491.97480.974333.72215.77320.917527.69690.022
LAB space
+ Linear regression3.53400.972033.09432.14490.971033.75174.63100.928829.71290.052
+ Polynomial regression3.62870.971632.87032.14040.970733.70164.67610.928329.58510.158
+ Histogram matching6.87380.943828.09231.99400.973833.69396.91040.902426.35540.034
+ Color transfer6.06800.950928.98201.99380.973833.69436.29520.909427.02940.040
+ Gradient boosting3.40490.972533.36981.82770.973234.61974.17270.931430.34731.979
+ Gamma correction5.45680.955629.85001.99320.973833.69585.82590.914727.63070.028
Blue, green, and red pixel histograms
Ground truth Shadow image SFR-Net output before post-processing SFR-Net output after post-processing
(d) \(I_{gt}\)
(e) \(I_S\)
(f) \(I_{sf}\)
(g) \(I_{sf\text{-}pp}\)

Figure 8. Color histograms with and without post-processing: (a) blue, (b) green, (c) red. After linear-regression post-processing, the distribution aligns more closely with the ground truth.

Qualitative comparison of post-processing algorithms

Figure 9. Post-processing algorithms for color restoration. (a) \(I_{sf}\), (b) linear regression, (c) polynomial regression, (d) color transfer (Reinhard et al.), (e) gradient boosting, (f) gamma correction, (g) \(I_S\), from left to right. Linear regression blends the previously shadowed and non-shadowed regions seamlessly, while histogram matching and color transfer can introduce color artifacts.

Conclusion

SFR-Net learns shadow removal through knowledge distillation of feature maps: the ground-truth image is passed through a pretrained inpainting network, and its features supervise those of the shadow removal network. Together with the MS-SSIM, L1, and feature refinement losses and a linear-regression post-processing for color restoration, SFR-Net effectively reconstructs shadow-free images.

The method has several limitations. The model is trained on ISTD+ and SRD and may not generalize to unseen lighting conditions, object types, noisy backgrounds, or complex overlapping shadows. It depends on paired data, and the post-processing step is separate from the network and is not optimized jointly. Future work will explore self-supervised or weakly supervised learning to reduce the dependence on paired data, and an end-to-end architecture that integrates color correction into the network.

BibTeX

@article{han2025sfrnet,
  title   = {Shadow Feature Refinement Network: Progressive Feature Refinement based on Knowledge Distillation for Effective Shadow Removal},
  author  = {Donghyun Han and Byoung-dai Lee},
  journal = {Multimedia Systems},
  volume  = {31},
  pages   = {449},
  year    = {2025},
  doi     = {10.1007/s00530-025-02036-5},
  eprint  = {2610.05325},
  archivePrefix = {arXiv}
}