Foreground Harmonization and Shadow Generation for Composite Image

Jing Zhou, Ziqi Yu, Zhongyun Bao, Gang Fu, Weilei He, Chao Liang, Chunxia XiaoACM Multimedia 2024

TL;DR

This paper introduces a novel diffusion model-based approach for simultaneously harmonizing foreground object lighting and generating realistic cast shadows in composite images. To address the limitations of existing datasets, they also present IH-SG, a new outdoor dataset specifically designed for this dual task.

What Problem Does This Paper Address?

Creating realistic composite images often involves more than just seamlessly blending objects. A key challenge is ensuring visual consistency in lighting and shadows between the foreground object and the background. Existing methods tend to focus on either image harmonization (adjusting colors and brightness) or shadow generation, but rarely both effectively. Furthermore, lighting significantly influences both the appearance of an object and the shadows it casts, making a unified approach crucial for true realism. The authors highlight that current datasets are often insufficient for training models that can handle both aspects simultaneously, especially in diverse outdoor environments.

Methods

The proposed method leverages the power of diffusion models, known for their strong generative capabilities and iterative denoising properties. The core idea is to use a conditional diffusion model guided by both the composite image and a coarse shadow prediction.

Here's a breakdown of their approach:

  • Coarse Shadow Prediction Module (SP): This module acts as a precursor to the main diffusion process. It takes the composite image and a foreground object mask as input. It employs an encoder-decoder architecture with attention mechanisms to extract relevant background information and predict a coarse shadow mask. This module is designed to identify key areas in the background that influence shadow formation.
  • Channel-Spatial Cross-Attention Module (CSCA): Integrated within the SP and the main diffusion model, this module helps the model focus on relevant illumination information from the background. It establishes relationships between foreground and background features to guide more accurate shadow generation.
  • Harmony Diffusion Model: This is the main generative component. It takes the composite image and the predicted coarse shadow as conditional inputs. The diffusion model then iteratively denoises a random noise image, guided by these conditions, to produce a harmonized foreground object with realistic cast shadows. The primary goal here is to learn lighting variations to harmonize the foreground and generate high-quality, detailed shadows.

Datasets

  • IH-SG Dataset: The authors introduce a new, large-scale, real-world outdoor dataset called IH-SG. This dataset is specifically constructed to support both image harmonization and shadow generation tasks. It includes composite images, real images, foreground object masks, foreground shadow masks, background object masks, and background shadow masks. The dataset was created by relighting foreground objects and compositing them with background images.
  • Benchmark Datasets: The method was also evaluated on existing benchmark datasets, including iHarmony4, DESOBAv2, and ShadowAR, to demonstrate its generalizability.

Key Insights and Ideas

  • Unified Approach is Key: The paper strongly advocates for tackling image harmonization and shadow generation as a single, integrated problem, as lighting affects both aspects simultaneously.
  • Diffusion Models for Control: Diffusion models, with their iterative nature, are well-suited for tasks requiring fine-grained control and detail generation, making them a good choice for producing realistic shadows and harmonized lighting.
  • Coarse Shadow as Prior: Using a coarse shadow prediction as a prior for the diffusion model significantly aids in generating more accurate and detailed shadows, rather than relying solely on the diffusion process from scratch.
  • Importance of Context: The CSCA module highlights the importance of leveraging background context (illumination, object relationships) to accurately predict foreground shadows and harmonize lighting.
  • Outdoor Realism: The creation of the IH-SG dataset addresses a critical gap in existing benchmarks, which often lack sufficient diversity and realism for outdoor scenarios.

Key Results

  • Quantitative Improvements: The proposed method achieved state-of-the-art results on the IH-SG dataset, outperforming existing methods in RMSE, SSIM, MSE, and fSSIM metrics. For instance, their RMSE was 5.248, significantly lower than the next best at 6.108.
  • Qualitative Superiority: Visual comparisons demonstrate that the method produces more realistic and harmonized foregrounds with accurate cast shadows, effectively bridging lighting gaps between foreground and background.
  • Ablation Study Success: Ablation studies confirmed the effectiveness of each component: the image condition (y), the coarse shadow prediction module (SP), and the channel-spatial cross-attention module (CSCA) all contributed significantly to the overall performance. Removing these components led to noticeable degradation in results.

Limitations and Future Work

  • Non-Planar Shadows: The authors acknowledge that their method struggles with generating non-planar cast shadows. This is attributed to the need for more detailed information about object geometry and environmental depth, as well as potential issues with mutual object occlusion.
  • Future Work: The primary direction for future work is to address the generation of non-planar shadows, which would require incorporating more sophisticated geometric reasoning or scene understanding.

Summary updated

BibTeX
@inproceedings{zhou2024foreground,
  author = {Jing Zhou and Ziqi Yu and Zhongyun Bao and Gang Fu and Weilei He and Chao Liang and Chunxia Xiao},
  title = {{Foreground Harmonization and Shadow Generation for Composite Image}},
  booktitle = {ACM Multimedia},
  year = {2024},
  url = {https://openreview.net/forum?id=FxcoztYv98},
}
Figure