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 · DOI

Abstract

High-precision image matting in unconstrained environments is hindered by the lack of diverse, natural training data and the limitations of existing segmentation models in capturing fine-grained transparency. We present SEMat (Semantic Enhanced Matting) and a novel dataset, COCO-Matting, to address these issues. By incorporating real-world priors from the COCO dataset and introducing a semantic-enhanced architecture based on the Segment Anything Model (SAM), our approach significantly improves matting quality for complex subjects in the wild.

Introduction

Image matting—the task of separating a foreground object from its background with pixel-level transparency—is critical for high-end graphics and vision applications. While recent advances in segmentation, such as the Segment Anything Model (SAM), have shown remarkable zero-shot generalization, they often fail to provide the nuance required for matting, such as individual hair strands or soft edges.

This failure is largely due to a "data discrepancy" between synthetic training sets and real-world images. Most matting models are trained on foregrounds digitally pasted onto random backgrounds, which fails to capture the complex lighting, occlusions, and interactions (like a person holding a bag) found in "in the wild" photography. Furthermore, interactive matting tools often treat SAM as a frozen feature extractor, failing to exploit its deep semantic knowledge for transparency estimation.

The COCO-Matting Dataset

To bridge the gap between synthetic and real-world data, we introduce COCO-Matting. Unlike traditional datasets, COCO-Matting utilizes real-scenario images from the COCO and COCONut datasets. We employ two key techniques to ensure high-quality labels:

  1. Accessory Fusion: Standard segmentation labels often separate a person from their accessories (e.g., hats, bags). For matting, these are usually considered a single subject. We use an IoU-based fusion method to merge these into a cohesive "human instance" mask.
  2. Mask-to-Matte Conversion: We convert rough binary masks into high-quality alpha mattes using a specialized trimap-based refinement network, resulting in 38,251 natural, instance-level labels.
Comparison of COCO-Matting with existing datasets and its impact on Instance Matting Quality (IMQ).

SEMat Architecture

The SEMat framework enhances SAM's semantic capabilities for the matting task through a two-pronged architectural revamp:

  • Feature-Aligned Transformer (FAT): Instead of using SAM as a frozen feature extractor, we utilize LoRA (Low-Rank Adaptation) to fine-tune the ViT backbone. This allows the model to adapt its deep semantic knowledge specifically for transparency estimation and fine-grained edge detection.
  • Matte-Aligned Decoder (MAD): We introduce specialized "matting tokens" and a matting adapter to the mask decoder. This is followed by a lightweight UNet-style decoder that restores high-resolution details often lost during internal downsampling.
  • Specialized Losses: We implement a Regularization Loss to ensure the model retains SAM's robust pre-trained knowledge, alongside a Trimap Loss to push the decoder to distinguish between foreground, background, and the "unknown" transition regions.

Key Results

SEMat demonstrates a substantial lead over previous state-of-the-art (SoTA) methods like MAM and SmartMat. On the P3M-500-NP benchmark, SEMat achieved a 69.8% relative improvement over the MatAny baseline.

As illustrated in Figure 1 (III), training on COCO-Matting provides a significant boost in Instance Matting Quality (IMQ) across various metrics (MAD, Grad, Conn, MSE) when tested on natural human matting datasets. Qualitative results highlight SEMat's ability to handle extremely challenging subjects, such as basketball nets, fine animal fur, and complex hair structures, which typically cause "chunky" artifacts in standard segmentation models. Despite these gains, the model remains efficient, adding only approximately 18M trainable parameters to the pre-trained SAM backbone.

Conclusion

By leveraging real-scenario priors and a semantically enhanced architecture, SEMat and COCO-Matting provide a robust solution for image matting in the wild. The integration of real-world data and targeted fine-tuning of large-scale models like SAM proves to be a powerful strategy for overcoming the limitations of synthetic training environments. Future work will focus on expanding the COCO-Matting approach to include a wider variety of non-human object categories.

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