Abstract
Image composition—the integration of a foreground object into a new background—is a fundamental task in photo editing. However, lighting and environmental discrepancies often result in a "fake" appearance. This paper introduces a novel image harmonization framework based on Denoising Diffusion Probabilistic Models (DDPM) and Latent Diffusion Models (LDM). By combining a non-parametric appearance consistency discriminator with selective color transfer, the proposed method achieves high-fidelity results that blend foreground objects into backgrounds more realistically than traditional deterministic approaches.
Introduction
Image harmonization aims to adjust a foreground object's appearance to match its new background while preserving its original structure and identity. Traditional deep learning approaches, such as CNNs and Transformers, often struggle with complex lighting or produce blurry outputs because they are optimized for pixel-wise differences (MSE) rather than overall realism. This research explores the potential of generative diffusion models to overcome these limitations by modeling the distribution of realistic images.
Methodology
The framework explores two variants of conditional diffusion models:
- Denoising Diffusion Probabilistic Models (DDPM): Trained end-to-end to map unharmonized images to harmonized versions.
- Latent Diffusion Models (LDM): Utilizing a pre-trained Stable Diffusion model fine-tuned via ControlNet. This approach leverages the massive prior knowledge of natural images inherent in large-scale models while remaining computationally efficient.
Appearance Consistency and Detail Preservation
A significant challenge in using generative models for editing is "hallucination," where the model alters the object's texture or shape. To mitigate this, the authors introduce two key components:
- Appearance Consistency Discriminator: A non-parametric method that converts images to grayscale to isolate structure from color, guiding the diffusion process to maintain structural integrity.
- Selective Color Transfer: A post-processing step in the HSV/HSL color space. By replacing the generated image's lightness channel with a version derived from the original composite, the model ensures that fine details are not lost.
Key Insights
Distribution vs. Pixel-Matching
Unlike traditional models that minimize Mean Squared Error (MSE), diffusion models attempt to match the distribution of realistic images. This shift allows for results that appear more "correct" to human observers, even if they deviate slightly from a single ground-truth pixel value.
Stochasticity as a Feature
Diffusion models are inherently probabilistic. This allows the system to generate multiple diverse harmonization options for a single input, enabling users to choose the lighting direction or tone that best fits their creative vision.
Results and Evaluation
The models were evaluated on the iHarmony4 dataset (HCOCO, HAdobe5k, HFlickr, and Hday2night), comprising over 65,000 training samples.
- Quantitative Performance: The method achieved competitive results, reaching a PSNR of 34.33 on the HCOCO dataset, performing on par with state-of-the-art models like DoveNet and S²AM.
- Qualitative Performance: Visual comparisons demonstrate superior object integration, particularly in rendering textures and aligning foreground brightness with the background. The selective color transfer method was specifically noted for its ability to recover fine details that standard LDMs typically obscure.
Conclusion and Future Work
While diffusion models offer a significant leap in visual realism, they face challenges with standard metrics like MSE, which may penalize realistic but non-identical lighting setups. Future work will focus on addressing the computational speed of diffusion models for real-time applications and tackling the even more diverse lighting conditions found in unconstrained real-world composites.
Summary updated