Emma (Left)
Teddy (Right)
Emma-Teddy
Sky (Left)
Night (Right)
Sky Night
Problems Encountered
I originally made Lapalcian stacks by continually calling the Laplacian operator onto the image, but that resulted in blended images that were very harsh because the detail kept being enhanced each layer. This was solved by taking the Laplacian of different Gaussian smoothed layers. Here is an example of an overly detailed blended image vs the fixed blend image:
Part 2.1 Toy Gradient Domain Fushion
The toy problem involved turning an image into two components, a sparse matrix A and a vector b, to solve the least squared problem, which is equivalent to solving Ax=b for x. The components are calculated by finding the gradient along the x and the y seperately, noting pairs (x,y), (x+1, y) or (x, y+1) into rows for A, and the difference in the pixel value of pairs into a rows for b. Finally, in the toy example, the vector x that we solve for at the end should give us back our original image.
Note: A has dimensions (2*m*n+1, m*n), x has (m*n, 1), b has (2*m*n+1). And we convert x back to a (m, n) matrix to save the image
Original
Gradient Calculated
Problems Encountered
The biggest problem I encountered was figuring out a way to solve Ax=b for very large dimensions, since (2*m*n+1, m*n) was very large and hard to calculate quickly. Luckily I saw a piazza post recommending to use scipy.sparse.linalg.lsqr which worked very well for me, and ran the toy example in about two minutes.
Part 2.2 Poisson Blending Gradient Domain Fushion
This was an extension of the toy version to incoporate two pictures. It involved taking a selection of one picture and pasting it onto another, but making it so that the colors blend with one another. It also involves creating an equation for Ax=b. However, this time the rows of A are dependent on the Poisson neighbors, with each interior pixel as 4 and the neighbors as -1 inside the mask. Also based on the mask, we can calulate rows of b based on the source image, these together will blend the hues of the source image to match the target image.
Source
Target
Penguin Hiking
Source
Target
Penguin God
Problems Encountered:
Also, I had difficulty using the provided MATLAB, so my masks were generated by a very simple rectangular crop function. But, this made the images not seem too well integrated because the mask covered a lot of the source's background instead of taking the background of the target. This can be seen in the second image where the penguin in the sky still has flecks of snow instead of pure sky.
Also there was a problem when the images don't have similar backgrounds as seen in the Fruit Cat picture, because of the spotted background in the apple picture that doesn't go away with the gradients.