16-726 Learning-Based Image Synthesis

Project 2: Gradient Domain Fusion

Chang Shi


Overview

This project explores gradient-domain processing, a simple technique with a broad set of applications including blending, tone-mapping, and non-photorealistic rendering. For the core project, we will focus on using “Poisson blending” to seamlessly blend an object or texture from a source image into a target image. Comparing with the simplest method that just copies and pastes the pixels from one image directly into the other, Possion Blending maximally preserves the gradient of the source region (instead of absolute intensity value) without changing any of the background pixels, while reaching good blending performance on the edges. Check out the Perez et al. 2003 paper to see sample results, or to wallow in extraneous math.

Method

    For Poisson blending, the working pipeline is as below:
  1. Select source and target regions. Select the boundaries of a region in the source image and specify a location in the target image where it should be blended. Then, transform (e.g., translate) the source image so that indices of pixels in the source and target regions correspond. We've provided starter code that will help with this. You may want to augment the code to allow rotation or resizing into the target region. You can be a bit sloppy about selecting the source region - just make sure that the entire object is contained. Ideally, the background of the object in the source region and the surrounding area of the target region will be of similar color.
  2. Solve the blending constraints: $\boldsymbol{v}=\operatorname{argmin}_{\boldsymbol{v}} \sum_{i \in S, j \in N_{i} \cap S}\left(\left(v_{i}-v_{j}\right)-\left(s_{i}-s_{j}\right)\right)^{2}+\sum_{i \in S, j \in N_{i} \cap \neg S}\left(\left(v_{i}-t_{j}\right)-\left(s_{i}-s_{j}\right)\right)^{2}$ by treating this optimization as a least squares problem. The length of the variable vector remaining to be solved is $N$, which is the number of pixels in the source region.
  3. Copy the solved values $\mathrm{v}_{i}$ into the target image, the pixels outside the source region will keep the original value of the target image. For RGB images, I process each channel separately.
Bells & Whistles: Mixed gradient. Follow the same steps as Poisson blending, but use the gradient in source or target with the larger magnitude as the guide, rather than the source gradient: $\boldsymbol{v}=\operatorname{argmin}_{v} \sum_{i \in S, j \in N_{i} \cap S}\left(\left(v_{i}-v_{j}\right)-d_{i j}\right)^{2}+\sum_{i \in S, j \in N_{i} \cap \neg S}\left(\left(v_{i}-t_{j}\right)-d_{i j}\right)^{2}$. Here ${ }^{u} d_{i j}{ }^{n}$ is the value of the gradient from the source or the target image with larger magnitude, i.e.

Results

My favorite blending result

The images below show the results from Poisson blending and mixde gradients blending.b As we can see comparing to direct copy-paste, Poisson blending makes the edge surreounding the bear have the same color tone as the background instead of pure white, however the blending is far from perfect. The mixed gradient blending is able to mix more detailed background information to the edges of the source patch, however it also brings some blending to the inside of the bear, making the bear a bit "transparent". This is a problem need to fix probably by better tuning the combination coefficient between source image gradient and target image gradient.





Source
Target
Result
Source
Target
Result




More Poisson Blending results on peronal images

The dog example seems to not work very well, with some weird halo appeared on the dog boy. This may due to the reason that the fur color is kind of even over the entir dog and also similar to the snow color, makes the gradients not working so well.





Source
Target
Result
Source
Target
Result