Region-Aware Adaptive Instance Normalization for Image Harmonization

Jun Ling, Han Xue, Li Song, Rong Xie, Xiao Gu

Abstract

Image harmonization is the task of adjusting the appearance of a foreground object to match a new background scene, ensuring visual consistency in composite images. Traditional methods often treat this as a direct image-to-image mapping problem. This paper proposes a novel perspective by framing image harmonization as a style transfer task. We introduce the Region-aware Adaptive Instance Normalization (RAIN) module, which explicitly captures visual styles—such as lighting, color temperature, and saturation—from the background and applies them to the foreground. Our proposed architecture, RainNet, demonstrates superior performance on the iHarmony4 benchmark, significantly improving both quantitative metrics and visual realism compared to existing state-of-the-art methods.

Introduction

When compositing an image—for example, placing a car from a sunny photo into a rainy street scene—the result often appears unnatural due to visual style discrepancy. The foreground object retains the illumination and color characteristics of its original source, which clashes with the new environment. While deep learning has advanced image harmonization, many models struggle to adapt when the same object is placed into vastly different environments because they do not explicitly ensure style consistency.

This paper addresses the problem by treating the background as a "style" that must be transferred onto the foreground "content." By explicitly modeling this relationship, the proposed method ensures that the foreground object inherits the statistical distribution of its new surroundings.

Methodology

The core innovation of this work is the Region-aware Adaptive Instance Normalization (RAIN) module. Unlike standard Adaptive Instance Normalization (AdaIN), which pulls style from an external reference image, RAIN extracts the channel-wise mean ($\mu$) and variance ($\sigma$) specifically from the background regions of the composite image itself.

RainNet Architecture

The RAIN module is integrated into a U-Net-style generator called RainNet. The authors found that RAIN is most effective when placed in the decoder stages of the network. In these stages, high-level semantic features are reconstructed into pixels, and the RAIN module forces the foreground features to "wear" the statistical distribution of the background, ensuring seamless integration during the final rendering process.

The RainNet architecture featuring RAIN modules integrated into the decoder stages to harmonize foreground features with background statistics.

Because RAIN is a normalization layer, it offers drop-in compatibility and can be integrated into other existing harmonization architectures to boost their performance.

Experimental Setup and Datasets

The models were trained and evaluated on iHarmony4, the current gold standard for image harmonization. This dataset contains 73,147 pairs of synthesized composite images and their corresponding ground truth real images, divided into four sub-datasets:

  • HCOCO and HFlicker: Synthetic foreground adjustments based on COCO and Flickr.
  • HAdobe5K: Based on the MIT-Adobe FiveK dataset.
  • Hday2night: Focused on extreme lighting changes, such as day-to-night transitions.

Results and Discussion

RainNet achieved state-of-the-art performance across almost all sub-datasets. Quantitatively, it improved the Peak Signal-to-Noise Ratio (PSNR) by an average of 1.37dB over the previous leading method, DoveNet. Furthermore, using the foreground Mean Squared Error (fMSE) metric, RainNet outperformed baselines by a massive margin (469.60 vs 808.68), proving its efficacy in specifically adjusting the object of interest.

Qualitative comparison of RainNet against other state-of-the-art harmonization methods (DIH, DoveNet, S²AM) across various scenes.

In a blind user study with 11 volunteers, RainNet's results were preferred 32.5% of the time, significantly higher than competing methods like DIH (18.6%) or DoveNet (20.8%). The success of the model stems from the realization that the background provides the ground truth for the foreground's appearance; by treating the background as the style source, the model effectively matches the local environment without needing to "guess" the correct lighting.

Conclusion and Future Work

While RainNet sets a new benchmark for image harmonization, some limitations remain. The model occasionally "softens" or slightly blurs foreground objects to achieve harmony, particularly in dark scenes with sharp foregrounds. Additionally, the specific reasons why RAIN provides significantly more benefit in the decoder than the encoder remain a subject for further study. Future research may explore more complex definitions of "style" beyond simple mean and variance and investigate methods to maintain sharp object boundaries while achieving perfect color harmony.

Summary updated

BibTeX
@inproceedings{ling2021region,
  author = {Jun Ling and Han Xue and Li Song and Rong Xie and Xiao Gu},
  title = {{Region-Aware Adaptive Instance Normalization for Image Harmonization}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2021},
  doi = {10.1109/cvpr46437.2021.00924},
}
Figure