CS129 / Project 2 / Image Blending

Seamless representation of President Obama's

head on President Bush's body.

Motivation

We want to seamlessly blend an object from a source image into a target image. In the example on the right, the target image is President Bush's presidential portrait while the source is President Obama's presidential portrait. We can do this naively by simply copying and pasting one head onto the other's body or we can implement the image blending algorithm.

Algorithm

For pixels that are not in the mask, the result pixels are simply the target pixels at that location. For the pixels that are in the mask however, I take the source image and apply a laplacian filter to blend the gradients. I do this by constructing a large matrix A which is of size number of pixels by number of pixels. I look at all the neighboring pixels and apply the laplacian.

Results

Below are my results. In the first column is the target image. The second column is the mask. The third image is the source. The fourth image is the naively generated image (copy-paste). The fifth image is the result with the algorithm. You can see on the 6th row (the one with the rainbow), the algorithm does not work that well. The rainbow is blended onto the background when in reality it should not appear on top of the palm tree that way.