NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Towards Natural Image Matting in the Wild via Real-Scenario Prior

Ruihao Xia, Yu Liang, Peng-Tao Jiang, Hao Zhang, Qianru Sun, Yang Tang, Bo Li, Pan Zhou · Submission to ICLR 2025 · Withdrawn

TL;DR

Existing interactive image matting models struggle in complex, real-world scenes because they rely heavily on synthetic training data and fail to fully harness the feature representations of foundation models like Segment Anything (SAM). To bridge this gap, this paper introduces COCO-Matting—a dataset of over 38,000 real-world, instance-level human alpha mattes—and SEMat, a framework that adapts SAM using feature/matte-aligned architectures and trimap-guided regularization.

What Problem Does This Paper Address?

Interactive image matting aims to extract high-precision foreground alpha mattes (capturing continuous transparency like hair, glass, or smoke) using simple user prompts such as bounding boxes. However, training these models poses two core challenges:

  1. The Synthetic Data Trap: Ground-truth alpha mattes are labor-intensive to annotate. Most models rely on pasting cutouts onto arbitrary backgrounds, resulting in synthetic images that fail to reflect complex lighting, overlapping subjects, and real-world occlusions.
  2. Suboptimal SAM Adaptation: While pre-trained models like SAM offer powerful visual priors, previous matting methods merely feed frozen SAM features or coarse binary masks into a small matting decoder. This setup ignores SAM’s feature mismatch with continuous transparency, struggles with matting-specific objects (e.g., nets, silk), and risks degrading SAM's robust general knowledge during fine-tuning.

Methods

[ BBox + Image ] ──► [ Feature-Aligned Transformer (LoRA) ] 
                             │
                             ▼
                 [ Matte-Aligned Decoder ]
                 ┌───────────┴───────────┐
                 ▼                       ▼
           [ SAM Logits ]        [ Matting Logits ]
                 │                       │
      (Regularization Loss)         (Trimap Loss)
                 │                       │
                 └───────────┬───────────┘
                             ▼
                 [ UNet Matting Decoder ] ──► Final Alpha Matte

The authors tackle these bottlenecks through both data generation and model design:

  • COCO-Matting Dataset Construction:
  • Accessory Fusion: In segmentation benchmarks like COCO, accessories (bags, hats, held items) are labeled as distinct classes. In matting, they are treated as part of the human subject. The authors merge accessory masks based on bounding-box IoU thresholds ($\tau > 0.8$) and dilation checks.
  • Mask-to-Matte: Coarse binary masks are converted into soft alpha labels using adaptive erosion/dilation to generate pseudo-trimaps, which are refined using an existing pre-trained trimap-based matting network.
  • SEMat (Semantic Enhanced Matting) Architecture:
  • Feature-Aligned Transformer (FAT): The bounding-box prompt is converted to a binary mask and concatenated with image patches via a learned embedding, tuned alongside the ViT backbone using Low-Rank Adaptation (LoRA) to focus early features on fine boundaries.
  • Matte-Aligned Decoder (MAD): Enhances SAM's mask decoder with three learnable "matting tokens" and an adapter module. It predicts both a standard SAM mask and a 3-channel coarse matting logit (foreground, background, unknown). A lightweight UNet decoder then restores full-resolution details.
  • Dual-Objective Supervision:
  • Regularization Loss ($L_{\text{Reg}}$): Distills predictions from a parallel, frozen SAM to prevent the network from catastrophic forgetting when exposed to matting data.
  • Trimap Loss ($L_{\text{Trimap}}$): Supervises intermediate matting logits using ground-truth trimaps with a Gradient Harmonizing Mechanism (GHM) loss, forcing the internal tokens to learn semantic transitions before the final refinement.

Datasets

  • COCO-Matting (New): 38,251 human instance alpha mattes situated in natural, multi-instance, and occluded environments derived from COCO/COCONut.
  • Existing Training Sets: Composition-1k, Distinction-646, and AM-2K.
  • Evaluation Benchmarks: Evaluated across seven diverse benchmarks: P3M-500-NP, RWP636, RefMatte-RW100 (human matting), AM-2K (animals), AIM-500 (objects), SIM (synthetic transparency), and HIM2K (human instance matting).

Key Insights and Ideas

  • Semantic Mismatch Matters as Much as Resolution: Models trained solely on synthetic humans fail when two people overlap because they lack contextual scene comprehension. High-quality natural datasets (even if pseudo-labeled) provide critical semantic disambiguation.
  • Internalizing the Trimap: Trimap-based matting typically outperforms interactive prompt-based matting because the "unknown" transition zone simplifies the learning problem. By forcing internal decoder tokens to predict a pseudo-trimap via $L_{\text{Trimap}}$, SEMat captures the advantages of trimaps without requiring manual trimap inputs at inference.
  • Priors Must Be Explicitly Protected: Unconstrained fine-tuning on matting targets erodes SAM's general object awareness. Maintaining consistency against a frozen SAM branch ($L_{\text{Reg}}$) stabilizes generalization to unseen objects.

Key Results

  • Benchmark Generalization: SEMat consistently outperforms recent foundation-based matting models (MAM, MatAny, SmartMat). Compared to the previous state-of-the-art (SmartMat), SEMat achieves relative SAD improvements of 32% on P3M, 45% on RefMatte-RW100, and 21% on AM-2K.
  • Human Instance Matting: On the HIM2K benchmark, SEMat combined with Grounding DINO achieves an Instance Matting Quality (IMQ) gain of 5.8% to 9.6% over dedicated instance matting frameworks like InstMatt.
  • Backbone Flexibility: The architectural improvements are model-agnostic, providing consistent quantitative gains when instantiated across vanilla SAM, HQ-SAM, and SAM 2.

Limitations and Future Work

  • Bottlenecked by Foundation Model Coverage: SEMat relies on SAM's pre-trained representations. While effective for common categories, failure modes in SAM (such as rare object categories or non-standard distributions) propagate downstream to the matting stage.
  • Human-Centric Data Bias: COCO-Matting currently targets human subjects due to the complexity of human interactions and accessories. Extending the automated pseudo-labeling pipeline to generic object classes remains an open direction.

Summary updated

BibTeX
@misc{xia2024towards,
  author = {Ruihao Xia and Yu Liang and Peng-Tao Jiang and Hao Zhang and Qianru Sun and Yang Tang and Bo Li and Pan Zhou},
  title = {{Towards Natural Image Matting in the Wild via Real-Scenario Prior}},
  year = {2024},
  eprint = {2410.06593},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.06593},
}
Figure