Let Segment Anything Help Image Dehaze

Zheyan Jin, Shiqi Chen, Yueting Chen, Zhihai Xu, Huajun FengarXiv 2023 · DOI

Abstract

Traditional image dehazing models often struggle with complex, real-world atmospheric conditions due to their limited training data and focus on low-level pixel restoration. This paper introduces a novel framework that leverages the "emergent" anti-fog capabilities of large-scale segmentation models, specifically Meta’s Segment Anything Model (SAM). By extracting robust structural priors from SAM and injecting them into specialized dehazing networks via a grayscale coding scheme, the authors demonstrate significantly improved restoration quality and faster training convergence in challenging, non-uniform haze scenarios.

Introduction

Image dehazing is a fundamental low-level vision task aimed at restoring visibility in images degraded by atmospheric particles. Historically, dehazing models have been relatively small and trained on synthetic or limited datasets. While effective in controlled environments, these models frequently fail in "the wild," where haze is thick, non-uniform, or obscures critical scene structures.

In contrast, high-level vision models like SAM are trained on massive, diverse datasets. These models exhibit emergent properties—capabilities that arise only at a certain scale—including a surprising robustness to atmospheric degradation. The authors observed that while a dedicated dehazing model might struggle to perceive depth or object boundaries through thick fog, SAM can often "see through" the haze to identify underlying structures. This paper explores a method to bridge the gap between high-level structural knowledge and low-level pixel restoration.

Methodology: Integrating SAM Priors

The proposed framework integrates large-model priors into standard encoder-decoder dehazing architectures. This is achieved through a three-step process designed to maintain efficiency while maximizing structural guidance.

1. Emergent Prior Extraction

The process begins by using SAM to generate segmentation masks for hazy input images. Testing revealed that larger versions of SAM (such as ViT-H) are remarkably resilient to haze. Even as fog density increases, these models maintain high segmentation accuracy, providing a reliable "map" of the scene that smaller models cannot generate independently.

2. Grayscale Coding

Standard segmentation masks are typically represented in 3-channel RGB format, which introduces unnecessary computational overhead. To optimize this, the authors developed a "grayscale coding" algorithm. This technique maps over 130 possible segments into a single 8-bit grayscale channel (0-255). This compact representation preserves essential texture and edge information while keeping the input data lean for the subsequent dehazing network.

3. Channel Expansion and Architecture

To utilize this prior, the standard 3-channel (RGB) input of the dehazing encoder is expanded to 4 channels. The fourth channel carries the grayscale-encoded SAM mask. This provides the model with a structural scaffold, guiding the restoration process by indicating where object boundaries and textures should reside.

Overview of the SAM-guided dehazing framework, including mask generation and architecture.

Experimental Setup and Datasets

The efficacy of the mask-guided approach was evaluated across a diverse range of benchmarks:

  • RESIDE & REVIDE: Covering both thin outdoor fog and thick indoor haze.
  • NTIRE Series (2018-2020): Challenging real-world scenarios featuring non-uniform haze and extreme outdoor conditions.
  • Unreal Engine 5 (EPIC): To provide quantitative rigor, the authors used UE5 to render custom smog data. This allowed for precise control over fog concentration (ranging from 0 to 0.2), enabling a direct measurement of SAM’s robustness compared to smaller segmentation models.

Key Insights and Results

Emergence and Robustness

The study confirms that as the parameter count of the segmentation model increases (e.g., from ViT-B to ViT-H), its "anti-fog" capability improves significantly. This suggests that learning general scene representations at scale inherently provides a form of atmospheric robustness that can be harvested for low-level tasks.

Quantitative and Qualitative Gains

In the most difficult benchmarks, such as NTIRE 2019 and 2020, the proposed method yielded performance improvements of 13% to 17% over baseline models lacking mask guidance. Qualitatively, the results are striking: the mask-guided models excel at restoring the natural colors of specific objects and maintaining sharp edges that are typically blurred by standard dehazing algorithms.

Qualitative comparison of dehazing results across various NTIRE benchmarks, showing the impact of mask guidance.

Training Acceleration

Beyond final image quality, the inclusion of SAM masks significantly accelerates training. By providing a structural "hint," the mask allows the dehazing model to bypass the difficult stage of learning scene layout from scratch, allowing it to focus its capacity entirely on the nuances of pixel-level color and contrast restoration.

Conclusion and Future Work

This research demonstrates that large-scale models like SAM can serve as powerful structural teachers for specialized low-level vision tasks. While the current implementation requires a preprocessing step to generate masks—which may limit real-time mobile applications—the gains in robustness and quality are substantial. Future work may involve distilling these large-model priors directly into the dehazing network or applying similar structural guidance to tasks like low-light enhancement and motion deblurring.

Summary updated

BibTeX
@misc{jin2023let,
  author = {Zheyan Jin and Shiqi Chen and Yueting Chen and Zhihai Xu and Huajun Feng},
  title = {{Let Segment Anything Help Image Dehaze}},
  year = {2023},
  eprint = {2306.15870},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2306.15870},
}
Figure