Introduction
The goal of this project is to blend two pictures as seamlessly as possible.
Poisson Blending
Since human perception is more sensitive to the gradient of an image, the goal then becomes to minimize the gradient difference in the target image. To simplify things, a discrete formula is used to describe the problem:

where M is the mask, i is a pixel, N_i is the four neighbors of i.
If we iterate through the summation and simplify things a bit by combining equations for one pixel, we get MxM equations, and they can be transformed into a matrix form:

where A is the coefficient matrix, b is a vector derived from both acutal intensity values (for pixels outside mask) and the gradient values (for pixels inside the mask).
Solving for v, we get the output image. Here are some results:
cut and paste |
poisson blending |
 |
 |
More ImagesFewer Images
Mixed Gradient
The rainbow picture in the result of Poisson Blending is not very good. Mixed Gradient can be used to give the rainbow some transparency. This is done by modifying the possion equation above slightly: instead of using source gradient, we choose the larger one between the source and target gradient. We still need to iterate through the four neighbors of a pixel to see which gradient is larger.
Poisson Blending |
Mixed Gradient |
 |
 |
 |
 |
 |
 |
Source |
Target |
Poisson Blending |
Mixed Gradient |
All Photos
Most of the time, Poisson blending works well. Here is a comparison of poisson blending and mixed gradient.
Source |
Target |
Poisson Blending |
Mixed Gradient |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |