---
# System prepended metadata

title: CS 194-26 - Fun with Filters and Frequencies!

---

CS 194-26 - Fun with Filters and Frequencies!
============================================

## Part 1: Fun with Filters
#### 1.1: Finite Difference Operator
To compute the gradient magnitude we needed to calculate the partial derivatives for both the X and Y directions Using this we can use the results to compute the `√(x^2 + y^2)`. Next we had to arbitrarily find a threshould that would maximize the binarize edges so the lines would be more defined. After choosing random numbers and testing them, I found that `0.0007` was the best number.

> Magnitude
> ![](https://i.imgur.com/HR8XNaH.png)

> Binarized Edge
> ![](https://i.imgur.com/s9aNyXf.png)

#### 1.2: Derivative of Gaussian (DoG) Filter
It is clear that the image in part 1.1 that there is a lot of noise throughout the image. To smoothen the image, we apply a guassian filter to the image before calculating the partial derivatives. The main differences we can see by using this method is that there is much less noise in the resulting image and the edges are more well defined and stronger than the resulting images in part 1.1.

> Magnitude (DoG Filter)
>![](https://i.imgur.com/v7gTTYp.png)

> Binarized Edge (DoG Filter)
>![](https://i.imgur.com/G7Uui4R.png)


#### 1.3: Image Straightening
##### Example:

> Original
> ![](https://i.imgur.com/TEdqEzK.png)![](https://i.imgur.com/MQgY2PA.png)

As we can see from the example image, the histogram clearly helps us show that adjusting the angle of the image helped  straigten the picture so that there were more straight vertical edges in the adjusted image.

> Changes
> ![](https://i.imgur.com/s4orAqo.png)![](https://i.imgur.com/L1bkCGK.png)

##### Self Selected Images:
###### Door
> Original
![](https://i.imgur.com/N0xTiIB.png)![](https://i.imgur.com/98L4xPS.png)


> Changes
![](https://i.imgur.com/4znWvBZ.png)![](https://i.imgur.com/bHpNcOW.png)


###### Park
> Original
> ![](https://i.imgur.com/ZmpCPms.png)![](https://i.imgur.com/LN6L4PO.png)

> Changes
> ![](https://i.imgur.com/JCZYJ1d.png)![](https://i.imgur.com/PyBjt8B.png)

##### Failure:
> Original
> ![](https://i.imgur.com/vpLU0zL.png)![](https://i.imgur.com/GUOk7J5.png)


As we can see from the image's background there are a lot of things, such as foliage and fences, that might make our implentation  perceive that the image we have chosen is already straight since only the sign is tilted and the other items in the background are not tilted. As a result, the adjustment angle of the image was only -0.5 degress and signifies that a lot of the background prevented the main item of the image from straightening out.

> Changes
> ![](https://i.imgur.com/YZZBoeU.png) 
> ![](https://i.imgur.com/Q4SaOxd.png)

## Part 2: Fun with Frequencies!
#### 2.1: Image "Sharpening"
We sharpened the image by first creating a blurred version using a Gaussian filter. We used this blurred version as a low-pass filter and subtracted it from the original to create an image only consisted of high frequency edges.
##### Taj Example:
> Original
> ![](https://i.imgur.com/8RYu7sL.jpg)

> Blurred
> ![](https://i.imgur.com/4RV1YlO.jpg)

> Sharppened
> ![](https://i.imgur.com/MDJXSY0.jpg)

##### Self Selected Image:
> House Original
> ![](https://i.imgur.com/yGcZj4K.jpg)

> House Blurred
> ![](https://i.imgur.com/KyLWKzM.jpg)

> House Sharppened
> ![](https://i.imgur.com/PuUhmLn.jpg)


#### 2.2: Hybrid Image

###### Example
> Nutmeg
> ![](https://i.imgur.com/mxeTff6.jpg)

> Derek
> ![](https://i.imgur.com/Hlj2VzE.jpg)

> Hybrid
>  ![](https://i.imgur.com/8QBwwLX.jpg)


##### Self Selected Images: 

> Prof. Denero with Corresponding Frequency
> ![](https://i.imgur.com/a78y07t.jpg)![](https://i.imgur.com/Bx51apx.png)


> Prof. Hilfinger with Corresponding Frequency
> ![](https://i.imgur.com/ZnSG9Fo.jpg)![](https://i.imgur.com/eYkucWn.png)

> Low pass filter with Corresponding Frequency
> ![](https://i.imgur.com/XAUNNXC.png) ![](https://i.imgur.com/xJH7ERU.png)


> High pass filter with Corresponding Frequency
>![](https://i.imgur.com/3qnKjt0.png) ![](https://i.imgur.com/PXpgtsD.png)


> Professor Hybrid with Corresponding Frequency
> ![](https://i.imgur.com/wLoKHYT.jpg) ![](https://i.imgur.com/Q5iZtRW.png)


> Tiger
>![](https://i.imgur.com/THYJuQU.jpg)

> Lion
> ![](https://i.imgur.com/Yk7ejHt.jpg)

> Liger Hybrid
> ![](https://i.imgur.com/s3t3uGk.jpg)


##### Failure Case:
Putting the two images with the light backgrounds makes the combined image overexposed and it is impossible to distinguish the old gentleman's face and the baby's face.

> Elder
> ![](https://i.imgur.com/gQY6YoV.jpg)

> Baby
> ![](https://i.imgur.com/f4sFKJ2.jpg)

> Eldby Hybrid
> ![](https://i.imgur.com/CkR1REd.jpg)


#### 2.3: Gaussian and Laplacian Stacks
I applied a Gaussian and Laplacian stacks to a hybrid of Professor Denero and Professor Hilfinger. This process allows you to see Professor Hilfinger using the Gaussian stack and Professor Denero using the Laplacian stack.

![](https://i.imgur.com/nulmFXD.jpg)![](https://i.imgur.com/8rep194.jpg)![](https://i.imgur.com/W54zOTV.jpg)![](https://i.imgur.com/pSP1dA6.jpg)

![](https://i.imgur.com/M43MUYn.jpg)![](https://i.imgur.com/Otf2H0s.jpg)![](https://i.imgur.com/YJKt18H.jpg)![](https://i.imgur.com/CwL7KcQ.jpg)

![](https://i.imgur.com/WFgDGBq.jpg)![](https://i.imgur.com/RwpiReG.jpg)![](https://i.imgur.com/Rtya3Zk.jpg)![](https://i.imgur.com/PLp9mgC.jpg)
![](https://i.imgur.com/2RTaovD.jpg)![](https://i.imgur.com/nS6dCA8.jpg)![](https://i.imgur.com/x0SGbk2.jpg)![](https://i.imgur.com/OjtIxi2.jpg)


#### 2.4: Multiresolution Blending (a.k.a. the oraple
For this I applied the Laplacian to the two images and then applied the gaussian filter to the mask in order to softens the edges of the mask. Finally, I combined the images and the mask with the following equation: `right[i] * l_im2[i] + left[i] * l_im1[i]`. This resulted in a blending that looks seemless between the two objects.

##### Example
> Orange
> ![](https://i.imgur.com/NI0NhJ3.jpg) 

> Apple
> ![](https://i.imgur.com/U8i84ZC.jpg)

> Oraple Hybrid
> ![](https://i.imgur.com/1a3Jgkf.jpg)

###### Left
![](https://i.imgur.com/wyNJuM6.jpg)![](https://i.imgur.com/ebTiEIq.jpg)![](https://i.imgur.com/KTmKsns.jpg)![](https://i.imgur.com/hUdSIZ5.jpg)![](https://i.imgur.com/dXLdPky.jpg)![](https://i.imgur.com/YxfwpXa.jpg)

###### Right
![](https://i.imgur.com/rBJC7Hu.jpg)![](https://i.imgur.com/nlIELIa.jpg)![](https://i.imgur.com/Y3I5K6F.jpg)![](https://i.imgur.com/1BYb66V.jpg)![](https://i.imgur.com/rGeFdDw.jpg)![](https://i.imgur.com/MIQZtdV.jpg)

###### Combined
![](https://i.imgur.com/haJ0JTo.jpg)![](https://i.imgur.com/8Day0QV.jpg)![](https://i.imgur.com/xnmVNtt.jpg)![](https://i.imgur.com/1QavZw2.jpg)![](https://i.imgur.com/QwxWQn7.jpg)![](https://i.imgur.com/jAjBxyE.jpg)

##### Self Selected Images:
> Dog
> ![](https://i.imgur.com/K9oRVF2.jpg)

> Cat
> ![](https://i.imgur.com/F7rmCIR.jpg)

> Dat Hybrid
> ![](https://i.imgur.com/Qqsa8nK.jpg)

###### Left
![](https://i.imgur.com/uoyKt3d.jpg)![](https://i.imgur.com/8bkEfkF.jpg)![](https://i.imgur.com/UtIExjO.jpg)![](https://i.imgur.com/nIS79ga.jpg)![](https://i.imgur.com/8Dw5j46.jpg)![](https://i.imgur.com/qE9RbPd.jpg)

###### Right
![](https://i.imgur.com/dMMa6bF.jpg)![](https://i.imgur.com/pAZNmeB.jpg)![](https://i.imgur.com/ZfZJqm3.jpg)![](https://i.imgur.com/e5yEhs6.jpg)![](https://i.imgur.com/Lpq6FZs.jpg)![](https://i.imgur.com/Q9IveiU.jpg)

###### Combined
![](https://i.imgur.com/TyRppX4.jpg)![](https://i.imgur.com/mLYXX3s.jpg)![](https://i.imgur.com/JFiCHcL.jpg)![](https://i.imgur.com/Nobt4K7.jpg)![](https://i.imgur.com/dJisBmA.jpg)![](https://i.imgur.com/VckKa3b.jpg)

## Most interesting thing I learned.
I found this project really enjoying even though it took me a long time to complete and there were a lot of setbacks along the way. The one thing I really enjoyed about this project was part 1.3 involving straightening the image. I found this it was really cool to automatically straigthen edges and found the implementation novel but clever.

