Compsci 194-26 Project 2

Nicholas Figueira

Overview

This project will begin by showcase filtering images to detect edges and sharpen images. We will then combine some images, first by overlapping their frequencies, and then by blending their edges.

Part 1: Fun With Filters

Part 1.1: Finite Difference Operator

First, we will try to detect the edges of an image. This will be done by first finding the partial derivatives in the x and y direction of the image by convolving it with x and y finite difference operators. Then, we will compute the magnitude of the gradient at each point and if that gradient is above some threshold (I chose 0.25), then we treat it as an edge.

X Gradient

Y Gradient

Gradient Magnitude

Edges

Part 1.2: Derivative of Gaussian (DoG) Filter

In this part, we try blurring the image with a Gaussian filter before computing the gradient magnitude. This helps to avoid false edge detections. I used a Gaussian kernel size of 5 and a sigma of 4. I then combined the Gaussian filter and the finite difference operators into a single convolution, which yielded the same edges as doing everything separately. I used a threshold of 0.05 for edges this time.

X Gradient After Blurring

Y Gradient After Blurring

Gradient Magnitude After Blurring

Edges After Blurring

Gaussian Convolved with dX

Gaussian Convolved with dY

Part 2: Fun with Frequencies!

Part 2.1: Image "Sharpening"

For this part, we will sharpen images by increasing the high frequencies in them. We do this by applying an unsharp mask filter.

Taj Original

Taj Sharpened

Hummingbird Original

Hummingbird Sharpened

I also blurred an image, then applied the unsharp mask filter to see what the difference would be with the original image. It looks unnatural compared to the original, although both do look sharper than the blurred version. Information is lost when the image is blurred, so it is not possible to sharpen back to the original image.

Golden Gate Bridge Original

Golden Gate Bridge Blurred

Golden Gate Bridge Sharpened

Part 2.2: Hybrid Images

Now we try to create hybrid images that appear as one picture from close up but a different picture from far away. This is done by combining the low frequency portion of one image with the high frequency portion of the other image. Low frequencies are better seen from far away and high frequencies are better seen from close up.

Derek Picture (Low Passed)

Nutmeg Picture (High Passed)

Derek and Nutmeg Combined

The next one I tried didn't work very well, as it mostly just looks like the dog.

Lion (Low Passed)

Dog (High Passed)

Lion and Dog Combined

This worked a little better, but not great.

Cat (Low Passed)

Teddy Bear (High Passed)

Teddycat

Finally, this is my favorite of the hybrid images I created.

Dwayne Johnson (Low Passed)

Jason Statham (High Passed)

Dwayne Statham

Here are the Fourier transforms of various portions of the process for that last hybrid.

Dwayne Johnson Frequencies

Jason Statham Frequencies

Dwayne Johnson Low Passed Frequencies

Jason Statham High Passed Frequencies

Dwayne Statham High Passed Frequencies

Part 2.3: Gaussian and Laplacian Stacks

Now we try to blend two images together with a smooth transition between them. We use Laplacian stacks to break them up into different frequencies, blend the frequencies together, and then combine all of the frequencies back into one whole combined image. Here are the different levels of the laplacian for the apple, orange, and orapple from left to right. The final column is all frequencies added together.

Orapple Final

Part 2.4: Multiresolution Blending

Now we'll try on some other images. Here is a desert blended with an ocean, so it seems like some camels are walking into the ocean.

Desert

Ocean

Desert Merged With Ocean

Finally, we have an image of Berkeley merged with one of Oski to show Oski looking down on us from the sky. At the start, the Oski image was smaller than the Berkeley image, and I wanted Oski to be in the sky in the upper right of the image, so I appended 0s to the left and bottom of it.

Berkeley

Oski Original

Oski With 0s Appended

I drew a mask (literally haha) on Oski and used that to create the mask for the combination of the images.

Oski With Drawn Mask

Image Mask

Oski Watching Final