Human Perception Modeling for Automatic Natural Image Matting

Yuhongze Zhou, Liguang Zhou, Tin Lun Lam, Yangsheng Xu

Abstract

This paper introduces a two-stage, semantic-guided pipeline that automates natural image matting, eliminating the need for labor-intensive manual trimaps. By combining a dedicated Trimap Generation Network (Net-T) with a light-weight Non-local Matting Network (Net-M), the authors achieve state-of-the-art results while significantly reducing computational complexity through a novel, downsampled attention mechanism.

Introduction

Image matting is the process of precisely extracting a foreground object from its background by calculating an "alpha matte"—a per-pixel opacity map. Mathematically, this is an under-constrained problem: for every pixel, we have three known values (RGB) but need to solve for seven unknowns (foreground RGB, background RGB, and alpha).

To simplify this, most high-performing algorithms require a trimap: a hand-drawn guide that labels pixels as definitely foreground, definitely background, or "unknown." However, creating accurate trimaps is tedious and expensive. While automatic "trimap-free" methods exist, they often struggle with complex backgrounds, shadows, or specific object categories. This paper tackles the "trimap quandary" by creating a system that generates its own high-quality trimaps from a rough semantic mask and then uses them to produce a refined alpha matte.

Methods

The authors propose a modular architecture consisting of two primary networks:

  1. Trimap Generation Network (Net-T): Instead of jumping straight to the alpha matte, Net-T takes a raw image and a coarse, "soft" segmentation mask (which is easy to generate using standard off-the-shelf models). It uses a modified DeepLabv3 encoder and a custom decoder to predict a precise 3-class trimap. This stage essentially "cleans up" the rough input to provide better guidance for the next step.
  2. Non-local Matting Network (Net-M): This network takes the original image and the predicted trimap to estimate the alpha matte. It features two key innovations:
  3. Light-weight Non-local Attention (NLM): Standard non-local blocks capture global context by comparing every pixel to every other pixel, which is computationally expensive ($O(N^2)$). The authors use stride convolutions to downsample the feature maps before calculating attention, drastically reducing the GFLOPs while still capturing the necessary global relationships.
  4. Refinement Module: A final stage that learns the residuals between a coarse alpha prediction and the ground truth, "polishing" the fine details like hair or transparent edges.
The proposed two-stage pipeline consisting of Net-T, NLM, and a Refinement Module.

Experimental Setup

The model was trained and evaluated on several industry-standard benchmarks:

  • Composition-1k: A large-scale dataset for matting evaluation.
  • Distinctions-646: A dataset featuring 646 distinct foreground objects.
  • alphamatting.com: A competitive online benchmark where the authors' method achieved top-tier rankings.
  • Real-World Human Data: To prove practical utility, the authors collected 37 handheld videos and used a GAN-based adaptation strategy to fine-tune the model for real-world performance without manual labels.

Key Results

On the Composition-1k test set, the proposed method (Net-M) outperformed several well-known models like Deep Image Matting (DIM) and GCA-Matting across all metrics (SAD, MSE, Gradient, and Connectivity errors).

The light-weight attention block is remarkably efficient. Compared to GCA-Matting, the authors' attention mechanism reduced parameters from 49,792 to 25,984 and slashed GFLOPs from 3.56 to 0.14—a nearly 25x reduction in computational cost for that specific module. Ablation studies showed that even when the input coarse segmentation was significantly eroded or dilated, Net-T was able to recover a usable trimap, proving the system's fault tolerance.

Qualitative results showing the predicted alpha mattes for various challenging objects.

Discussion

  • Disentanglement is Key: By separating trimap generation from alpha estimation, the network becomes more robust. The trimap acts as a "buffer" that prevents errors in the initial coarse segmentation from ruining the final matte.
  • Efficiency via Downsampling: One of the biggest "aha" moments is that you don't need full-resolution feature maps to calculate effective global attention for matting. Downsampling the "keys" and "values" in the attention block (using a stride of 4) maintains performance while making the model much faster.
  • Semantic Guidance: Using a coarse segmentation mask as an "indicator" helps the network understand the object's shape and its relationship with the surroundings, which is more effective than relying on the RGB image alone.

Conclusion

While the system is highly effective, the authors note some areas for improvement. Although robust, the system still requires some form of initial coarse segmentation. If the initial segmenter fails completely, the pipeline cannot recover. Furthermore, to get the best results on real-world video, the authors had to employ a GAN-based fine-tuning process. Future work includes extending this light-weight attention mechanism to video matting while maintaining temporal smoothness across frames.

Summary updated

BibTeX
@misc{zhou2021human,
  author = {Yuhongze Zhou and Liguang Zhou and Tin Lun Lam and Yangsheng Xu},
  title = {{Human Perception Modeling for Automatic Natural Image Matting}},
  year = {2021},
  eprint = {2103.17020},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2103.17020},
}
Figure