CS194 Project 3: Fun with Frequencies and Gradients!

Part 1.1

I sharpened the image by adding the original image to the high pass filtered image, which is derived by subtracting the gaussisan filtered image from the original image.

Part 1.2

I take the high pass filter of one image by subtracting the gaussian filtered image from the original. Then I take a low pass filter on the other image using a gaussian filter. I then add the pictures. I think the combination of my dog and I failed because we don't have similar features and the picture of my dog is brighter in general and has less high frequencies than the picture of me, though I intended for my dog's picture to be the high frequency one.

Fourier Analysis for Leo

Part 1.3

I constructed the gaussian stack by starting with applying a gaussian filter on the original image with sigma of 2 then multiplying the sigma by 2 for the next level in the stack, so I ended up using 2, 4, 8, 16, 32 sigmas for my gaussian filters. I constructed the laplacian stack subtracting the next level of the gaussian stack from the current level of the gaussian stack.

Gaussian and Laplacian for Leo

Part 1.4

For each color channel, I would compute the Laplacian stacks for the two images and combine them at each level using the mask. For level i, I would get gaussian(mask(i)) * laplacian(a(i)) + (1 - gaussian(mask(i))) * laplacian(b(i)). Then the combinations are summed, with the combined gaussian of the bottom of their gaussian stacks to get the blended images.

Combination of Japan and SF using the shown mask

Laplacian stack of combinations

Part 2.1

In this part of the project, we use the gradients of images to recover a desired image. We do this by constructing a sparse matrix representing the system of linear equations we are trying to solve to get every pixel and use least squares regression to get the result.

Toy Result

I created a height * width * 2 + 1 by height * width matrix with an equation in each row. There would be height * width equations for the x gradient for each pixel and height * width equations for the y gradient for each pixel, and then one equation for the corner pixel used as pixel intensity reference.

Part 2.2

I created a matrix with height * width equations for each pixel. The row would have just a 1 (on the diagonal) if it was part of the target background and the original value in the corresponding b vector index, or have 4 (on the diagonal) and -1 for all indices corresponding with that pixel's neighbors. Then the corresponding b vector index would have the sum of the gradients from the source image. Using this sparse matrix, I would run least squares regression to retrieve an optimal resulting image. I converted my matrix to a CSR matrix before running the solver for a speed optimization.

I thought my dragon in space result was somewhat of a failure, since the background of the dragon picture was smooth but the background of the space picture is speckled with stars so if you look closely, there's a starless border surrounding the dragon.

Compare Laplacian vs. Poisson

I think the poisson works better for these images because it captures the original lighting from the target photo and applies it to the source photo, making it look more natural. Thus, I think this method is better when you have images from different environments and want the source image to not stand out.

Original

Laplacian and Poisson