Fun With Frequencies & Gradients

CS 194-26 Computational Photography Fall 2018

Guowei Yang  cs194-26-acg 

For any computer image file, the image itself could be described in either frequency domain or gradient domain. In each domain, we could manipulate the image using different techniques, such as Laplacian Blending and Poisson Blending. In this project, we played around with the frequency and gradient of the input image, and managed to create some really stunning pictures. Let's dive right in.

Part 1: Frequency Domain

1.1 Image Sharpening

Original Image

Gaussian Layer

Laplacian Layer

Sharpened Image

To sharpen an image, we have to perform 3 steps: first is to find the Gaussian layer of the original image, which is essentially applying a Gaussian Kernel on the original image. The second step is to calculate the Laplacian Layer, which is the difference of the original image and the gaussian layer. The last step is subtracting the Laplacian Layer from the original image

=

1.2 Hybrid Images

Gaussian Filter is essentially a low pass filter, and the Laplacian Filter is a high pass filter. By combining two images using these two filters, we could obtain some really interesting pictures.

+

=

Derek and the Cat

John DeNero

Josh Hug


John Hug


+

=

Hug Original

John Original

John Gaussian

Hug Laplacian

Final

Now let's see if professor DeNero and professor Hug plays well with each other

By taking the FFT of the images, we could visualize the hybrid process

1.3 Gaussian & Laplacian Stacks

By creating the Gaussian & Laplacian stacks, we could analyze a hybrid image and discover the components within that image. For example:


Gaussian Stack

Laplacian Stack

Gaussian Stack

Laplacian Stack

1.4 Multiresolution Blending

Utilizing the Gaussian and Laplacian stacks could helps us editing some more interesting pictures, such as blending two images seamlessly. The following examples showcases blending two images using the Laplacian Stacks


Trumple

Four Seasons

Part 2: Gradient Domain

2.1 Reconstructing Image Using Gradient

2.2 Poisson Blending

Lion in the Ocean

DeNero & The Campnile

Comet in Yosemite

Failure Case:


Poisson Blending fails when the background of two images are very different in color. For example, the Campnile has a blue background, whereas professor DeNero is in a bright orange background. Therefore the hybrided image looks quite weird.

Original Image

Reconstructed Image

 Using Least Squares

This blended image uses Trump's face as the mask, and applies 5 layers of Laplacian stack to generate the final result

Besides frequency domain, images could also be represented in the gradient domain, which is essentially the "derivative" of the pixel values (in our case, the difference between two adjacent pixel values). Using the gradient could help us blend different images seamlessly, because the transition between the boarder of two images are now smoothed out, which makes the image looks like a whole.

Implementing Poisson Blending is essentially solving the problem: "given the source image pixel values and the target pixel values, as well as the mask, solve the pixels in the target image so that it contains all information from the source image but also blends in with the boarder of the target image". The following examples are the results of the algorithm.

To create the result image, we first select the source image region for the image mask, and then use least square to solve the correct pixel values that fits in the target region in the target image. After that, we simply copy over all the solved pixels to the target region, and Voila!

Final Thoughts:


Compared with Laplacian Pyramid/Stack Blending and Poisson Blending, it appears that either technique have their own advantage and disadvantages. For Laplacian blending, the result is quite satisfying when the mask is chosen carefully. For Poisson blending, the result is satisfying when the background color of two images are similar. Poisson blending looks more realistic because the overall color transition is smooth. However, Poisson blending may be probabilistic when the background color is extremely different. For example, consider the Trumple:


Laplacian Stack

Poisson Blending with Black Background

Poisson Blending with Light Background

Original