Semantic-guided Automatic Natural Image Matting with Trimap Generation Network and Light-weight Non-local Attention

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

Abstract

Natural image matting aims to precisely separate foreground objects from background using alpha matte. Fully automatic natural image matting without external annotation is challenging. Well-performed matting methods usually require accurate labor-intensive handcrafted trimap as extra input, while the performance of automatic trimap generation method of dilating foreground segmentation fluctuates with segmentation quality. Therefore, we argue that how to handle trade-off of additional information input is a major issue in automatic matting. This paper presents a semantic-guided automatic natural image matting pipeline with Trimap Generation Network and light-weight non-local attention, which does not need trimap and background as input. Specifically, guided by foreground segmentation, Trimap Generation Network estimates accurate trimap. Then, with estimated trimap as guidance, our light-weight Non-local Matting Network with Refinement produces final alpha matte, whose trimap-guided global aggregation attention block is equipped with stride downsampling convolution, reducing computation complexity and promoting performance. Experimental results show that our matting algorithm has competitive performance with state-of-the-art methods in both trimap-free and trimap-needed aspects.

Introduction

Image matting—the process of precisely extracting a foreground object from its background—is a fundamental task in image editing. Traditionally, high-quality matting requires a "trimap": a hand-drawn guide that labels pixels as definitely foreground, definitely background, or unknown.

Creating these trimaps is labor-intensive and impractical for real-time or large-scale applications. While "trimap-free" methods exist, they often struggle with complex backgrounds or generic objects, or they require a pre-captured "background plate." The authors identify a critical trade-off: how to provide enough additional information to the network to ensure accuracy without requiring tedious manual input.

Methodology

The proposed semantic-guided pipeline consists of two main stages designed to automate the extraction process while maintaining high precision.

The overall architecture of the proposed automatic matting pipeline, featuring the Trimap Generation Network (Net-T), the Non-Local Matting Network (NLM), and the Refinement Module.

Trimap Generation Network (Net-T)

Instead of relying on a human, this network takes a raw image and a coarse, "soft" foreground segmentation (easily obtained from standard off-the-shelf models) to predict a 3-class trimap. It uses a modified DeepLabv3 architecture with a custom decoder designed to be more tolerant of inaccurate initial segmentations, acting as a buffer that prevents errors in the initial coarse segmentation from ruining the final matte.

Non-local Matting Network (Net-M)

This U-Net-style network takes the original image and the predicted trimap to estimate the final alpha matte. Its core innovation is the Light-weight Non-local Attention (NLM) block.

Detailed structure of the Light-weight Non-local Attention block, which uses stride downsampling to reduce computational complexity while maintaining global context.

Standard non-local attention blocks are computationally expensive because they calculate relationships between every pair of pixels. The authors introduce stride downsampling convolution within the attention block. This captures long-range dependencies (like hair textures across an image) while drastically reducing the number of calculations. Finally, a Refinement Module learns the "residuals" between a coarse matte and the ground truth to polish the final output.

Experimental Results

The model was trained and evaluated on several industry-standard benchmarks, including Composition-1k and Distinctions-646.

  • Accuracy: On the Composition-1k test set, the proposed Net-M achieved a SAD (Sum of Absolute Differences) of 29.43, outperforming previous state-of-the-art methods like GCA-Matting (35.28) and IndexNet (45.80).
  • Efficiency: The light-weight attention block is remarkably efficient. Compared to GCA-Matting, it uses roughly half the parameters (25,984 vs 49,792) and is about 25 times faster in terms of GFLOPs (0.1416 vs 3.5621).
  • Robustness: In ablation studies, the network remained stable even when the input segmentation was significantly eroded or dilated, proving its "anti-jamming" capability.

Conclusion

By separating trimap generation from alpha estimation, the system becomes more robust. The "aha moment" in their attention block is that pixel-to-pixel precision is not required for the entire global context. By using stride convolutions to downsample feature maps before calculating attention, the authors maintain performance while using significantly fewer computational resources. Future work may explore tighter integration between stages and handling extremely high-resolution 4K+ video in real-time.

Summary updated

BibTeX
@misc{zhou2021semantic,
  author = {Yuhongze Zhou and Liguang Zhou and Tin Lun Lam and Yangsheng Xu},
  title = {{Semantic-guided Automatic Natural Image Matting with Trimap Generation Network and Light-weight Non-local Attention}},
  year = {2021},
  eprint = {2103.17020},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2103.17020},
}
Figure