Part 2

Project Description

In part 2 of the project, we turn our attention to a different blending technique from multiresolution blending. In multiresolution blending we utilize the Laplacian pyramid blending technique; however, in this part we take advantage of the fact that humans tend to notice edges more than just simply colors. One way we could blending two photos to simply put one cut out of a photo on top of another. Unfortunately, that would make the difference between the two photos too obvious because of the seam or edge that is formed between the images. One way to overcome this while still keeping the integrities of the two photos is to preserve the gradients of the source images while keeping the background or target pixels the same. We keep the gradient of the source image by computing the difference (which is essentially like calculating the derivative) between a pixel and its four neighbors.

2.1 Toy Problem

In order from left to right: Original, Output, Failure





2.2 Poisson Blending (Bells and Whistles!)

Sources and Targets

Ironman Group Photo (with blend!)




Ball is Life




Goat Lebron

Results!

Ironman Group Photo

Ball is Life (Compare to Multiresolution Blend)

Goat Lebron (Bells and Whistles)






How it works...

I first used the Matlab starter code to create the appropriate masks for the source so that I could blend it with the target. Afterwards, I set up a least squares problem to find the best blend that will incorporate the colors of the target but keep the gradient of the source. As explained above, I get the neighbors of each pixel and calculate the gradient of the source except for the bells and whistles, where I sometimes get the gradient of the target depending on which has more contrast. I set up the A matrix to get the correct values from our value matrix which we are solving for. I do this for all red, green, and blue color scales and then put all three together to get a complet color image. I then solve the least squares problem with sparse matrices to speed up the runtime - this greatly increased the performance of the algorithm. I also used 'spsolve' instead of 'lsqr', because it does not solve iteratively which speeds up the process as well. At the very, end after I get all three color channels, I also normalize so that the colors are within the range [-1, 1] and no excess weird colors are shown.






Failures...

No division by 255.

No normalizing

Wrong population of b

Failures Explained

The first failure was caused by not dividing the images by 255. By dividing by 255., I make the images in a scale within [-1, 1] making it easier to compute and deal with in terms of color.

The next failure was caused by not normalizing. Without normalization weird colors show because the matrix values are not in the range of [-1, 1].

The last failure was caused by not populating my b matrix correctly, aka the gradients of our source image. I accidentally included target pixels in this gradient calculation giving weird colors and combinations.

Laplacian Pyramid vs. Poisson
(In Order)

Laplacian Explained

In general, Laplacian seems to be better for wider, smoother blending; however, Poisson seems to be better for when you want to seemlessly incorporate an image into the middle of another. Only this is for Poisson blending the surround colors of the source must be similar to its surround target or else the blending is too obvious - this is similar to Laplacian blending but Laplacian blending is better fit for longer transitions. So for this particular example, Laplacian was better for the smooth transitioning, but if the colors were similar in the surrounding than Poisson would have been better.