Image Harmonization by Matching Regional References

Ziyue Zhu, Zhao Zhang, Zheng Lin, Ruiqi Wu, Zhi Chai, Chun-Le GuoarXiv 2022 · DOI

Abstract

Image harmonization aims to adjust the appearance of a foreground object to match its new background in a composite image. Traditional methods often rely on global statistics, which fail to capture local variations in lighting and color. This paper proposes a novel framework utilizing Locations-to-Location (LTL) and Patches-to-Location (PTL) translation modules to adaptively harmonize foreground pixels based on relevant local background regions. Evaluated on the iHarmony4 benchmark, the method achieves state-of-the-art performance by effectively matching regional references.

Introduction

Image harmonization is the process of making a "cut-and-paste" composite image look natural. When a foreground object is moved from one photo to another, discrepancies in lighting, color temperature, and saturation often create a jarring visual disconnect.

Existing deep learning methods typically address this by analyzing the entire background to apply a global transformation to the foreground. However, this approach overlooks the fact that lighting and color vary across a scene. For instance, if a pineapple is inserted into a new background, its green leaves should be harmonized based on other green plants, while its yellow body should refer to similarly colored background elements. A single global adjustment fails to capture these regional nuances.

Regional attention mechanism: the model focuses on different background areas for the leaves versus the body of the pineapple.

Methodology

The proposed architecture is a U-Net-based generator that incorporates three key innovations designed to handle regional context at different scales.

Locations-to-Location Translation (LTL)

Operating on deep, low-resolution layers, the LTL module handles coarse, semantic-level harmonization. It employs an attention mechanism where each foreground location acts as a "query" to find and fuse information from related background "keys."

Patches-to-Location Translation (PTL)

Operating on shallow, high-resolution layers, the PTL module manages fine-grained details like color tone and illumination. The background is divided into overlapping patches. The model calculates content similarity between foreground pixels and these patches, then applies specific style statistics (mean and standard deviation) from the most relevant patches to the foreground.

Residual Reconstruction Layer

Rather than generating a new foreground from scratch—which can lead to loss of texture—the network predicts a residual adjustment map. This map is added to the original composite foreground, tuning the appearance while preserving the underlying image structure.

The overall architecture of the proposed harmonization network featuring LTL and PTL modules within a U-Net framework.

Experiments and Results

The model was evaluated on iHarmony4, the gold standard for image harmonization, which includes sub-datasets such as HCOCO, HAdobe5K, HFlicker, and Hday2night. The training and testing involved 73,147 pairs of synthesized composite images and their ground truth counterparts.

Quantitative Performance

The proposed method achieved state-of-the-art (SOTA) performance across all metrics. Compared to the previous leading method (D-HT), the standard model improved the foreground Mean Squared Error (fMSE) by 38.01 and increased the Peak Signal-to-Noise Ratio (PSNR) by 0.42 dB. A higher-capacity version of the model ("Ours-p") further extended the fMSE improvement to 72.66 over D-HT.

Qualitative Analysis

Visual comparisons demonstrate that the model effectively avoids the "washed out" appearance common in global methods. It excels in complex scenes where the foreground must match specific, non-uniform background lighting conditions.

Conclusion

The core insight of this work is that local context provides a much stronger supervisor for harmonization than global statistics. By implementing a coarse-to-fine hierarchy through LTL and PTL modules, the model mimics human perception—first establishing a general semantic match and then refining specific colors and textures. While the reliance on synthetic training data remains a challenge for the field, this regional reference approach sets a new standard for realistic image composition.

Summary updated

BibTeX
@misc{zhu2022image,
  author = {Ziyue Zhu and Zhao Zhang and Zheng Lin and Ruiqi Wu and Zhi Chai and Chun-Le Guo},
  title = {{Image Harmonization by Matching Regional References}},
  year = {2022},
  eprint = {2204.04715},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2204.04715},
}
Figure