Harmonizer: Learning to Perform White-Box Image and Video Harmonization

Zhanghan Ke, Chunyi Sun, Lei Zhu, Ke Xu, Rynson W. H. Lau

Overview

Harmonizer shifts image harmonization from a heavy "black-box" pixel-translation task to a lightweight "white-box" regression problem. By using a neural network to predict parameters for standard image filters (like brightness and contrast) rather than regenerating pixels from scratch, it achieves state-of-the-art accuracy while running at a blistering 56 FPS at 1080p resolution.

The Challenge of Image Harmonization

Image harmonization is the process of adjusting a "cut-and-paste" foreground object to match the lighting, color temperature, and contrast of a new background. Current state-of-the-art methods typically treat this as a pixel-to-pixel translation task using deep autoencoders. While effective, these "black-box" models suffer from three major drawbacks:

  1. Resolution Dependence: They are computationally expensive and slow down significantly as resolution increases.
  2. Texture Loss: Reconstructing images through convolutional layers often "smudges" the original fine textures of the foreground.
  3. High Overhead: Models are often too large (>100MB) for real-time or mobile deployment.

The Harmonizer Framework

Harmonizer mimics the manual workflow of a human artist by adjusting global filter "sliders" rather than redrawing pixels. This "white-box" approach ensures that the original high-frequency details of the foreground are perfectly preserved.

Comparison of image harmonization architectures: (a) Matching-based, (b) Autoencoder-based, and (c) the proposed Harmonizer.

Architecture and Methodology

  • Backbone Encoder: A lightweight EfficientNet-B0 extracts semantic features from a downsampled (256x256) version of the composite image and its mask.
  • Cascade Regressor: Instead of predicting all settings at once, a cascade approach predicts filter arguments sequentially. This accounts for the fact that image filters (e.g., brightness and highlights) are often interdependent.
  • White-Box Filters: The model predicts arguments for six differentiable filters: brightness, contrast, saturation, color temperature, highlights, and shadows.

To stabilize training, the authors introduced a Dynamic Loss Strategy that reweights the importance of each filter based on learning difficulty. For video applications, an Exponential Moving Average (EMA) is applied to predicted arguments across frames to prevent flickering and ensure smooth transitions.

Filter Selection and User Study

The choice of the six core filters was informed by a User Study with 26 participants to determine which adjustments humans find most critical for harmonization. The model was evaluated on the iHarmony4 benchmark, which includes diverse lighting conditions and professional photography.

User study importance scores (left) and predicted argument ranges (right) for the core image filters.

Key Results

  • Superior Accuracy: Harmonizer outperformed previous models (like IHT and BARG) on the iHarmony4 benchmark, reducing average Mean Squared Error (MSE) by roughly 35%.
  • Blazing Speed: On an NVIDIA RTX 3090, Harmonizer processes 1080p video at 56 FPS, whereas previous models struggled to reach 10 FPS.
  • Texture Preservation: Because the filters are mathematical transformations (e.g., $f(x) = ax + b$), the original high-resolution textures are never altered by convolutions.
  • Efficiency: The model size is only 21.7 MB, making it significantly more portable than traditional 100MB+ autoencoders.

Limitations and Future Work

While powerful, Harmonizer relies on global filters. This means it may struggle with directional lighting (e.g., a light source from the left when the foreground is lit from the right) or extreme color inconsistencies that simple sliders cannot resolve. Future work may involve developing more complex, spatially-varying "white-box" relighting tools to handle these edge cases.

Summary updated

BibTeX
@inproceedings{ke2022harmonizer,
  author = {Zhanghan Ke and Chunyi Sun and Lei Zhu and Ke Xu and Rynson W. H. Lau},
  title = {{Harmonizer: Learning to Perform White-Box Image and Video Harmonization}},
  booktitle = {European Conference on Computer Vision},
  year = {2022},
  doi = {10.1007/978-3-031-19784-0\_40},
}
Figure