Project 2: Fun with Filters and Frequencies!

Kachi Onyeador

Overview

The task of this project is to colorize the Prokudin-Gorskii photo collection. His photo collection consists of 3 separate color channel images that appear to the normal eye as gray. Our job was to combine these separate color channel images into one colorized image output.

1.1 Finite Difference Operator

To compute the gradient magnitude image, I calculate the square of the images convolved with the Dx and Dy. Then I added those up and after I took the square root of that. The threshold for this main image is 0.13. As you can see from the image below, there is still plenty of noise at the bottom. But that is where the next part of this project comes in to save the day.

Convolved with dx
Convolved with Dx
Convolved with dy
Convolved with Dy
The gradient image
Gradient Image
The binarized image
Binarized Image
Part 1.2: Derivative of Gaussian (DoG) Filter

For the first part of this problem, I did what was asked. I blurred the image using the gaussian filter before applying the dx and dy operators. With this resulting image. I noticed it was a lot clearer and less noise than the results from 1.1. However, I also did the second part of the problem to see if I got the same image results when I would convolve the gaussian filter with dx and dy before applying the convolved filters onto the image. I still got the same clear, non noisy results which was very cool as well. I show the two results from both methods below, as well as images of the x gradient filter and the y gradient filter. (Gaussian kernel parameters: ksize = 5, sigma = 2)

gaussianconvolvedwithx
Gaussian filter convolved with Dx
gaussianconvolvedwithy
Gaussian filter convolved with Dy
binarizedimage
Without Gaussian filter
method1
Gaussian Filter - Method 1
method2
Gaussian Filter - Method 2
Part 1.3: Image Straightening

In the final section of part 1, we use what we learned to do automatic rotation to try to achieve a straight image. We learn in this part that images with right angles and straight lines are more likely to be straighter images. We use the derivatives to calculate the gradient angles of an image. We do this by calculating the distribution of gradient angles for each angle rotation between -15 to 15 to determine what the best angle is for a straight image (as shown in my histogram). Our kernal size here is 5 and our sigma is 2

facade
Regular Facade
straightenedfacade
Straightened Facade
histogram1
Histogram
leaningtower
Leaning Tower
straighttower
Straight Tower
towerhisto
Tower Histogram
leaningcampanille
Leaning Campanille
straightcampanille
Straight Campanille
campanillehisto
Campanille Histogram
Part 1.3: Failed Case

I noticed everyone doing the woman image case and i thought it was interesting so i wanted to find out for myself. Sure enough, it failed with my algorithm. I believe the reason it failed is because my algorithm cannot differentiate between horizontal and vertical lines properly so it ended up orienting her sideways instead of right side up. I thought this was super fascinating!

womanstraight
Original Woman
womanfailed
Woman Failed
womanhisto
Woman Histogram
Part 2.1: Image Sharpening

We then got into making images sharper. Images can be sharpened by by upping the higher frequencies. We do this by first subtracting the blurred image from the original image. This can be put together into a single unsharp filter using a combination of weighted unit impulse function and gaussian filter. Below, I show the original image, sharpened image, and me blurring the image myself.

taj
Original Taj
sharpenedtaj
Sharpened Taj
blurrytaj
Blurry Taj
nicki
Original Nicki
sharpenednicki
Sharpened Nicki
blurred-nicki
Blurry Nicki
nicki
Original Nicki
sharpenednicki
Sharpened Nicki
blurred-nicki
Blurry Nicki
Part 2.2: Hybrid Images

We then got to create hybrid images! These are when two images are combined and interpreted differently at different distances when looking at them. It happens by combining the higher frequencies from one image to the lower frequencies from the other. Then, at closer distances, you can see the higher frequencies while at further distances, you can see the lower frequencies. I have my images below.

help1
Derek Combined with Nutmeg Cat
help1
FAILURE CASE: Barack Obama combined with George Clooney. I think its a failure because the different shapes of our faces is very clear.
help2
Barack Obama combined with another cat I found because I like cats
Part 2.3: Gaussian and Laplacian Stacks

By taking the Gaussian and Laplacian stacks, we can see the image at different resolutions. I repeatedly blur an image with a kernal of size 30 and a sigma of size 6. The deeper you go in the gaussian stack, the more clear the original low frequency image becomes. The deeper you go in the laplacian stack, the higher frequency images become clearer. You will see however that my laplacian images, even though the right process is happening, are very dark. This is a clipping issue that me and a TA were having trouble figuring out. But regardless of that, you can still makeout that the further you go in the laplacian stack, the higher frequencies are becomming clearer.

g1
Gaussian Level 1
g2
Gaussian Level 2
g3
Gaussian Level 3
g4
Gaussian Level 4
g5
Gaussian Level 5
g6
Gaussian Level 6
g7
Gaussian Level 7
g8
Gaussian Level 8
g9
Gaussian Level 9
l1
Laplacian Level 1
l2
Laplacian Level 2
l3
Laplacian Level 3
l4
Laplacian Level 4
l5
Laplacian Level 5
l6
Laplacian Level 6
l7
Laplacian Level 7
l8
Laplacian Level 8
l9
Laplacian Level 9
g1
Gaussian Level 1
g1
Gaussian Level 1
g2
Gaussian Level 2
g3
Gaussian Level 3
g4
Gaussian Level 4
g5
Gaussian Level 5
g6
Gaussian Level 6
g7
Gaussian Level 7
g8
Gaussian Level 8
g9
Gaussian Level 9
l1
Laplacian Level 1
l2
Laplacian Level 2
l3
Laplacian Level 3
l4
Laplacian Level 4
l5
Laplacian Level 5
l6
Laplacian Level 6
l7
Laplacian Level 7
l8
Laplacian Level 8
l9
Laplacian Level 9
Part 2.4: Multiresolution Blending

Multiresolution blending happens by blending two images using laplacian and gaussian stacks to create a smooth transition with a mask. Below are the results that I got on the orange apple and my own results (including the failed image).

mask
This is the mask I appled on all my images (other than the irreglar leotiger)
orapple
The OrApple (Orange and Apple base example)
leopard
The leopard
tiger
The tiger
leotiger
The leotiger (success)
irregularmask
This is the mask I appled on the next image I am going to show you
weirdtigerblend
This is the results of using the irregular mask shown above. See how the tiger print and the leopard print got reversed! I found that very cool.
obama
The Obama
george
The George
george
The GeoBama. I believe this failed because faces are really hard to get a seamless blend with since they both have very different faces.
Bells and Whistles

The Bells and Whistles I did were colored images for 2.2 Hybrid images (see above). Also, for 2.3 I attempted to do colored multiresolution and it came out kinda colored but my bug is that the image is quite dark and I believe it has something to do with clipping. But regardless you can kinda see how the apple is blended with the orange. (see below)

attempedcolor
Attempted Bells and whistles for color for multiresolution. My bug is that the image is quite dark and I believe it has something to do with clipping. But regardless you can kinda see how the apple is blended with the orange.
What I learned

I thought this project was super cool because the baselines for the filters we see on Snapchat and Instagram are all based on the concepts we are learning from this project. I think one of my favorite things to learn about were the Gaussian filters because we used then in every single part of this project and it was amazing to see how important they are in creating that final image. The other thing I thought was really cool was the concept of low frequency being seen at further distances vs high frequency being seen at closer distances and I thought this was awesome to see applied in CS because I have seen it in my Perception psychology class. This project is awesome!