Project 3: Fun with Frequencies and Gradients!

CS 194-26: Image Manipulation and Computational Photography, Fall 2018

Marisa Wong


Overview

The purpose of this project is to explore different methods of blending images together.


Part 1.1: Warmup

I applied a Laplacian filter on the original image using a kernel of size 21 and sigma 5 in order to obtain the high frequency details of the image. Next I multiplied the Laplacian image with a chosen alpha value and added the result to the original image. This yielded a sharpened version of the image.

Original
alpha = 0.50
alpha = 1.00
Original
alpha = 0.50
alpha = 1.00
Part 1.2 Hybrid Images
A hybrid image is one that consists of two images overlayed on top of each other where one image has its high frequency details preserved while the toher imge has its low frequency details preserved. First I used the provided code to align two images, usually picking the eyes as the two points to align against. In order to get the low frequences of an image, I applied a Gaussian filter on the chosen image. In order to get the high frequencies of an image, I subtracted the Gaussian filter from the original image. Next we just add the two images up to obtain the hybrid image.
Original Image 1
Original Image 2
Low Pass Filtered Image 1, Sigma = 30
High Pass Filtered Image 2, Sigma = 150
Hybrid Image
FFT Analysis
FFT of Original Image 1
FFT of Original Image 2
FFT of Low Pass Image 1
FFT of High Pass Image 2
FFT of Hybrid Image
Bells and Whistles: Using Colors
Derek in Color
Nutmeg in Color
Derek and Nutmeg in Color

More Hybrid Images

Original Image 1 Sigma = 20
Original Image 2 Sigma = 50
Black and White Hybrid

Here is one failure case. It is very difficult to see Michelle Obama's face.

Sigma = 5
Sigma = 10
Part 1.3 Gaussian and Laplacian Stacks

To create Gaussian stacks, I applied the Gaussian filter on the image repeatedly while increasing the sigma value by a factor of two. To create the Laplacian stacks, I applied the Gaussian filter on the image and subtracted it from the previous image while increasing the sigma value by a factor of two. For both Gaussian and Laplacian stacks I started with a sigma value of 1. The pictures below show stacks with sigma equal to 1, 2, 4, 8, 16, and 32. We see that as we increase the sigma for the Gaussian stack, the Lincoln Dali image gts very blurry. Interestingly, as we increase the sigma for the Laplacian stack, it gets easier to see the Lincoln Dali image since we are getting more of the high frequency details.

Original Image
Sigma = 1
Sigma = 2
Sigma = 4
Sigma = 8
Sigma = 16
Sigma = 32
Original Image
Sigma = 1
Sigma = 2
Sigma = 4
Sigma = 8
Sigma = 16
Sigma = 32
Part 1.3 Multiresolution Blending

Multiresolution blending uses splines to help blend two images together without there being a sharp seam between the two combined images. Given two images, we create Laplacian stacks of them (LA, LB). Next we create a mask and create a Gaussian stack for it (GM). For each level of the stacks, we assemble a combined stack by doing the following: LA_i * GM_i + (1 - GM_i) * LB_i.

Apple
Orange
No Blend
Blended
Blended

Here are the Laplacian stacks for the apple and orange.

More Multiresolution Blends
Sun
Moon
No Blend
Blended

A blend with an irregular mask.

Marisa
Moon
Marisa on the Moon


Part 2.1 Toy Problem

Given a pixel and the gradient of the original toy image, we reconstruct the image using a system of equations. We create a sparse matrix A with dimensions ( * height * width + 1, height * width). Note that the number of rows we have in A represents the number of equations we are trying to solve for. The first half of matrix A corresponds with the x-gradient while the second half corresponds with the y-gradient. The last row of matrix A helps make sure that the top left corners of the two images are the same color. We multiply this matrix A to vector x which represents all the unknowns we are solving for - the mapping between a given pixel to the reconstructed image. So we now have Ax = b. The vector b with dimensino (2 * height * width + 1, 1) represents the result of the gradient equations in matrix b.

Goal Image to Recover
Recovered Image

Part 2.2 Poisson Blending

In Poisson Blending we look at the gradient of an image and attempt to find values for the target image that maximally preserve the gradient of the source image without changing any of the background image. For each pixel i outside the masked region, the output image pixel is the same pixel as the target image. For each pixel i inside the masked region, the output image pixel depends on its left, right, above, and below neighbors. We construct a sparse matrix A (# target rows * # target cols, # target rows * # target cols) and a vector b (# target rows * # target cols, 3 RGB). We can plug this into a least squares solver to obtain the solution that encodes the correct pixel value from source to target image.

Source
Target
Mask
No Blend
Poisson Blend

Laplacian Pyramid Blending vs Poisson Blending

What I Learned from this Project
Most important thing I learned was to start earlier for the next projects.