CS 194-26: Computational Photography Project 2

Akash Singhal

Project Overview

The second project involved using various filtering and blurring techniques in order to alter and enhance images.

Part 1

1.1

In order to find the edges of the image, we can use the dx kernel [1, -1] and dy [[1], [-1]] to convolve with the original image. With both of these gradient images, we can then compute the gradient magnitdue (sqrt(dx^2 + dy^2)) in order to combine and determine the edge strength in the image. Finally, we can find a magnitude threshold and binarize the image to produce the final edge image.

dx [1, -1] convolution to cameraman image
dy [[1], [-1]] convolution to cameraman image
gradient magnitude
Final binarized image

1.2

We can apply a gaussian filter first to the cameraman image and then calculate the partial derivatives as in the previous part. The initial blurring will provide better results as it removes some of the higher frequencies. We can see that applying the gaussian blur creates much more defined edges in the gradient magnitudes.

Final binarized image

The guassian and derivative convolution operations can be combined into one convolution. We develop a Derivative of Gaussian (DoG) filter and convolve each once with the cameraman image.

DoG dx filter
DoG dy filter

Convolving the above filters and then computing the gradient magnitude image results in the exact same image as using 2 separate operations.

Final binarized image

1.3

In order to straighten images that are crooked, we need to leverage gradient angles in order to determine which image is straight. A gradient angle is found by finding the arctan of the partial derivatives of an image. A straight image is one that has the highest number of 90 and -90 degree angles in it compared to others. I generated a small subset of possible angles and then generated a histogram of the distribution of gradient angles in each rotated image. I then selected the rotation that yielded the highest number of -90 and 90 degree angles.

Facade Histogram: -3 degrees is best fit
Crooked and then Straightened Facade
Mississippi sign Histogram: -8 degrees is best fit
Crooked and then Straightened Mississippi sign
Picture Frame Histogram: 10 degrees is best fit
Crooked and then Straightened Picture Frame

Failure Case

I tried to straighten an image of a swingset on a field. A truly straightened image would just make the horizon of the image straight. But the prominent edges in this image are the angled swing supports and thus looking at the distribution of angles, the best fit angle actually aligns the swing supports to be straight and not the picture horizon.

Swings Histogram: -8 degrees seems to be best fit
Crooked and then Mis-straightened Swings

Part 2

2.1

In this part, we had to sharpen blurry images so that to the human eye it looks clearer and crisper. In order to fool the human eye, the amount of high frequency boosting has to be closely regulated.

Original and Sharpened Taj Mahal
Original and Sharpened Cafe
Original, Blurry, Sharpened Radar Building

2.2

In this part, the goal was to make hybrid images. We combined 2 images to form a hybrid image where one could be seen from a certain distance and the other from further away. In order to achieve this effect, I extracted the high frequencies of one of the images and the low frequencies of the other and then superimposed them to create the hybrid image.

Me and My Dog
Low Pass, High Pass, Combined
Grumpy Cat and Mouse

Failure Case

Hybrid Images only look appropriate when the 2 images have shapes that can align and match up. This is why faces work well. However objects that have different shapes do not align well when superimposed.

Toothbrush and Toothpaste

2.3

For this part, we had to generate the LaPlacian and Guassian stacks for 2 hybrid style images.

Me and My Dog

2.4

I performed image blending of 2 different images using a provided mask.

Oraple

Eye of Sauron on a Brick Wall

Comet in San Francisco

Comet in San Francisco Deconstructed