ShadowFormer: Global Context Helps Image Shadow Removal

Lanqing Guo, Siyu Huang, Ding Liu, Hao Cheng, Bihan WenarXiv 2023 · DOI

Introduction

Image shadow removal is a classic computer vision challenge that involves restoring the underlying "shadow-free" version of an image. Despite significant progress driven by deep learning, two persistent hurdles remain: boundary artifacts and illumination inconsistency. Many existing models focus on local pixel-patching, which often results in "ghosting" effects or visible seams at the shadow boundaries. Furthermore, restored regions frequently fail to match the surrounding non-shadowed areas in color and illumination because the models lack a global understanding of the scene.

To address these issues, we introduce ShadowFormer, a lightweight, transformer-based architecture that treats shadow removal as a global context problem. By modeling the relationship between shadowed and non-shadowed regions, ShadowFormer achieves state-of-the-art results with significantly higher computational efficiency than previous leading models.

Methodology

ShadowFormer is built upon three primary pillars designed to leverage global information for precise restoration:

1. Retinex-Based Shadow Model

The approach is grounded in Retinex theory, which represents an image ($I$) as the element-wise product of illumination ($L$) and reflectance ($R$): $I = L \odot R$. The authors observe that while illumination changes within a shadow, the underlying reflectance—representing the true color and texture—remains consistent with non-shadowed areas. This physical insight justifies using non-shadowed regions as a direct reference for restoring shadowed pixels.

2. Channel Attention (CA) Transformer

Rather than employing standard spatial transformers, which are computationally intensive, ShadowFormer utilizes a hierarchical encoder-decoder structure based on Channel Attention. This design allows the model to capture global information across the entire image efficiently, identifying long-range dependencies without the quadratic complexity of vanilla transformers.

3. Shadow-Interaction Module (SIM)

The core innovation of ShadowFormer is the Shadow-Interaction Module (SIM), located at the network's bottleneck. This module employs a Shadow-Interaction Attention (SIA) mechanism. Using the shadow mask, the SIM distinguishes between "shadow" and "non-shadow" patches and explicitly calculates the correlation between them. This allows shadowed pixels to "borrow" accurate color and texture information from their unshadowed counterparts elsewhere in the image, ensuring global consistency.

Experimental Setup

The model was evaluated on three standard benchmark datasets:

  • ISTD: A popular dataset featuring 1,330 training and 540 testing triplets (shadow image, mask, and ground truth).
  • ISTD+: An adjusted version of ISTD that corrects illumination inconsistencies found in the original ground truth images.
  • SRD: A larger dataset (2,680 training pairs) containing complex real-world scenes with diverse colors and textures.

Key Results and Insights

Superior Performance and Efficiency

ShadowFormer outperformed all previous state-of-the-art (SOTA) methods across the ISTD, ISTD+, and SRD datasets. On the ISTD dataset, it achieved a PSNR of 32.21 dB. Most notably, the "Ours-Small" variant achieves these results using only 2.4 million parameters. Compared to models like CANet, which utilizes 358 million parameters, ShadowFormer represents a 150x reduction in model size while delivering superior performance.

Visual Quality and Robustness

Qualitatively, ShadowFormer produces smoother transitions at shadow boundaries and avoids the "washed out" appearance common in earlier deep learning approaches. The model also demonstrated strong generalization; when trained on synthetic data and tested on real-world images, it outperformed competing models, suggesting that its physics-inspired architecture captures the underlying nature of shadows more effectively than standard "black box" convolutional neural networks (CNNs).

Conclusion

ShadowFormer demonstrates that global context is essential for high-quality image shadow removal. By utilizing a Retinex-inspired architecture and the novel Shadow-Interaction Module, the model can effectively "borrow" information from non-shadowed regions to produce color-consistent, artifact-free results. Future work may involve extending the Shadow-Interaction Module to other partial corruption tasks, such as object removal or localized deblurring, where global reference information is key to successful restoration.

Summary updated

BibTeX
@misc{guo2023shadowformer,
  author = {Lanqing Guo and Siyu Huang and Ding Liu and Hao Cheng and Bihan Wen},
  title = {{ShadowFormer: Global Context Helps Image Shadow Removal}},
  year = {2023},
  eprint = {2302.01650},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2302.01650},
}
Figure