NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Diverse Image Harmonization

Xinhao Tao, Tianyuan Qiu, Junyan Cao, Li NiuarXiv 2024 · DOI

Abstract

Image harmonization is the task of adjusting the foreground of a composite image to match the illumination of the background. While traditional methods seek a single deterministic solution, this paper introduces a framework for diverse image harmonization. By leveraging Retinex theory and a novel two-branch reflectance generation network, the proposed method produces multiple plausible results that account for the inherent ambiguity of an object's intrinsic properties under unknown lighting conditions.

Introduction

In image composition, an object is extracted from one source and placed into a new background. A common artifact of this process is the mismatch in lighting between the foreground and background, which breaks the visual realism of the scene. Image harmonization aims to correct this by re-lighting the foreground object.

The primary challenge in this field is ambiguity. According to Retinex theory, an image $I$ is the product of its reflectance $A$ (the object's true color) and its illumination $L$. Given only a composite image, it is often impossible to determine whether a color shift is due to the object's reflectance or the scene's lighting. Most existing deep-learning models ignore this uncertainty, producing a single "best guess." This research addresses the problem by generating a variety of realistic outputs that reflect different possible interpretations of the scene.

A composite image showing a lighting mismatch. The foreground object (right bird) is highlighted with a green outline to indicate the area requiring harmonization.

Methodology

The authors propose a two-stage framework designed to handle reflectance uncertainty.

Reflectance-Guided Harmonization

The core architecture is a modified harmonization backbone (such as iSSAM or PCT-Net) that accepts a foreground reflectance map as an auxiliary input. The research demonstrates that if the model is provided with the "true" reflectance, the harmonization task becomes significantly more accurate, as the reflectance acts as a physical "anchor" for the transformation.

Diverse Reflectance Generation

To handle the lack of ground-truth reflectance at inference time, a Diverse Reflectance Generation Network is employed. It consists of two branches:

  • Supervised Branch: During training, this branch uses the original, unedited foreground image to learn the target reflectance.
  • Unsupervised Branch: This branch utilizes a Variational Autoencoder (VAE) to sample a "guidance code" from a learned distribution. By sampling different codes, the network generates multiple plausible reflectance maps ($A_{pre}$).
  • Dynamic Kernels: To effectively inject the guidance code into the generation process, the network uses dynamic convolutions where the filter weights are predicted based on the sampled code.

Experimental Evaluation

The framework was evaluated on the iHarmony4 benchmark and the RealHM dataset. To provide training labels, a pre-trained RelightingNet was used to decompose original images into reflectance and illumination layers.

A harmonized result where the foreground object's illumination has been adjusted to match the background scene.

Key Results

  • Accuracy Gains: Incorporating ground-truth reflectance significantly improved performance across all metrics. For the iS2AM backbone, the Mean Squared Error (MSE) improved from 24.64 to 21.37.
  • Best-of-Many Performance: When the model generated 10 diverse versions, the "best" version often outperformed deterministic state-of-the-art models, indicating that the optimal solution often resides within the generated distribution.
  • Consistent Diversity: The generated diversity is not random; it follows physical intuition. For example, variations in predicted reflectance lead to consistent shifts in the final harmonized image's mood and tone.

Conclusion

This work shifts the paradigm of image harmonization from deterministic prediction to probabilistic generation. By explicitly modeling the uncertainty of reflectance, the proposed method provides more robust and creative results for complex photo editing tasks. Future research may extend this approach to handle non-Lambertian surfaces, such as glass and metal, which are not fully captured by basic Retinex theory.

Summary updated

BibTeX
@misc{tao2024diverse,
  author = {Xinhao Tao and Tianyuan Qiu and Junyan Cao and Li Niu},
  title = {{Diverse Image Harmonization}},
  year = {2024},
  eprint = {2407.15481},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.15481},
}
Figure