Project 2: Image Blending
Tristan Hale (thale)
Overview
The goal of this project was to blend an image into another image seamlessly using Poisson equation solving.
Algorithm
I implemented the algorithm from the paper Poisson Image Editing by Pérez, et al. The method is to set up a system of equations that will allow us to solve for the pixel values of the resulting image. More specifically, each pixel in the resulting image must solve the equation:
If the pixel is not masked,
else
where,
P is the pixel in the final resulting image
N is the set of neighboring pixels and n is the size of N
Target and Source are the target and source images
is the set of pixels that are masked
My program runs through each pixel, setting up an
sparse matrix A of coefficients and an
length vector b of values. After computing x = A\b, we reshape x back into the shape of the target image to get the new image.
Results
The results were generally good. I implemented the standard algorithm as well as the extra credit transparent version. As you can see in the following resulting images, the transparent version works better in many cases, although the face picture was pretty messed up by this method, since the resulting image has elements from both faces.
without transparency
|
with transparency
|
|
|
|
|
|
|
|
|
|
|
Here are some more results using my own images. The transparency is generally worse in these pictures, because they require a part of the target picture being overwritten, like a face.
without transparency
|
with transparency
|
|
|
|
|
|
|
|
|
|
|