CS 194-26 Final Project: Gradient Domain Fushion

The human eye is often more perceptive to representations of objects in the gradient domain than the spatial domain. As a result, gradient domain processing can be used for techniques like blending two images together. This project explores one such technique: "Poisson blending."

The main idea behind "Poisson blending," which is detailed in the Perez et al. 2003 paper, involves taking the gradient domain representation of a source image and inserting into the background of a target image while keeping boundaries smooth.

Toy Problem

In the simple case, where the relative intensities of the backgrounds of the source and target image are the same, the Poisson blend can be solved analytically by adding a constant RGB value to each pixel in the source image and pasting it into the appropriate window in the target image. However, because this is generally not the case, a least-squares approach is necessary.

We begin by testing our approach on a toy example, where no resizing occurs, where the source and target image are the same, and where the only extra constraint present is to have the top left pixels of both images match. Building the appropriate matrices for this problem, finding the least squares solution, and reshaping it into an output image, we get the following results:

toy problem

This is the image of the toy problem.

toy solution

This is image that results when the toy problem is blended with itself.

Poisson Blending

Confident with the solution to the toy problem, I proceeded to implement Poisson Blending in its full glory. This involved setting up a least squares problem with the following constraints:

Applying these constraints to images in the sample folder, I obtained the following results:

im2

The resized im2

im3

The resized im3

penguin

The resized penguin

penguin chick

The resized penguin chick

im2 penguin blend

im2 penguin blend

im2 penguin chick blend

im2 penguin chick blend

im3 penguin blend

im3 penguin blend

im3 penguin chick blend

im3 penguin chick blend

im2 penguin family

im2 penguin family

im3 penguin family

im3 penguin family

What I Learned

I learned that gradient domain image processing is more complex than just copying the gradients of the source image and pasting it into the target image. I also learned that in some cases, it is okay to loop over pixels, as long as the window size is sufficiently small as to not significantly hamper runtime.