Fun with Frequencies and Gradients!

David Tseng

Part 1

1.1 Warmup

Here is a blurry image of a bird, and a sharpened version of it.

Blurred bird Sharpened bird

1.2 Hybrid Images

Hybrid images can be created by passing one image through a low-pass filter, another image through a high-pass filter, and then averaging the resulting images. This creates different interpretations of the image depending on the distance the viewer is from the displayed image.

President Obama President Trump President Trauma
Cat Llama Cama
Smiling Kanye Frowning Kanye Scary Kanye (failure)

Here are some figures of the log magnitude of the Fourier Transform of the President Obama/Trump hybrid from the first row.

President Trump (original) President Trump (low-passed)
President Obama (original) President Obama (high-passed)
Hybrid

1.3 Gaussian and Laplacian Stacks

Gaussian stacks are created by repeatedly applying a Gaussian filter to the previous image. Laplacian stacks are generated from Gaussian stacks by subtracting adjacent images from the Gaussian stack, which essentially shows portions frequencies from the original image (like a band-pass filter).


1.4 Multiresolution Blending

Blending can be achieved by using Laplacian Stacks of two images and Gaussian Stacks of a binary mask. For a given layer, the result would be im1_layer * mask_layer + im2_layer * (1 - mask_layer). Here is the classic orapple example, along with several other examples.

Orange Apple Orapple
Fall Spring Fall-Spring
Penguin Snow Penguin in Snow

The last image actually uses an irregular mask, however, due to Gaussian blurring of the mask, you can still see the original rectangle from the penguin.

Part 2

As we can see in the above images, the blending can look nice, but could be better. The second part of this project uses Poisson blending to make the blending more realistic by using gradients. We try to minimize the square loss between the gradients in the resulting image and the gradients in the source/target image.

2.1 Toy example

As a toy problem, we can take an original image and reproduce that image by minimizing the square loss between the x and y gradients, and also using a single point for reference. Here is the toy example below.

Original Reproduced

2.2 Poisson Blending

Let's try blending images by mixing the gradients. Here's an example of how this works. We first scale the source image appropriately so that it would fit on top of the target image. We then create a mask that would allow us to crop the source image before placing it on top of the target image. The values of the pixels in the resulting image is found by minimzing the square loss betweeen the gradients of the resulting image and the gradients of the source/target images.

Source Target
Direct copy Poisson blending

Here are some more examples of blended images.

Source Target Blended

I consider the last one to be a failure (larger version shown below). As you can see, the original background of the fish had a different texture of waves, so attempting to blend the fish onto the ship image did not work really well. Source images with a flat background work better, since they tend to clash less with the target image.

The penguin picture did not blend that well with Laplacian Pyramid blending, but does relatively well with Poisson blending.

Laplacian Blending Poisson Blending

It is evident that Poisson blending performs much better compared to Laplacian blending. Generally, Laplacian blending only really works well when the source and target images are almost matched. Poisson blending still works really well when the background of the source image and the background of the target image are slightly different. Since Laplacian blending is computationally faster (relative to the size of the source image), one should use Laplacian blending over Poisson blending when the source/target images are almost matching.