Abstract
Image harmonization aims to adjust the foreground of a composite image to match the background's lighting and color. While deep learning models excel at local context, they struggle with high-resolution images due to computational costs. This paper introduces CDTNet, a framework that combines global color mapping via 3D Lookup Tables (LUTs) with local pixel-to-pixel transformations. This dual approach achieves state-of-the-art performance on 2K images while being significantly faster and more memory-efficient than previous deep learning models.
Introduction
Image composition—pasting a foreground object from one image into another—is a staple of photo editing. However, the foreground often looks "fake" because its lighting, color temperature, and saturation do not match the new background. Image harmonization aims to fix this by adjusting the foreground to look natural in its new context.
The challenge lies in resolution. Modern deep learning models are great at understanding local context (pixel-to-pixel transformation), but they are computationally "heavy." Running them on high-resolution images (like 2048x2048) requires massive amounts of GPU memory and processing power. Conversely, traditional methods used global color transformations (RGB-to-RGB) which are fast and resolution-independent but ignore local details, often leading to "inharmonious" results where specific parts of the object still look out of place.
Methods: The CDTNet Framework
The authors propose CDTNet, which uses a three-pronged approach to handle high-resolution data efficiently by combining local and global transformations.
- Low-Resolution Generator: A standard U-Net-style architecture (specifically iS2AM) processes a downsampled version of the image (e.g., 256x256). This captures the "local context"—how specific pixels should change based on their neighbors.
- Color Mapping Module: This is the "global" branch. It learns a set of 3D Lookup Tables (LUTs). Instead of processing every pixel through a heavy neural network, the model predicts a set of weights to combine these LUTs into an image-specific color transformation. This transformation is then applied to the full-resolution image. Because LUTs are simple math operations on color values, they scale to any resolution effortlessly.
- Refinement Module: This light-weighted module acts as a "fuser." It takes the high-res color-mapped result and the upsampled low-res result, along with features from the original encoder, to produce the final harmonized image. It essentially uses the low-res "intelligence" to fix any local errors made by the global color mapping.
Datasets and Evaluation
- HAdobe5k: A subset of the iHarmony4 benchmark. It is currently the only public dataset containing high-resolution (up to 1024px and beyond) composite images and their ground truths.
- High-Resolution Real Composites: The authors created a new evaluation set of 100 high-resolution real composite images (ranging from 1024 to 6016 pixels) using foregrounds from the Open Image Dataset V6 and backgrounds from Flickr to test the model's performance in real-world scenarios.
Key Results
- Performance: On 2048x2048 images, CDTNet outperformed the previous best model (iS2AM) across all metrics (MSE, PSNR, SSIM).
- Efficiency: CDTNet is a "lightweight" champion. Compared to iS2AM at 2K resolution, CDTNet-512 is ~63% faster (11.5ms vs 31.1ms inference time), ~63% more memory efficient (7.7GB vs 20.6GB), and has ~67% lower computational cost (312G vs 957G FLOPs).
- User Study: In a subjective test on real-world composites, humans preferred CDTNet's results significantly more often than those from pix2pixHD or iS2AM.
Conclusion and Future Work
CDTNet successfully bridges the gap between local pixel-to-pixel accuracy and global transformation efficiency. By leveraging learnable LUTs and a shared encoder, the model discovers complex color relationships while maintaining a low computational footprint.
The authors note that the model can still struggle with unrealistic local results in extreme cases, such as severely overexposed foregrounds. Future work could involve exploring more sophisticated refinement modules or incorporating semantic information to better handle these edge cases.
Summary updated