Direction-aware Spatial Context Features for Shadow Detection and Removal

Xiaowei Hu, Chi-Wing Fu, Lei Zhu, Jing Qin, Pheng-Ann Heng · DOI

Introduction

Shadows are a fundamental aspect of natural scenes, providing critical information about lighting and geometry. However, for many computer vision tasks like object tracking and detection, shadows act as noise that can lead to significant errors. The primary difficulty lies in disambiguation: distinguishing between a dark-colored object and a shadow cast on a surface. This paper, published in IEEE Transactions on Pattern Analysis and Machine Intelligence, introduces a novel deep learning framework that leverages direction-aware spatial context to solve both shadow detection and removal.

The Challenge of Context

Traditional shadow detection algorithms often rely on local features, such as the color or texture of a small image patch. However, local information is frequently insufficient. A dark region might be a shadow, or it might simply be a dark material.

Ambiguity in shadow detection: distinguishing between shadows and dark materials requires context.

As shown in the figure above, point A (a shadow) and point C (a dark part of the bench) might look similar in isolation. To correctly identify A as a shadow, a model must look at point B (the lit part of the same surface). Crucially, the most informative context isn't always uniformly distributed; the direction of the light source makes certain neighboring regions more relevant than others.

Proposed Framework

The authors propose a Direction-aware Spatial Context (DSC) module designed to capture global image context while prioritizing informative directions. This module is integrated into a multi-scale Convolutional Neural Network (CNN) architecture.

The overall architecture of the proposed network featuring DSC modules and multi-scale fusion.

Direction-aware Spatial Context (DSC)

The core of the architecture is the DSC module, which employs a spatial Recurrent Neural Network (RNN) to propagate information across the image in four directions: up, down, left, and right. Unlike standard global context methods, the DSC module incorporates a direction-aware attention mechanism. This mechanism learns to assign different weights to the context features coming from each direction at every pixel, allowing the model to focus on the most relevant spatial cues for shadow identification.

Multi-scale Fusion and Color Compensation

The network extracts features at multiple scales to capture both fine-grained boundary details and high-level semantic information. These features are fused to generate the final shadow masks. For the task of shadow removal, the authors identified a common issue in existing datasets: "shadow-free" ground truth images often have inconsistent color balances compared to their shadowed counterparts. To address this, they introduced a color transfer function to align the training data, leading to a more robust model variant termed DSC+.

Experimental Results

The proposed method was evaluated on several benchmark datasets, including SBU and UCF for detection, and SRD and ISTD for removal.

  • Shadow Detection: On the SBU dataset, the DSC model achieved a state-of-the-art Balance Error Rate (BER) of 5.59, significantly outperforming previous methods.
  • Shadow Removal: The DSC+ model achieved the lowest Root Mean Square Error (RMSE) in the LAB color space recorded at the time, with scores of 6.21 on SRD and 6.67 on ISTD.
  • Efficiency: The model is computationally efficient, processing a 400x400 image in approximately 0.16 seconds on a modern GPU.

Conclusion

By explicitly modeling the directional nature of spatial context, the DSC framework provides a powerful solution for shadow analysis. The attention-driven spatial RNN allows the network to "look around" intelligently, effectively disambiguating shadows from dark objects. While challenges remain in handling extremely fragmented shadows or scenes with zero informative context, this work sets a new benchmark for accuracy and efficiency in shadow detection and removal. Future work may extend these directional features to video processing and other context-dependent vision tasks.

Summary updated

BibTeX
@article{hu2018direction,
  author = {Xiaowei Hu and Chi-Wing Fu and Lei Zhu and Jing Qin and Pheng-Ann Heng},
  title = {{Direction-aware Spatial Context Features for Shadow Detection and Removal}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2018},
  doi = {10.1109/tpami.2019.2919616},
}
Figure