Project 3 - Fun with Frequencies and Gradients

by CS194-26-acz Steven Wu

In this project, I explored different image blending techniques that involve filtering and manipulating the frequency domain as well as blending in the gradient domain.

1.1 Image Sharpening

Mechanism

Sharpening means adding back details to the image. The "details" can be obtained by substracting a blurred version of our image from the original image. Then we can adding the "details" back to the original image. If the blurring processes is done using a Gaussian Filter, we can use the following kernel:

Results


1.2 Hybrid Images

Mechanism

We can make hybrid images by combining the low frequncies from one image and the high frequencies of another image. Low frequencies are visible from far away and high frequencies from up close, creating a hybrid. Therefore, we can apply Glaussian on image A, which sits at the bottom. We then overlay the details from image B, obtained by Laplacian, over the top. Here I illustrate the Fourier analysis of the filtered images and the blended image I create.

 

Low Frequency in Image A | High Frequency in Image B | Blended Image

 

Gallery

Catman

Trum-Pun-Un-1

Trum-Pun-Un-2

 

 

1.3 Gaussian and Laplacian Stacks

Mechanism

In the gaussian stack, we convolve with a gaussian with increasing sigma at each level, so each successive image has a smaller active frequency range in the low frequencies. In the laplacian stack, we take the difference of the results in the consecutive gaussian stack.

Gallery

1.4 Multiresolution Blending

Mechanism

Taking advantage of Gaussian and Laplacian stacks, we can create Laplacian stacks for two images and a Gaussian stack for a mask. At each layer we blend the two images with the mask, and then add together all the layers to create a frequency-blended image that is blended on all frequency spectrum.

Gallery

  1. CNN Exclusive: Magnificent Aurora in SF Last Night (irregularly-shaped mask)

  1. CNN Exclusive: PUBG Corporation - New Map 'Chaos' Created by Milo Yiannopoulos

  1. CNN Exclusive: PUBG Corporation - Announcing New Assult Rifle: AWM-K14

2.1 Toy Problem

In Part 2 we explore blending images using gradient domain fusion. We start with a simple problem - reconstruct the original image by minimizing the gradient parity between the original image and the image we are reconstructing.

Original vs Reconstructed

The error of our minimazion Av - b is 2.6158066451483797e-05

2.2 Poisson Blending

Machanism

Poisson blending makes it possible for objects to be nicely blended into a larger image. It sets the values on the boundary of the mask to the value on the destination image where the object will be placed to. Then it reconstructs the values within the mask area - like we had done in 2.1 - so that the gradients in the mask match closely to what is the source image.

Gallery

  1. CNN EXCLUSIVE: Global Warming Is FAKE! Penguins Found in Tahoe City
  2. CNN EXCLUSIVE: What REALLY Happened on Sept, 11, 2001
  3. CNN EXCLUSIVE: Llama Visits His Alma Mater
  4. CNN EXCLUSIVE: Leonardo Went Crazy after ONE Week of Higher Education

 

Comparision with Naive Copying

 

Observation

To generate a realistic-looking seamless blending, it is very important for the destination image also matches the color scheme and brightness setting of the cropped object.

For results 0 - 2, this criteria almost holds and we get reasonable results. However, for results 3, as the destination image has low brightness and the lawn appears to be dark, our Leonardo is thereby affected. Also his head cuts through the road, which is sad.

Special Thanks