194 Project 2: Fun with Filters and Frequencies!

Part 1: Fun with Filters

Part 1.1: Finite Difference Operator

In this part we attempted to identify edges by using the finite difference as our filter. These filters were then convolved on our cameraman image. The resulting 2 images were squared and summed then squarerooted. The final image was then binarized with a empirically tested threshhold of 0.14.
Original:
Italian Trulli
Dx and Dy convolutions:
Italian Trulli Italian Trulli
Result:
Italian Trulli

Part 1.2: Derivative of Gaussian (DoG) Filter

In this next part we applied to a guassian filter (size 15, sigma 3) first to reduce noise in the image:
Italian Trulli
I noticed that the edges are much sharper in the DoG filter around the person (it made them much thicker). It also elimated all the noisy edges from the sky and the grass.
After Combining Filters (DoG filters):
Italian Trulli Italian Trulli
Result after applying filter (Same as before!):
Italian Trulli

Part 1.3: Image Straightening

In this next part we attempted to straighten images based on their gradient angles. We tested various orientations of images to find one that maximized the number of vertical and horizontal lines. To detect edges we once again used the DoG filters from the step before (size 15, sigma 3) to calculate the gradient angles. These values were then used by minimizing the average angle deviation from a multiple of 90 degrees, rewarding horizontal and vertical lines and punishing diagonal ones.

Results and Angle Histograms(Before, After):

Provided Images:
Italian Trulli Italian Trulli
Italian Trulli Italian Trulli
Custom Images:
Italian Trulli Italian Trulli
Italian Trulli Italian Trulli

Italian Trulli Italian Trulli
Italian Trulli Italian Trulli

Italian Trulli Italian Trulli
Italian Trulli Italian Trulli

Failure Case:
I tried to use a dark image with lots of confusing lines to mess up the straightening process. As you can see below the image despite alright being properly aligned, rotated the image to align the rings around the bridge.
Italian Trulli Italian Trulli
Italian Trulli Italian Trulli

Part 2: Fun with Frequencies!

Part 2.1: Image "Sharpening"

In this section we hoped to sharpen images by amplifying the high frequency signals. This was gone by subtracting the low frequncy image (gaussian filter size 5 , sigma 3) and adding the resulting image back to the original picture. Various alpha paramters were tested for different images for optimal sharpening ranging from (0,5)>
Results
Taj Mahal (Alpha 1.8):
Italian Trulli Italian Trulli
Sagrada Familia (Alpha 1.5):
Italian Trulli Italian Trulli

Mountain (Alpha 3):
Italian Trulli Italian Trulli

Blurred Image:
In this section I blurred an image with a gaussian filter to see if I could recover it. I used a gaussian filter of size 5 and sigma 1.
Original

Blurred

Sharpened (Alpha 1.4)

Part 2.2: Hybrid Images

In this sections we hope to combine images by taking the high frequncy data from one image and layering it on the low frequncy data from another. Through this process we hope to see one image up close and one from afar.
Sample:
Cat

Person

Cat Person!

Cusom Images:
Trump

Biden

Biden-Trump!




Rabbit

Duck

Duck-Rabbit!

Inspiration

Below are the log magnitude plots of the fourier transform for the combination:
Rabbit

Duck

Combined

Part 2.3: Gaussian and Laplacian Stacks

In this section we hoped to see information at different frequencies through the gaussian and laplacian stacks. In my implementation I convolved the image with a gaussian filter of size 30 and sigma 1 with the image, then repeated the process with double the previous sigma at every stage.

Lincoln Test Image

Gaussian Stack:
Original

Layer 1

Layer 2

Layer 3

Layer 4

Layer 5

Laplacian Stack:
Original

Layer 1

Layer 2

Layer 3

Layer 4

Layer 5

Rabbit Duck from previous section:

As you can see below with the application of guassian stack the duck slowly becomes more visible. In the Laplacian stack the Rabbit slowly becomes more visible!
Gaussian Stack:
Original

Layer 1

Layer 2

Layer 3

Layer 4

Layer 5

Laplacian Stack:
Original

Layer 1

Layer 2

Layer 3

Layer 4

Layer 5

Part 2.4: Multiresolution Blending

In this section we use the Guassian and Laplacian Stacks from the previous part to blend two images in to one! I used a stack of size 5 and filters of size 50 for all images in this part.
Sample:
Apple

Orange

Mask

Apple-Orange!

Custom:
Ocean

Eiffel tower

Mask

Stranded Beacon (Global Warming/Paris Treaty)

Non Linear:
Trump

Biden

Mask

Biden-Trump

How it was made:
Layer 1

Layer 2

Layer 3

Layer 4

Layer 4


Layer 1

Layer 2

Layer 3

Layer 4

Layer 4


Original

Layer 1

Layer 2

Layer 3

Layer 4


Bell and Whistles Attempt:

Most exciting thing I learned:

I really enjoyed learning how to play around with image frequencies and stick them together in interesting ways without having to use anything black-box like deep learning. I thought it was really cool how you could sharpen an image with no other information, and straighten an image so well with just edge information. Also how easy it is to stitch images together is really neat, but also scary!