Assignment 2: Gradient Domain Fusion

Student name: Tianxiang Lin
Andrew ID: tianxian

Project Overview

This project aims at blending an object or texture into another background image seamlessly using Poisson Blending.

After selecting source and target regions to blend, the blend constraints are solved using the follwing formula:
v=arg minviS,jNiS((vivj)(sisj))2+iS,jNi¬S((vitj)(sisj))2.\mathit{v} = \argmin_{v}\sum_{i \in S, j \in N_i \cap S}((\mathit{v}_i-\mathit{v}_j)-(\mathit{s}_i-\mathit{s}_j))^2+\sum_{i \in S, j \in N_i \cap \neg S}((\mathit{v}_i-\mathit{t}_j)-(\mathit{s}_i-\mathit{s}_j))^2.
where v is the resulting blending region, t is the target image and s is the source image. Finally, the blending region is copied to the background image to complete the blending process.

Toy Problem

For the toy problem, three objective functions need to be satisfied:

  1. Minimize ((v(x+1,y)v(x,y))(s(x+1,y)s(x,y)))2(( v(x+1,y)-v(x,y)) - (s(x+1,y)-s(x,y)) )^2, so the x-gradients of v should closely match the x-gradients of s.
  2. Minimize ((v(x,y+1)v(x,y))(s(x,y+1)s(x,y)))2(( v(x,y+1)-v(x,y)) - (s(x,y+1)-s(x,y)) )^2, so the y-gradients of v should closely match the x-gradients of s.
  3. minimize (v(1,1)s(1,1))2(v(1,1)-s(1,1))^2.

The result is as follows:

Poisson Blending

As mentioned above, the objective function to blend the source and target images is:
v=arg minviS,jNiS((vivj)(sisj))2+iS,jNi¬S((vitj)(sisj))2.\mathit{v} = \argmin_{v}\sum_{i \in S, j \in N_i \cap S}((\mathit{v}_i-\mathit{v}_j)-(\mathit{s}_i-\mathit{s}_j))^2+\sum_{i \in S, j \in N_i \cap \neg S}((\mathit{v}_i-\mathit{t}_j)-(\mathit{s}_i-\mathit{s}_j))^2.

Notably, in order to avoid computing gradients twice, for each pixel in the source region, 4 gradients are added up to one row instead of seperated into 4 rows. This will save time for computations. The results are shown below.

Name Source Target Result
Bear
Statue
Plane

All results are perfect blended except for the third one. An obvious artifact in front of the plane is not eliminated. The reason for this is the texture of the sky does not match to the texture of mountain.