Abstract
The purpose of image composition is to combine the visual elements of different natural images to produce a natural image. The performance of most existing image composition methods drops significantly when they solve multiple issues, such as image harmonization, image blending, shadow generation, object placement, and spatial transformation. To address this problem, we propose a multitask GAN for image compositing based on spatial features, aiming to simultaneously address the geometric and appearance inconsistency. We use three related learning objective functions to train the network. Moreover, a new dataset including 7756 images with RoI region annotations is contributed to help evaluate the multitask image compositing results. Extensive experiments demonstrate that our proposed method is effective on our dataset.
Introduction
Image composition—the process of taking an object from a source image and placing it into a target background—is a fundamental task in computer vision. However, creating realistic composites is deceptively difficult. Most existing methods struggle because they treat the problem in isolation: focusing either on geometric consistency (ensuring the object is correctly sized and positioned) or appearance consistency (matching lighting, color, and shadows).
When these issues are not addressed holistically, the resulting image often appears artificial. Furthermore, the field has lacked high-quality datasets providing "ground truth" references—real photos of the same scene with and without the object—to facilitate effective training. MT-GAN addresses these gaps by introducing a multitask framework and a large-scale indoor dataset with ground-truth annotations.
Methodology
The proposed MT-GAN framework addresses these challenges through a three-part pipeline designed to handle both spatial and appearance features simultaneously.
1. Geometric Consistency Network (GCN)
The GCN utilizes a Spatial Transformer Network (STN) to automatically resize and reposition the source object ($I_s$). This ensures the object fits naturally within the perspective and layout of the target scene ($I_t$), resulting in a geometrically aligned source image ($I'_s$).
2. Spatial Feature Extraction Network (SFEN)
To improve efficiency and focus, the SFEN compresses the target background from three color channels into a single spatial feature channel ($I'_t$). This lightweight approach forces the generative backbone to prioritize the foreground object while maintaining an understanding of the background's spatial layout. This channel reduction significantly speeds up training and improves the "focus" of the generator.
3. MT-GAN Backbone
The core of the system is an encoder-transformer-decoder architecture. This generative adversarial network produces the final composite image ($I_{com}$) along with a mask ($M$) that facilitates seamless blending between the new object and the original background.
Learning Objectives
The model is trained using a "triple threat" of loss functions to ensure both global and local realism:
- Adversarial Loss ($L_A$): Drives the overall realism of the generated image.
- Compositing Loss ($L_C$): Measures global accuracy against the ground truth.
- Region of Interest (RoI) Consistency Loss ($L_R$): Specifically penalizes errors in the area where the object and its shadows are located, ensuring local realism.
The SHU Multitask Dataset
A significant contribution of this work is the SHU multitask image composition dataset, currently the largest of its kind. It contains 7,756 total images of indoor scenes featuring tables, chairs, and sofas with various cups as source objects. Crucially, the dataset provides paired images—one with the object (ground truth) and one without (target background)—captured under controlled lighting conditions. This allows the model to learn exactly where a shadow should fall and how the color should shift.
Results and Discussion
MT-GAN outperformed several established baselines, including ST-GAN and DoveNet, across multiple metrics on the SHU dataset.
Quantitative Performance
The model achieved a Mean Square Error (MSE) of 82.30 and a Peak Signal-to-Noise Ratio (PSNR) of 29.51. Furthermore, using a VGG-based classifier to distinguish real from fake images, MT-GAN achieved a realism score of 0.954, significantly higher than arbitrary composition methods which scored a mere 0.15.
Qualitative Analysis
Qualitative results demonstrate the model's ability to generate realistic shadows and even complex interactions like reflections on polished surfaces. By solving for position and appearance simultaneously, the network produces more plausible results than modular approaches. One of the most impressive outcomes was seeing the network learn to generate reflections on shiny surfaces without being explicitly programmed to do so.
Conclusion
MT-GAN demonstrates that a multitask approach to image composition—addressing geometry and appearance in tandem—yields superior results. While the model is currently trained against a single ground-truth reference, future work may explore handling the inherent subjectivity of "reasonable" placement and expanding the dataset to include more diverse objects and complex outdoor environments.
Summary updated