Project 2: Fun with Filters and Frequencies!

Jason Yan

This project explores various image processing techniques, including finite difference operators, Gaussian filters, image sharpening, hybrid images, and blending.

Part 1.1: Finite Difference Operator

In this part, we implemented a finite difference operator to detect edges in images. The operator calculates the gradient using convolution in both x and y directions, allowing us to identify areas of rapid intensity change. We then threshold the gradient magnitude to get the edge image that shows the edges and less noise.

Original Cameraman Image

Original Cameraman Image

XY Edge Detection Result

Finite Difference Edge Detection Result (threshold=0.32)

Part 1.2: Derivative of Gaussian (DoG) Filter

The DoG filter, an edge detection method, is illustrated here. First, we obtain a 2D Gaussian kernel by taking the outer product of two 1D Gaussians. Then, we use this kernel to filter our image, which results in the high-frequency components being filtered out, making the image a bit more blurry, as you can see in the first line below. Next, we obtain an edge image using the same method as in 1.1, and you can notice that the lines in 1.2 are more pronounced and thicker. Afterwards, I tried to accomplish this operation directly using a convolution. We first take the partial derivative of the 2D Gaussian (similar to 1.1), and then convolve the image with this kernel, allowing us to blur and obtain the edge image in one step.

Original Image

Original Image

Gaussian Kernel

Gaussian Kernel

Blurred Image

Blurred Image

Blur Edge Image

Blur Edge Image

DoG Filter X

DoG Filter X

DoG Filter Y

DoG Filter Y

DoG Edge Image

DoG Edge Image

Part 2.1: Image "Sharpening"

In this part, we applied image sharpening techniques to various images. Each image below shows a comparison between the original (left) and sharpened (right) versions. We sharpened these images using a single convolution by setting up a special kernel. First, the base of this kernel is -alpha * Gaussian_kernel, and in the center of this kernel, we also add 1 + alpha (which is the impulse filter minus the Gaussian filter). This way, we can obtain sharpened images with just one convolution.

These images were found in my phone's photo album; they are pictures of my favorite soccer players that I saved back in 2016. Using this method, I made them look sharper. I chose alpha = 3 for all of them.

Muller Comparison

Thomas Muller: Original vs. Sharpened

Lewan Comparison

Robert Lewandowski: Original vs. Sharpened

Roben Comparison

Arjen Robben: Original vs. Sharpened

Buffon Comparison

Gianluigi Buffon: Original vs. Sharpened

Reus Comparison

Marco Reus: Original vs. Sharpened

Taj Mahal Comparison

Taj Mahal: Original vs. Sharpened

These are my cats. I first used a Gaussian kernel to blur it, then used the kernel described above to make this blurred image sharper.

Cat Comparison

My Cats: Original vs. Blurred vs. Blurred + Sharpened

Part 2.2: Hybrid Images

In this part, we extract a high-frequency version and a low-frequency version of an image. Then, we combine them so that when you look from a distance, you see the low-frequency image, and when you get closer, you can see the high-frequency image.

The first column shows the low-frequency image, the second column shows the high-frequency image, and the third column shows the hybrid image. Through my experiments, I believe that keeping the low-frequency image in color and turning the high-frequency image to grey yields better results.

DerekPicture

Derek

nutmeg

Nutmeg

hybrid_image2

Hybrid: DerekNutmeg

model

Model

butterfly

Butterfly

hybrid_image3

Hybrid: Modelfly

My favorite hybrid image:

monalisa

Mona Lisa

van_gogh

Van Gogh

hybrid_image1

Hybrid: Mona Van Gogh

Here is the FFT of the hybrid image. You can see that the high-frequency components are in the center, and the low-frequency components are on the outside.

FFT of Hybrid Image

FFT of Hybrid Image: Mona Van Gogh

Failure case: The hybrid of these two images didn't turn out very well. Regardless, the fox's appearance is more pronounced, while the human figure is less noticeable. This may be due to their very different backgrounds. The low-frequency image has too much weight.

fox

Fox

xiaoliang

Xiaoliang

hybrid_image4

Hybrid: Fox + Xiaoliang

Part 2.3: Gaussian and Laplacian Stacks

This section demonstrates the Gaussian and Laplacian stacks for the apple and orange images. The stacks show the decomposition of the images at different scales, which is crucial for later blending.

Apple

Original Apple Image

Orange

Original Orange Image

Gaussian and Laplacian Stacks

Gaussian and Laplacian Stacks

Part 2.4: Multiresolution Blending

In this section, we demonstrate the results of blending using various image pairs and masks. Each row shows the original images, the blending mask, and the final blended result.

First, I create a Gaussian stack of the masks, Gaussian and Laplacian stacks for both images. Then, at each level, I use this mask to blend the corresponding layers of the two images' Laplacian stacks. Finally, by adding up the layers of the blended Laplacian stacks, I obtain the blended image. The advantage of this method is that the blending appears more natural, without very obvious boundaries.

Apple and Orange Blend

Apple

Apple

Apple-Orange Mask

Mask

Orange

Orange

Apple-Orange Blend

Blended Result

The left side is a photo of my cat, and the right side is a photo I took at BAMPFA, where I placed my cat's photo into the frame on the right.

Cat

Cat

Cat-Paint Mask

Mask

Paint

Paint

Cat-Paint Blend

Blended Result

The left side shows a photo of the mother of the cat mentioned above, and the right side is a photo of an elephant I took at the Omaha Zoo. I wanted to make the image look as if my cat is about the same size as the elephant and as if it wants to fight the elephant.

Fighting Cat

Fighting Cat

Cat-Elephant Mask

Mask

Elephant

Elephant

Cat-Elephant Blend

Blended Result

The left side shows my grandfather's birthday cake, and the right side features a cat and a dog from my home. I wanted them to also celebrate the birthday together and share my grandfather's birthday cake.

Cake Right

Cake (Right)

Cat-Dog Mask

Mask

Cat and Dog

Cat and Dog

Cat-Dog Blend

Blended Result

This is the blending process of my favorite image, including all of their stacks.

Blended Stack 1
Blended Stack 2
Blended Stack 3