CS194-26 Project 2: Fun with Filters and Frequencies! (Ujjaini Mukhopadhyay)

Part 1: Fun with Filters

Part 1.1: Finite Difference Operator

Gradient Magnitude Computation

Gradient Magnitude Computation is integral to edge finding. To compute the gradient, we can use can use a convolution with horizontal/vertical filters (depending on direction) of [1, -1]. Finding the magnitude allows us to understand how big the slope is. To do so, I take the matrix muliplication of the two gradients with each other and take a square root of that value. Here is the partial derivative in X and Y:
Gradient in X
Gradient in Y
Here is the magnitude and binarized magnitude by setting the threshold at 0.23:
Magnitude
Binarized Magnitude

Part 1.2: Derivative of Gaussian (DoG) Filter

Instead, we blur the image before applying a the convolutions of the derivative and binarizing. Here are the results:
Blurred
Applying Derivative Filters And Binarizing
We can also combine the blurring to the derivative filters and only do one convolution. They provide almost exact same results:
In One Step
Here we see that the edges are much clearer and bolder as opposed to the non-blurred version above. The following are the DoG filters as images:
X Filter
Y Filter

Part 2: Fun with Frequencies!

Part 2.1: Image "Sharpening"

Here we focus on Image Sharpening -- however, how sharp the image becomes depends on alpha. Making alpha too big will result in an unrealistic image as shown below:
Original
Sharpened with Alpha=5 and filter_size=3
Here is an example of oversharpening:
Original
Sharpened with Alpha=1 and filter_size=3
Sharpened with Alpha=5 and filter_size=3
Here is another example image where we will attempt to blur and re-sharpen:
Original
Blurred
Sharpened with Alpha=4 and filter_size=3

Part 2.2: Hybrid Images

Hybrid images contain a mashup of two or more images filtered at different frequencies so that with distance, the image appears different to the human eye. This is evidenced by the contrast sensitivity curve which shows us that certain frequencies are not comprehensible by the human brain. These frequencies change with distance, thus giving the appearance of a hybrid image. Here is the given example:
Low Pass
High Pass
A Man
Or a Cat?
Here are some of my results for this part:
Low Pass
High Pass
Go Bears!
Go Bears!
Here is a fail. This probably didn't work because alignment didn't really exist and teh frequencies are pretty close together.
Orange Slice
Lion
This is not a good hybrid image.
Here is how the image is developed with another example:
I start with this picture of one of my closest friends (Priyanka).
Priyanka!
Thus it has the following Fourier frequencies:
Priyanka's Freqiencies
I put it through a Low Pass filter to create the following image and frequencies:
Priyanka, but blurred with Low Pass Filter
Her new frequencies!
I then load in this picture of myself which I will run a High Pass Filter through:
That's me!
Thus it has the following Fourier frequencies:
My Frequencies!
I put it through a Low Pass filter to create the following image and frequencies:
After filtering for high-pass!
My new frequencies!
Then I can put them together to create the following picture and frequencies:
Ok, we look similar, right?
I'm convinced!
Here are the hybrid frequencies!

Bells and Whistles: Color

By computing the convolution once for every channel and stacking them at the end, I'm able to play with hybrid images in color. Of course, this is more difficult, because the colors now have to match up.
Colored Image

Multi-resolution Blending and the Oraple journey

Part 2.3: Gaussian and Laplacian Stacks

By creating Laplacian stacks and a guassian blur for the mask, we can create the following grayscale image:
Grayscale Blend

Bells and Whistles: Color

If we do the same manipulations but this time three times (once for every color channel), we can do the same blending in the color space.
Sample photo Sample photo Sample photo Sample photo Sample photo Sample photo Sample photo Sample photo Sample photo Sample photo Sample photo Sample photo

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

Together this creates:
Orapple!
This is a significant difference from
Grayscale Blend
Applying different kinds of masks with different images, we can see:
San Francisco!
New York
"From Sea to Shining Sea"
We can also apply a circular mask:
Orange Slice
Lion
"Am I going to eat the orange or will the orange eat me?"
Especially in the last picture, we see how using color allows us to create more interesting photos, and while the blend on the grayscale is perhaps easier to achieve, especially when two images are two different colors (see "From Sea to Shining Sea"), the effect is definitely not as satisfying. Through this project, I learned a lot about picking compatible images to make creative blends or hybrids