Assignment 2 Gradient Domain Fusion

Name : Divam Gupta

Andrew Id: divamg

Introduction

In this project the aim is to implement gradient based poison blending in order to paste a source image on top of a target background. The inputs to the system is a target image, a source image and a source mask. The purpose of the source mask to specify the pixels of interest. We assume that the source mask is a "loose" mask which loosely contains the source object.

The naive method of copying the pixels from the source image to the target image is a bad idea because there is inconsistency between the source pixels and the target pixels.

In the poison blending method, we ensure that the in the gradients of the new image v are same as the gradients as the old image s. At the boundaries we ensure that difference in pixels in new image v with target neighboring pixel is close to the source image difference.

We minimize the following:

1.1 Toy problem

The toy problem is for us to make sure that the least squares implementation is correct. Here we have to reconstruct an image using the pixel intensities at pixel (0,0) and the gradients at other pixels. Here the optimization objective is that the pixel value at 0,0 should be as close as possible and at all other locations gradient of x and y directions should be as closed as possible. If the implementation is correct, we should get back the input image :

After running our code we get:

We can see that input and output are the same.

1.2 Poison Blending

In the poison blending method, we ensure that the in the gradients of the new image v are same as the gradients as the old image s. At the boundaries we ensure that difference in pixels in new image v with target neighboring pixel is close to the source image difference.

We construct the matrices A and b and use scipis sparse least squares minimizer to get the minimum solution. We observe that the implementation works in most of the cases:

Example 1

Example 2

Example 3

Example 4

Example 5

We see that the results in example 5 are not very good. This is because of high difference in the source pixels and the target pixels. To make the gradients as close to possible, the optimizer assigns very low pixel intensities to the car object. This is an inherent problem in the approach of poison blending.

Bells & Whistles - Mixed Gradients:

we can implement mixed gradient approach by building on the poisson blending function. There is a very minor change, where we replace the source pixel difference with the target pixels difference if the absolute difference is greater.

Vanilla poison approach:

Mixed Gradient approach:

We can see that in this case the mixed gradients perform better than the vanilla poison blending approach.