Learning Based Image Synthesis (16-726)

Assignment 2

Aviral Agrawal (avirala)

1. Overview

This project delves into the realm of gradient-domain processing that has been employed in applications such as image editing, computer graphics, and computer vision.

Snow
Fig1. Source image
Forest
Fig2. Target image
Forest
Fig3. Naively cut and paste source in target
From the Figures 1, 2, 3 we see that simply cropping out a region of interest and pasting it into a background isn't quite appealing and would produce rather pronounced seams. To deal with this issue, we manipulate the gradients of pixels within an image rather than directly manipulating the pixel values themselves. This approach allows for more nuanced and visually appealing results.

Blending images can be achieved by a gradient-domain processing algorithm known as "Poisson blending." This technique involves seamlessly merging an object or texture from one image into another by considering the gradients of both images and minimizing the differences between them.

2. Toy Problem

We see, with the help of a toy example figure below, how we can reconstruct an image from its gradients. We have selected the first pixel value as the boundary condition in order to reconstruct the image.
Snow
Fig4. Source image
Forest
Fig5. Reconstructed image

3. Poisson Blending

We implement Poisson blending to seamlessly merge an object or texture from a source image to a target image. The Poisson blending algorithm involves solving a linear system of equations to minimize the differences between the gradients of the source and target images. The algorithm can be summarized as follows:
The linear system of equations can be formulated as follows: $$ v = \arg\min_v \sum_{i \in S, j \in N_i \cap S} \left( (v_i - v_j) - (s_i - s_j) \right)^2 + \sum_{i \in S, j \in N_i \cap \neg S} \left( (v_i - t_j) - (s_i - s_j) \right)^2 $$
While selecting the images for Poisson blending, we try to select images that have similar backgrounds since that results in similar gradients and hence, a more visually appealing Poisson blending result.
We shall now see the results of Poisson blending on a few images.
Snow
Fig6. Source image
Forest
Fig7. Target image
Forest
Fig8. Naively blended image
Forest
Fig9. Poisson blended image
Snow
Fig10. Source image
Forest
Fig11. Target image
Forest
Fig12. Naively blended image
Forest
Fig13. Poisson blended image
Snow
Fig14. Source image
Forest
Fig15. Target image
Forest
Fig16. Naively blended image
Forest
Fig17. Poisson blended image
Snow
Fig18. Source image
Forest
Fig19. Target image
Forest
Fig20. Naively blended image
Forest
Fig21. Poisson blended image
FAILURE CASE
We see that the Poisson blending algorithm is not without its limitations. The algorithm can produce visually unappealing results when the source and target images have significant differences in their gradients. In the example below, the source image (halloween pumpkin) has a very different gradient compared to the target image (Oberoi hotel). Thus, when solving for the Poisson blending linear system, the boundary conditions and the gradient constrainsts lead to a changed color of the blended region.
Snow
Fig22. Source image
Forest
Fig23. Target image
Forest
Fig24. Naively blended image
Forest
Fig25. Poisson blended image

4. Bells & Whistles : Mixed Gradient Blending

A minor change to the Poisson blending algorithm is called the mixed gradients approach, wherein we blend the source and target image by considering the maximum of the source of target gradients. In the following example we can see that Poisson blending produces a blur boundary around the blended region while with the use of mixed gradients we can overcome this limitation.
Snow
Fig26. Source image
Forest
Fig27. Target image
Forest
Fig28. Naively blended image
Forest
Fig29. Poisson blended image
Forest
Fig30. Mixed gradient blended image

5. Bells & Whistles : Color2Gray

We shall now explore the use of mixed gradients to efficiently convert color images to grayscale without losing contrast information.
Snow
Fig31. Source image
Forest
Fig32. Naively grayscale converted image
Forest
Fig33. Grayscale conversion using Mixed gradient image