CS 194-26 Project 2 - Fun with Filters and Frequencies

Andy Wu, Fall 2020

Part 1: Fun with Filters

This project explored multiple image processing and methods through the manipulation of the frequencies in images, through the use of various filters and stacks.

Part 1: Fun with Filters

Part 1.1:

To compute the gradient magnitude, we convolve the image with a partial derivative in the x and y dimensions, defined as Dx=[1, -1] and Dy=[1,-1].T. The partial derivatives are shown below.

Then, we combine the two partial derivatives using the pythagorean theorem to find the gradient magnitude of the image.

Finally, to clean up the image, I took binarized the image using a threshold of 0.25.

Part 1.2:

Blurring the image by convolving it with a Gaussian kernel allows us to reduce the noise in the image. Since convolutions are associative, the two procedures result in the same output. The threshold used was 0.04. Notably, the resulting image has much thicker edges, since the hard edges from the original image were blurred.

Part 1.3:

Using the orientation of the gradients, we are able to straighten images, using the assumption that edges tend to be vertical or horizontal due to gravity. Shown below are the original (left)/rotated (right) pairs, along with their corresponding histograms.
Facade:


Keyboard:


Desk:


Campus:
Interestingly, aligning a picture of campus did not work well. My theory is that the edges are mostly located on the lines of Doe, and the algorithm tries to make those edges vertical, leading to a tilted image. We see the image as wrong since we know the Campanile is supposed to be vertical. This demonstrates that although the algorithm works well in many cases, there are still instances where the edges in an image are purposely not horizontal or vertical, or does not recognize the reference object to align the picture with.

Part 2: Fun with Frequencies

Part 2.1:

By taking the high frequencies and enhancing them in an image, we can artifically sharpen it. Shown below are the original(left) and sharpened(right) pairs.

For the keyboard picture, I took the original sharp image (left) and blurred it using a Gaussian filter (middle). I then sharpened it again (right). When comparing the blurred and sharpened image from up close, one can see that the words and objects are slightly sharpened, but not nearly as clear as the original image.

Part 2.2:

Shown below are the original and combined images.
Face + Cat:

Below are the images in frequency domain:
First are the original face image and the image after being filtered by a low pass filter.

Then are the original cat image and the image after being filtered by a high pass filter.

And finally, the combined image.

Bridge + Campus:

Harold + Dog:
For this case, the contrast in the fur of the dog is not large enough to be captured by the Gaussian filter, resulting in a very flat body of the dog when performing the combination. Instead, the high frequency grass is what shows up in the hybrid image.

Part 2.3:

Shown is the Gaussian (left) and Laplacian (right) stack for the Mona Lisa and the previous hybrid bridge/campus image.


Part 2.4:

Apple + Orange:

Rocket + Pineapple:
I used an irregular mask that isolated the leaves of the pineapple.

Watermelon + Cantaloupe:
The merging of a watermelon and cantaloupe did not work particularly well, probably due to the strong difference in intensity of the watermelon and cantaloupe images. This leads to a strong jump in intensity, even after blending.