Image composition—the process of integrating an object from one source image into a new background—is a fundamental task in digital image editing. However, the realism of the composite is often compromised by illumination inconsistencies between the foreground and the background. Image harmonization aims to resolve these discrepancies by adjusting the foreground's appearance to match the lighting of the target environment.
Existing deep learning approaches for image harmonization frequently encounter two primary challenges. First, they often rely on local feature statistics, neglecting the global context necessary to determine appropriate lighting. Second, these models typically lack intermediate supervision, relying solely on the final ground-truth image for training, which can lead to suboptimal feature representations in the network's encoder.
To address these issues, we introduce GiftNet, a novel framework that utilizes Globally Guided Feature Transformation (GIFT) and Relation Distillation. Additionally, we present ccHarmony, a new dataset designed to simulate natural illumination variations more accurately using color-checker data.
Globally Guided Feature Transformation (GIFT)
Traditional methods often use local pixel data to adjust foreground features. In contrast, GiftNet extracts a "bottleneck feature" from the encoder that captures the global state of the entire composite image. This global feature is processed through a Multi-Layer Perceptron (MLP) to predict a scale vector. This vector then modulates the convolution kernels used to transform the foreground features. By allowing the "big picture" to guide the transformation filters, the network can more effectively "tweak" the foreground to fit the global lighting environment. Experiments indicate that applying GIFT within the decoder is particularly effective for high-quality reconstruction.
Relation Distillation
The "supervision gap" refers to the lack of specific guidance for internal layers during training. GiftNet addresses this through a teacher-student distillation framework:
- The Teacher: A reconstruction branch that learns to recreate a naturally harmonious image.
- The Student: The harmonization branch tasked with correcting the composite image.
Rather than forcing the student's raw features to match the teacher's—a method often prone to noise—GiftNet employs Relation Distillation. The model calculates a "similarity map" representing the relationship between the average foreground feature and every other pixel in the image. By matching these similarity maps, the student learns the structural and contextual relationships between the foreground and its surroundings, leading to more robust feature representations.
The ccHarmony Dataset
Current benchmarks like iHarmony4 often rely on "inverse" methods (e.g., artificially darkening a real image) to create training pairs. These methods may not fully capture the complexity of natural light. To provide a more realistic alternative, we developed ccHarmony. This dataset utilizes images containing color checkers. By applying polynomial matching to these color patches, we can realistically transfer the illumination from one scene to a foreground object from another. This process resulted in 3,080 high-quality training pairs that better reflect real-world lighting conditions.
Results and Evaluation
GiftNet achieves state-of-the-art performance on the standard iHarmony4 benchmark, showing a 10.61% relative improvement in foreground Mean Squared Error (fMSE) compared to previous leading models like CDTNet.
Qualitative evaluations further support these findings. In a user study involving 100 real composite images, GiftNet achieved a Bradley-Terry score of 0.436, significantly higher than competitors such as DCCF (0.235) and CDTNet (0.212). Visually, the model excels at preserving object "lustre" (e.g., on metallic surfaces) and accurately matching skin tones to the surrounding environment.
Conclusion
GiftNet represents a significant advancement in image harmonization by integrating global context and relational supervision. While the model shows exceptional performance under natural lighting, future work will focus on improving robustness in scenes with complex artificial light sources and expanding the scale of color-checker-based datasets.
Summary updated