Fun With Frequencies

Allan Yu

Overview

Below are a collection of images manipulated through frequencies. We start with edge detection, then move to straightening images and even blending images together. Success cases and failure cases are shown throughout.

Gradient Magnitude Computation

We convolve arrays of [1,-1] and [1,-1] transposed (partial derivatives) with the original image. We then sum the squares and take the square root. I used a threshold of 0.15. Here is the result:

Original cameraman

Edge cameraman

Now we blur the image then do the same thing. As you would expect, our edges are thicker and more defined as a result. This is because we get less "edges" throughout the image, and only in the most pronounced areas. Noise is minimized here. Also, we can create a derivative of gaussian filters and only use a single convolution here.

Blurred Image

Single convolution (Same result!)

Straightening Images

Now we use the gradient angle of the edges of images to rotate images so that they appear aligned. I rotated from -10 to 10 degrees, and took the rotation with the best score. For each image, I display the original image and the straightened image, each followed by their respective orientation histogram. The house case and the sidewalk case are failure cases. The house case is likely because the house was rotated a lot. We could rotate this correctly given more computation time. The sidewalk case is a failure case because the image largely contains curves, which does not work very well with the angle reliant algorithm.

Original Facade

Original Facade Histogram

Rotated Facade

Rotated Facade Histogram

Original House

Original House Histogram

Rotated House

Rotated House Histogram

Original Pisa

Original Pisa Histogram

Rotated Pisa

Rotated Pisa Histogram

Original Sidewalk

Original Sidewalk Histogram

Rotated Sidewalk

Rotated Sidewalk Histogram

Unsharp Masking

Here, we make an image sharper using gaussian filtering and emphasizing high frequencies. For the Great Wall example, we take the original image, blur it, then run the algorithm on the blurred image to compare it to the original. Turns out our algorithm is pretty effective. (Note: I think the sharp image turned out pretty well here actually. But in reality I would expect the re-sharpened image to not be nearly as good as the original, since information is erased when blurring.

Taj Mahal Blurry

Taj Mahal Sharp

House Blurry

House Sharp

Great Wall Original

Great Wall Blurred

Great Wall Sharp (From Blurred Image)

Hybrid Images

In the next section, I mix two images- one with a low pass filter and one with a high pass filter. As a result, we get a mixed image, where it looks like one image far away and another close up. The image of Bill Gates and a baby is a failure case here. Although the faces align somewhat, the difference in positioning of the two pictures' bodies and hair make the image look unnatural. (For a more obvious failure case, we can use two completely different images/face shapes that are difficult to align, especially if the eyes cannot line up.)

Man

Cat

Man + Cat

Bill Gates Original

Bill Gates High Filter

Baby Original

Baby Low Filter

Bill Gates + Baby

Trump Original

Trump High Filter

Obama Original

Obama Low Filter

Trump + Obama

For the Trump + Obama images, here are the log magnitude of the Fourier transform of the input images, filtered images, and the hybrid image.

Trump Original

Trump High Filter

Obama Original

Obama Low Filter

Trump + Obama

Gaussian and Laplacian Stacks

Here, I used Gaussian and Lapalacian stacks to increase the effects of filtering. Here are the results.

Gaussian:

Lincoln Original

Lincoln Layer 1

Lincoln Layer 2

Lincoln Layer 3

Lincoln Layer 4

Lincoln Layer 5

Laplacian:

Lincoln Original

Lincoln Layer 1

Lincoln Layer 2

Lincoln Layer 3

Lincoln Layer 4

Lincoln Layer 5

Now, the same process but with the Obama + Trump image from earlier.

Gaussian:

Original

Layer 1

Layer 2

Layer 3

Layer 4

Layer 5

Laplacian:

Original

Layer 1

Layer 2

Layer 3

Layer 4

Layer 5

Multiresolution Blending

Using the previous ideas of blurring images, we blur part of images so that a nice transition can be made between two images. This creates the effect of a mixed image, as seen below. The failure case here is the first example of the baby + sun. This does not work as well as the following attempt because the sun's image has too similar colors and the blend becomes uncertain. We try again with the same baby and a new sun picture, and the result becomes significantly better. For this last example, the entire process is shown. (Inspiration from Teletubbies.)

Apple

Orange

Mixed with Vertical Mask

Baby

Sun

Mixed with Circular Mask

Baby (Again)

Sun (Second Attempt, Different Sun)

Mixed with Circular Mask

Following is the process to achieve the final result above.

Baby Gaussian:

Layer 1

Layer 2

Layer 3

Layer 4

Layer 5

Baby Laplacian:

Layer 1

Layer 2

Layer 3

Layer 4

Layer 5

Sun Gaussian:

Layer 1

Layer 2

Layer 3

Layer 4

Layer 5

Sun Laplacian:

Layer 1

Layer 2

Layer 3

Layer 4

Layer 5

Mask Gaussian:

Layer 1

Layer 2

Layer 3

Layer 4

Layer 5