CS194-26 Project 3: Fun with Frequencies and Gradients!

By: Jia Ze Yu

Date: 2018-09-30

Part 1: Frequency Domain

Part 1.1: Warmup

I used the unsharp masking technique to sharpen this cat image. I first applied a 5 by 5 Gaussian filter on the image and blur it with sigma 1 and subtracted a scalar multiple k of the blurred image from (1 - k) of the original image. I also make sure the pixel values are within the correct range.

Original

Sharpened (k=3)

Part 1.2: Hybrid Images

I combined the low frequencies from an image with the high frequencies from another image to create hybrid images. When we are close to the image, we see the high frequencies while when we are far way, we see the low frequencies.

Derek and Nutmeg

Derek

Nutmeg

Derek + Nutmeg


Girl and Boy

Girl

Boy

Girl + Boy


Corgi and Wolf

Cute Corgi

Fierce Wolf

Corgi + Wolf


Fourier Analysis

In the frequency domain, we see images in terms of high and low frequencies. As expected, after high and low pass, the even scatter in the original images changes to become high frequency FFT(brighter) and low frequency FFT(dimmer) respectively.

Corgi and Wolf

Corgi's Original FFT

Wolf's Original FFT

Corgi's High Pass FFT

Wolf's Low Pass FFT

Hybrid's FFT


Fail case

This pair does not work well because of their vastly facial expressions. The old lady has a wide grin that shows her teeth while the baby has his mouth wide opened, resulting in inconsistent textures.

Old Lady and Baby

Old Lady

Baby

Old Lady + Baby


Part 1.3: Gaussian and Laplacian Stacks

To visualize the image at various frequencies, I implemented Gaussian and Laplacian Stacks.

Dali

Gaussian Stack
Laplacian Stack

Girl and Boy

Gaussian Stack
Laplacian Stack

Part 1.4: Multiresolution Blending

This part blends images by first splitting them into frequency bands, blending each band with a seam and then adding them back into an image. For high frequency bands, a sharper seam is used while a more blurred seam is used for low frequency bands.

Apple

Orange

Orapple


White Cat

Yellow Cat

Blend Cat


Mona Lisa

Frowning White Lady

Smiling Yellow Lady


Visualizing the Laplacian Stack for Multiresolution Blending

By deconstructing both images using Laplacian Stack, we can see the composition of the multiresolution blending at each frequency band.

Yellow Cat
White Cat
Blended Cat

Part 2: Gradient Domain Fushion

In this part, a gradient domain processing technique called "Poisson Blending" is used to blend the images. This method blends a section of source image into the target image. To achieve this, two values need to be minimized to solve for the value of the pixels placed in the target image, the first being the squared error between the gradient of the new pixels and the corresponding source image pixels, while the second being the gradient between the new pixels and the target image boundary with the corresponding source image pixels such that the pixels on the edge of the image blend well. Hence, a least squares problem solving for the pixels placed in the target image needs to be set up.

Part 2.1: Toy Problem

Before trying Poisson Blending, for sanity check, I recreated a toy image by solving for an image that matches the gradient of the original image.

Original

Reconstructed


Part 2.2: Poisson Blending

This is my favorite blending result. I first created a mask for the face of Mona Lisa using GIMP Image Editor. Then, to smoothen the seam, I match the gradient within the new pixels to the source image and the edge to the target image. I make sure the target image has a smooth texture such that the blending is not obvious. On the other hand, the texture of the source image is well blended as we do not see any obvious artifacts of the blending.

From the famous frown to the famous smile

Mona Lisa

Frowning White Lady

Without Poisson Blending

Smiling White Lady


Swimming Cat

Running Cat (Source)

Underwater (Target)

Mask

Swimming Cat


Godzilla attacks Berkeley

Godzilla

Berkeley Marina

Mask

Incoming Godzilla


Fail Case

Poisson blending does not work well for this case because there are lots of details in the space image. Blending the running cat image with the space background causes the stars near the seam to be blurred, resulting in an obvious seam around the cat.

Flying Cat

Running Cat

Space

Flying Cat


Laplacian vs Poisson Blending

For this pair, Poisson Blending works better as the colors between two images are better blended. On the other hand, Laplacian Blending preserves the original colors of the two images better. Laplacian Blending works better if both images have small color difference across the seam as it preserve the colors and the textures of the original images better. Poisson Blending works better in most cases but often the color of the source image might seem "washed out" to blend into the target image.

From the famous frown to the famous smile

Original Mona Lisa

Original Frowning Lady

Laplacian Blending

Poisson Blending