CS194-26 Project 3: Alexander Ros

Part 1.1: Sharpening

Using a Gaussian filter, we find the low pass frequencies from the original image with a sigma = 2. When we subtract the original image with the low pass image, we get a high pass image. Adding this high pass image to the original image returns a sharpened image.


Original image


Sharpened image

Part 1.2: Hybrid Images

We blend two images into a single hybrid image. We do this by taking the high frequencies of one image and adding it to the low frequencies of a second image (We get the high pass frequencies much like how we did in part 1.1). This results in an image where you can see the low frequencies from afar, but when viewed up close you can see the high frequencies. Here's an example with Ronald McDonald and Michael Jackson, where I used sigma values 3 and 2

From left to right: FFT of Ronald McDonald, FFT of Michael Jackson, FFT of the lowpass filtered Ronald McDonald, FFT of the highpass filtered Michael Jackson, FFT of hybrid image

More examples!

From afar you see a pitbull, but close up you see...worldwide music superstar Pitbull?!

Derek and his cat Nutmeg. This one was a failure, as the higher frequency area is a little too subtle. Tuning the sigma values may result in a better image.

Part 1.3: Gaussian and Laplacian Stack

We created a Gaussian stack by applying a Gaussian filter repeatedly, increasing the sigma by a factor of 2. I started with a sigma value of 2 and made 5 layers for the stack, resulting in 5 images of sigma 2, 4, 8, 16, and 32

Next, we create a Laplacian stack by subtracting the Gaussian image with the previous Gaussian image

Part 1.4: Multiresolution Blending

To achieve these affects in multiresolution blending, we create two Laplacian stacks for two images we want to blend togethera nd a Gaussian stack for a mask where the blending will occur. We then create a new stack by adding a layer from both Laplacian stacks weighted by a layer from the Gaussian stacks together. When we flatten the new stack into an image, we will get a blended image.

From left to right: a wiener dog, a hotdog, our mask, and the final result

Obama in 2008 vs Obama in 2018

Part 2.1: Toy Image

In this part we were tasked to reconstruct an image by using the x and y gradients. To do this, we created a sparse matrix A and a vector b with 2xWxH+1 constraints (WxH constraints for the pixel values of the x gradient, W*X constraints for the pixels in the y gradient, and 1 constraint for the top left corner of the image). Then we solved for x using a least squares solver.

Part 2.2: Poisson Blending

We used Poisson Blending to seamlessly blend an image (source) to another image (target). We do this by first aligning the source image with the target image using MATLAB starter code, and then we create a mask. Assuming the target image is width W and size H, we use a sparse matrix A of size (WxH, WxH). We populate the matrix by checking the pixels of the mask. If the pixel is in the masked area (the black area) then the variable's row in the A matrix would be 1, and the constraint will be equal the pixel of the target image. If it is in the unmasked region (the white area) then we must look at the upper, lower, left and right neighbors of the pixel, and the constraint will be a weighted difference between the pixel and its neighbors. We must do this three times separately for the red, green, and blue channels. Afterwards we stack the images to get the final result.

More Examples

Failed Example

In this image, I tried to imagine climatic the scene where Obi-Wan has the high ground on Anakin on a pizza. Unfortunately, the background image of the pizza was much too different from the background of Anakin and Obi-Wan from the lava planet of Mustafar. Also, the images of Anakin and Obi-wan may have been too low quality as I took them off a screenshot from YouTube.

Bells & Whistles: Mixed Gradients

The mixed gradients chooses between source and target pixels based on which has a higher absolute value. This can lead to better blending results for images that need transparency

Adding a rainbow with Poisson blending vs adding a rainbow with Poisson blending plus gradient mixing. Notice how in the left image you can slightly see through the rainbow