CS 194 Project 2 : Fun with Filters and Frequencies!

Part 1: Fun with Filters

Part 1.1: Finite Difference Operator

In part 1.1, I began with creating the finite difference operator. In order to do so, I began with instantiating dx as [[1,-1]] and dy as the same but transposed. From here, I was able to convolve the image with dx and dy which is shown below. From there, I was able to calculate the gradient magnitude, by squaring the convolved dx and dys, summing them, and taking their square root, which is just the basic formula for calculating gradient magnitude here. Lastly, I was able to turn this into an edge image, by binarizing the gradient magnitude image by using a threshold that would be able to suppress the noise in the image, but still keep the real edges.

Original Image of Cameraman:

image

Partial derivative with respect to x (dx)

image

Partial derivative with respect to y (dy)

image

Gradient Magnitude

image

Edge Image:

image

Part 1.2: Derivative of Gaussian (DoG) Filter

Although, in 1.1 we see that we are able to trace over the edges of the camerman image, we can still do better. There is a lot of noise that we can still eliminate. As we learned in lecture, we can make use of the Gaussian filter to create a blurred version of the image by convolving with the image. From there, I was able to repeat what we did previously above to find an edge image with less noise and more real edges.

Gaussian Partial Derivative with Respect to x:

image

Gaussian Partial Derivative with Respect to y:

image

Gaussian Gradient Magnitude:

image

Gaussian Edge Image:

image

The difference is quite easy to see. The edge image that we created with the gaussian blur, has significantly reduced the noise, made the edges much smoother, and kept more real edges. This required two convolutions, however, we can do the same thing with a single convolution and expect to see the same results.

Single Convolution Partial Derivative with Respect to x blurred:

image

Single Convolution Partial Derivative with Respect to y blurred:

image

Single Convolution Gradient Magnitude:

image

Single Convolution Edge Image:

image

As we can see comparing the images from above to these, as expected, we have obtained the same images and results.

Part 2: Fun with Frequencies!

Part 2.1: Image "Sharpening"

In order to sharpen images in 2.1, I derived the unsharp masking technique. As mentioned before, we can use the Gaussian filter to remove high-frequencies and blur the image. If we take our remaining low-frequency image and subtract that from the original image then we have the high-frequencies which we can use to sharpen an image, as an image looks sharper with stronger high-frequencies. So, I did exactly this as shown below with the Taj Mahal and a Ferrari.

Taj Mahal Original:

image

Taj Mahal Blurred:

image

Taj Mahal Sharpened:

image

Ferrari Original:

image

Ferrari Blurred:

image

Ferrari Sharpened:

image

Another objective of 2.1, was to take a sharp image, blur it and then try to sharpen it again. Thus, I used the already sharpened Ferrari, blurred it again, and tried to sharpen it again As we can see, the ferrari below that has been re-sharpened, has become very sharpened to a point in which you can tell it has been heavily edited. However, you can clearly see the progression of sharpening above and what happens if we even further sharpen it below.

Ferrari-Sharpened:

image

Ferrari-Sharpened Blurred:

image

Ferrari Re-Sharpened:

image

Part 2.2: Hybrid Images

In 2.2, the goal was to take two images and form a hybrid image of them. To create a hybrid image, I first aligned the two images, then low-pass filtered one image and high-pass filtered the other image Lastly, I added the two images together and displayed the final hybrid image. I did this for Derek and Nutmeg and another example with Will and Jaden Smith. Additionally, I showed how hybrid images can go wrong as well.

Derek Original

image

Nutmeg Original

image

Derek-Nutmeg Hybrid

image

Derek FFT

image

Nutmeg FFT

image

Low-Pass FFT

image

High-Pass FFT

image

Derek-Nutmeg Hybrid FFT

image

Another example of the hybrid image I created was Will and Jaden Smith.

Will Smith Original:

image

Jaden Smith Original:

image

Will and Jaden Smith Hybrid:

image

Here if are close we are able to see Jaden Smith, stepping far back we are able to see Will Smith.

Failure Case : Lastly, I have an example for when hybrid images can go wrong. In this instance, I tried to make a hybrid image of a cheetah jumping and a motorcycle doing a wheelie. However, we see this does not work as well as the points used to align them are not as great as they have differing angles as well as sizes for the objects.

Motorcycle Original:

image

Cheetah Original:

image

Motorcycle-Cheetah Hybrid:

image

Multi-resolution Blending and the Oraple journey

2.3: Gaussian and Laplacian Stacks

image

2.4: Multiresolution Blending (A.K.A. The Oraple!)

To blend two images, I used the gaussian and laplacian stacks with a mask to blend the selected images together. This multiresolution blending and use of various image frequencies created in the stacks allows for making a smoother blend between two images. The first image that I blended was the orange and the apple, to create the ORAPLE!! From there, I also provide an example below of blending a basketball and volleyball together. Lastly, as a different masking approach I used the horizontal seam to make the ultimate energy drink Rockster (combination of monster and rockstar).

ORAPLE! :

image

Basketball Original:

image

Volleyball Original:

image

Basketball-Volleyball Blend:

image

Horizontal Seam Blend :

Rockstar Original:

image

Monster Original:

image

Rockster:

image