CS 194-26 Project 2 - Andrew Loeza

Overview:

In this lab, we did many things. We first, experimented with edge detection using finite difference operators with and without gaussian filters. Then, we the gaussian difference operator filter to straighten images by analyzing the angles of pixels. We then analyzed the results by plotting histograms of the pixel angles. Next, we used gaussian filters to "sharpen" images and to see if "sharpening" actually could resharpen a blurred sharp image. Following this, we used high pass and low pass filters to overlay two images and create a hybrid image of the two that would change depending on the distance to the observer. We then implemented Laplacian and Gaussian stacks so that we could analyze the frequency bands of our hybrid images and other images that utilized frequencies in clever ways. And finally, we used our Laplacian and Gaussian stacks and a mask to implement multiresolution blending of two images.

Part 1.1: Finite Difference Operator

In this section, we used our finite difference operator on the cameraman image to generate two derivative images with respect to the x-axis and y-axis. We then combined the two images using the gradient magnitude equation, which is the square root of the added squares of the derivatives, to generate the edge image. Lastly, I binarized the result of this to remove noise. Unfortunately, due to the amount of noise in the resulting edge image, the binarization threshold numbers had to be quite aggresive in order to remove most of it, causing a loss of some detail.

Part 1.2: Derivative of Gaussian (DoG) Filter

In this section, I repeated everything from the previous part with the exception of applying a gaussian filter to the original cameraman image. The main difference I see is that the final edge image has a significantly less amount of noise present in it. This allowed me to be much less aggressive with my binarization threshold numbers, which allowed the small amount of noise to be removed while keeping the detail of the edges intact for the most part. This is a result of the gaussian filter acting as a low pass filter, which removed a lot of the noise from the grass. Note, though how the outline of the edge image in this case is much thicker than previously. This is most likely due to the gaussian blur thickening the edges due to how it averages across the image during convolution.

Combination Filter

Below we can see the results of combining the gaussian and finite difference operator together. The white represents the positive part of the difference, while the black part represents the negative part.

Now we use this combination filter to apply both of the individual filters to our cameraman image in one convolution. This saves us time and gives us essentially the same results as before. Note that the X derivative and Y derivative images appear lighter than they did for the previous part. This is most likely the result of floating point arithmetic differences in combination with how the program interprets these minute differences when it displays the image.

Part 1.3: Image Straightening

In this section, we used our combination filter to calculate the pixel angle distribution for the image. Then, using the fact that properly oriented images are statistically more likely to have a higher number horizontal and vertical images than those that aren't, I was able to successfully straighten several images. Also displayed below each image is its histogram for the pixel angles before and after straightening. We can see that the properly oriented images have a much higher amount of vertical and horizontal edges. The only case this isn't true is with the last image of the owl, which failed pretty badly with our algorithm. This is most likely because of the owl's feathers which have a pattern and texture that is very different than the buildings that I previously used. Both of these factors most likely caused the incorrect orientation to have the highest number of vertical and horizontal edges.

Image #1: Facade

Image #2: Buildings

Image #3: Apartment

Image #4: Owl

Part 2.1: Image "Sharpening"

In this part, I used the unsharp mask filter to "sharpen" images. However, as can be seen in the second image, this isn't really "sharpening" since the pencil didn't gain any detail back. Moreover, the sharpened image of the blurred image looks worse than the blurred image in my opinion.

Image #1: Taj

Image #2: Pencil

Part 2.2: Hybrid Images

In this part, we used the low and high frequencies of each image to create a hybrid image that changes depending on how far the viewer is from it. Images 1 and 2 both turned out looking good, but I was unable to get image 3 to look good regardless of the values for my sigmas. I think this is most likely due to the fact that the high frequency image, the Vallhund, has a lot of low frequency noise in the form of the grass that is very difficult to eliminate just by applying a high pass filter. This is visible in the resulting image as you can clearly see the grass interfering with the snow of the Corgi image.

Bells & Whistles:

I implemented my images with color. In my opinion, the resulting image usually looks better and more realistic, except in the case where colors from the images really clash with one another. However, even when the colors didn't match too well, I was able to get the resulting hybrid image to look quite good by adjusting my sigma values.

Image #1: Derek and Nutmeg

Image #2: Young and Old

Image #3: Corgi and Vallhund

Part 2.3: Gaussian and Laplacian Stacks

In this part, we use a Laplacian and Gaussian stack to visually display the frequency bands of the Salvador Dali Lincoln painting and of the Young and Old hybrid image that was shown in the previous part. By doing this, we can deconstruct both images in a way that allows us to see both images fairly clearly.

Image #1: Lincoln

Image #2: Young and Old

Part 2.4: Multiresolution Blending (a.k.a. the oraple!)

In this final section, we again use the Laplacian and Gaussian stacks to break two images down into several frequency bands and then combine each band using a mask that determines the weights for each image. The resulting images are then added together to create a blended together image that has elements of both images in it.

Bells & Whistles:

For this part, I implemented the blending to work with colored images. I first implemented it to only work with black and white images, but after getting the colored images to work, I think it really enhances the illusionary effect of the blending.

Image #1: Oraple

Image #2: Dogs

Image #3: Bear Watch

Visualization of the Masked Images for the Bear Watch

Note that the top row is the bottom layer of the Laplacian stack and the second to last bottom row is the top layer. The final row is the result of adding all of the images above it together.