CS194-26 Project 2: Fun with Filters and Frequencies

Overview:
This time we'll be messing with the image frequencies and applying filters such as gaussian and laplacian filters, derivative of gaussian filters, etc.
Each of these filters have their uses, such as line detection, blurring, sharpening, and even image merging.
Lets put these techniques to use!

Part 1.1: Finite Difference Operator:
Lets make an edge outline image using 1-D differentiator filter!
Lets start with the base cameraman image:
Cameraman
First, we show the partial derivative in x and y of the cameraman image by convolving the image with finite difference operators D_x [0, 1] and D_y [0, 1].T
i
Now, we compute and show the gradient magnitude image, by taking the camera convolved with D_x, squaring it, adding it to the camera convolved with D_y squared, then taking the square root:
i
Finally, we turn this into an edge image by binarizing the gradient magnitude image using the threshold 0.1 (if x > .1, x = 1, else 0)
i

Part 1.2: Derivative of Gaussian (DoG) Filter
Lets repeat the same thing as the part above, but this time using the Derivative of the Gaussian as our filter.
Lets start (again) with the base cameraman image:
Italian Trulli
We'll create a blurred version of the original image by convolving with a gaussian and repeat the procedure in the previous part, and create a blurry mask, using a threshold of 20
Italian Trulli
Now, we'll try with a single convolution instead of two by creating out very own derivative of gaussian filters!
Italian Trulli
What are the differences? We can see that the first filter has the lines depicted independently, and has some noise from the grassy background.
The DoG filter is smoother on the lines, yet also has more sharp lines, as they are closer together and more pronounced.

Part 2.1: Image "Sharpening"
Now, we'll try sharpening images, or making the edges more pronounced. Using a highpass filter, we can amplify higher frequencies such as edges and spots since these features change quickly, ero, higher frequencies. We can amplify these frequencies by subtracting low frequencies (via a gaussian blur) and using the resulting image.
Here is the taj (left) and sharpened taj (right):
Italian Trulli
Here is the another image, one of a baby (left) and sharpened baby (right):
Italian Trulli
Another image, one of a dog (left) and the sharpened dog (right):
Italian Trulli
As an experiment, lets take a sharp image, blur it, then resharpen it:
Italian Trulli
The insect has been sharpened, but now has features that aren't present in the original. It's over sharpened to the point that the lines on the leaf (surface) are being warped and not in a circular fashion.

Part 2.2: Hybrid Images
Using the approach in the SIGGRAPH 2006 paper by Oliva, Torralba, and Schyns, we can create hybrid images, that can be two different images, varying based on where you view them from.
Lets start with Derek and his cat nutmeg:
Italian TrulliItalian Trulli
Italian Trulli
Next, we'll use an image of the Chinese Yuan and an image of a Doge (Because I have these images saved on my computer, not for any political reasons I swear)
Italian TrulliItalian Trulli
Italian Trulli
We'll go next to see a classic emoji and a custom emoji, and try to see both at the same time!
Italian TrulliItalian Trulli
Italian Trulli
For the emoji image, lets see the FFT spectrums for the images, their blurred masks, and the combine image:
Italian Trulli
Finally, lets see why another emoji image failed: it looks like the lack of eyes in the infamous laughing tears emoji doesn't allow our eyes to differentiate between the two images whether close by or far away.
Italian TrulliItalian Trulli
Italian Trulli
This has been an interesting experiment in hybrid images, which look different from different distances!

Part 2.3: Gaussian and Laplacian Stacks
Now lets create a gaussian and laplacian stacks!
We Create Gaussian Stacks first, then use the gaussian stacks to make laplacian stacks by subtracting the image from the gaussian stacks. Here's what the laplacian stack looks like for the oraple:
Italian Trulli
We also need a mask thats blurred to have a smooth blending:
Italian Trulli
Here's the oraple:
Italian Trulli
And Here's the Oraple's laplacian stack of black and white:
Italian Trulli

Part 2.4: Multiresolution Blending (a.k.a. the oraple!)
Now that we've done the oraple (technically an appange, but ok):
Italian Trulli
Taking a two images of cups (both of which are rolled for matching, as evidence of the glass above)
Italian TrulliItalian Trulli
Take a look at this cup blend!

Italian Trulli
Next, we have a blend of two interestingly similar characters ...
Italian TrulliItalian Trulli

Italian Trulli
Here is the mask: it's a square block mask that shows only the part of the images containing the eye. These images were also resized to have the same size. I also had to align the images slightly by rolling.
Italian Trulli