A Generative Adversarial Framework for Optimizing Image Matting and Harmonization Simultaneously

Xuqian Ren, Yifan Liu, Chunlei Song

Introduction

Image editing pipelines typically treat matting—the extraction of a subject with pixel-perfect edges—and harmonization—the adjustment of colors to match a new background—as independent sequential tasks. However, this decoupled approach often leads to sub-optimal results. This paper introduces a novel Generative Adversarial Network (GAN) framework designed to optimize both tasks simultaneously, demonstrating that high-quality edges and natural color blending are mutually beneficial.

The Problem: Decoupled Pipelines

When compositing a subject into a new background, two primary issues arise: "crunchy" edges from imprecise matting (especially around fine details like hair) and lighting/color mismatches that create a "cardboard cutout" effect. Current AI models usually tackle these in isolation. The authors argue that errors in the matting stage propagate to the harmonization stage. By treating these as isolated steps, the system loses the synergy where the requirements of a harmonious final image could guide the model toward a more accurate alpha matte.

Proposed Generative Adversarial Framework

The proposed framework consists of three integrated components designed to work in tandem:

  1. Matting Generator (IndexNet): Produces a high-quality alpha matte from a portrait and a rough trimap.
  2. Harmonization Generator (Attention U-Net): Takes the composite image and the alpha matte, using attention blocks to identify regions requiring color or brightness adjustments.
  3. Self-Attention Discriminator: Acts as a critic, distinguishing edited results from real photos by comparing non-local features, such as lighting consistency across the entire frame.
Overview of the GAN framework for joint training and testing.

The joint training process allows loss from the discriminator to flow back into both generators, forcing the matting network to produce "harmonization-friendly" edges.

Data Innovation: The HMH Dataset

To support joint training, the authors developed the Human Matting and Harmonization (HMH) dataset. Built upon existing human matting data, it utilizes high-quality alpha mattes rather than coarse masks. To create ground-truth pairs for harmonization, the researchers employed the Reinhard color transfer method to synthetically alter background colors, providing the model with clear targets for restoration.

Experimental Results

The simultaneous framework outperformed standalone state-of-the-art models in both tasks. In matting, the joint approach achieved a Mean Squared Error (MSE) of 0.02, significantly lower than the baseline IndexNet (0.11). In harmonization, a user study yielded a Mean Opinion Score (MOS) of 3.58, surpassing specialized networks like DoveNet and DIH.

Qualitative comparison of the proposed method against state-of-the-art harmonization models.

Qualitative analysis shows that the model excels at creating seamless transitions for complex details like hair, effectively eliminating the "white border" artifacts common in traditional compositions.

Conclusion

While the framework represents a significant step forward, challenges remain in handling extreme lighting discrepancies where subjects may appear over-saturated. Future work aims to eliminate the need for manual trimaps, moving toward a fully automated, end-to-end pipeline for real-time consumer applications.

Summary updated

BibTeX
@inproceedings{ren2021generative,
  author = {Xuqian Ren and Yifan Liu and Chunlei Song},
  title = {{A Generative Adversarial Framework for Optimizing Image Matting and Harmonization Simultaneously}},
  booktitle = {ICIP},
  year = {2021},
  url = {https://openreview.net/forum?id=kUsf5GnJxzz},
}
Figure