CS 194-26: Computational Photography, Fall 2020

Project 1: Fun with Filters and Frequencies

Michelle Fong, CS194-26-ael



Overview

In this project, I used various convolutions and filtering in order to produce gradient maps of input images. I also appled these methods to blur, straighten, and sharpen images. I also explored image manipulation further by creating hybrid images and blended images, with the help of low / high-pass filtering and Gaussian / Laplacian stacks.

Part 1: Fun with Filters

Part 1.1: Finite Difference Operator

This section of the code convolves the input image with the finite difference filter. I used two convolutions, one for dx and one for dy, and combined their magnitudes to produce the gradient magnitude image. Afterward, I binarized the gradient magnitude using a threshold. I experimented with various thresholds and found that .25 worked best to give a clear outline of the camera and the man while not detecting noise.

"cameraman" edge image

Part 1.2: Derivative of Gaussian Filter

Here I took a length-5 1D Gaussian filter courtesy of Stack Overflow and multiplied it with its transpose in order to derive a 2D Gaussian filter. This then only requires a single convolution to produce the same result as the previous part which required two convolutions. As above, I binarized the gradient magnitude using a threshold which I found to be .1 here, which is lower than the previous. Given these different thresholds, I am able to produce a result very similar to before.

"cameraman" edge image with Gaussian filter

"Cathedral" G(5,2) R(9,3)
"Monastery" G(-3,2) R(3,2)
"Tobolsk" G(3,2) R(6,3)

Part 1.3: Image Straightening

I went about writing the code for straightening images by first thinking about the search radius. I originally tried a search from [-20, 20] but found that the rotation was much greater than what it is needed for the average tilted picture, and decided that a search range of [-10, 10] would still succeed in most use cases while only taking half of the time. I iterated through all of the selected angles (chosen with approximate step size of 2) and I computed the gradient angle by convolving the image with the Gaussian filter. I then summed up all angles close to [0, 90, 180, 270] in the image. Inception is a failure case and park and facade are success cases.



Original "facade"
Straight "facade"
Histogram for "facade"
Original "inception"
Straight "inception"
Histogram for "inception"
Original "park"
Straight "park"
Histogram for "park"

Part 2: Fun with Frequencies

Part 2.1: Image Sharpening

I sharpened these images by applying a low pass filter to the original image and subtracting it from the original. Additionally, I add back in some of the high frequencies. This is known as the unsharp mask filter.


Original "taj"
Sharpened "taj"
Original "pug"
Sharpened "pug"

Part 2.2: Hybrid Images

I also implemented hybrid images using the starter code and implementing my own low pass and high pass filters and averaging the resulting images.

Hybrid derek and nutmeg
Jungkook
Taehyung
Hybrid Jungkook and Taehyung
Derek fourier
nutmeg fourier
Filtered Derek fourier
Hybrid derek and nutmeg fourier

Part 2.2: Gaussian and Laplacian Stacks

I implemented Gaussian and Laplacian stacks on the sample image of Lincoln and Gaia.


Stack 0
stack1
stack2
stack3

Part 2.4: Blending

I implemented blending as described in the paper.


Irregular mask
Blended Taehyung and Jungkook
Oraple