Fun with Filters and Frequencies

CS 194-26 | Project 2 | Catherine Gee

Part 1: Fun with Filters

Part 1.1: Finite Difference Operator

The gradient magnitude is calculated by taking the square root of the sum squared derivatives (dx, dy). Clearly, this requires calculating the derivative which luckily can be easily done by convolving with the derivative filters. ([1, -1] and it's transpose). I have included all of the images generated of this process.

dx

dy

Gradient magnitude (calculated as written above)

Binarized version of the gradient magnitude

Part 1.2: Derivative of Gaussian (DoG) Filter

We now blur the photo before doing the same as before. The main difference here is that there is less noise when we calculate the gradient magnitude.

2 convolutions: dx

2 convolutions: dy

2 convolutions: Gradient magnitude

2 convolutions: Binarized

1 convolution: dx

1 convolution: dy

1 convolution: Gradient magnitude

1 convolution: Binarized

Part 2: Fun with Frequencies

Part 2.1: Image "Sharpening"

Just for the folks at home who don't know how to sharpen a photo the process is as follows. Take the low frequencies (aka blur it) and subtract this by the original to get the high frequencies. From this add some weighted high frequencies to original and you are chilling.

I actually used the unsharp mask filter which is the following equation (sorry i dont know how to import latex so it's in comic sans). f * ((1+a)e - a g) Where a is alpha, f is the original picture and g is a gaussian kernel and e is the unit impulse

Original

alpha = 1

alpha = 5

alpha = 10

Original

alpha = 1

alpha = 5

alpha = 10

The next part is a blurred photo that is then sharpened. We can see that the results are not as good as the original photo, but much better than some blurry photo.

Original

Blurred original

alpha = 1

alpha = 5

alpha = 10

Part 2.2: Hybrid Images

These are hybrid images. You should look at them from a long distance and then up close. It's cooler that way. As an example, here's Derek and his cat. (Note I also cropped the final results)

See, you can see a cat AND a man!!

Chrissy

Francine

chrissy or francine? (fail -- too similar!!)

Cranston

Flora

Cranston or Flora? (fail for same reason)

Kim Petras at the 2021 Met Gala

Horse (what more can be said?)

Kim Petras or horse?

Fourier Analysis of the Kim Petras Horse photo

The following shows the log magnitude of Fourier transform for some image.

Kim

Horse

Filtered Kim (low)

Filtered Horse (high)

Hybrid

But what about color???

I did this in color for fun, so here's some quick analysis. I personally like when the high frequencies is b&w.

Both color channels are used.

Kim is black and white. (low)

Horse is black at white (high)

Part 2.3: Gaussian and Laplacian Stacks

A Gaussian pyramid is a very nifty thing where you downsample and blur a photo repeatedly. I did not make a pyramid but I did make a stack by blurring some black & white/color image by some gaussian kernel for some N amount of levels. (The kernel sigma is effectively doubled each time since I am blurring an already blurred photo. I could have increased it further but I thought that would be a little overkill.) Below I have an example of a level 3 Gaussian stack in b&w and color.

The Laplacian pyramid is the same except it uses the gaussian pyramid to find the bandpass (mid frequencies). For B&W and color I just calculated the gaussian stack (I did not make any pyramids) and subtracted the next layer in the stack by the current for N levels. I also tried to normalize the pictures because the Laplacian outputs were a little gross looking. Below I have an example of a level 3 Laplacian stack in b&w and color.

Color gaussian 0

Color gaussian 1

Color gaussian 2

B&W gaussian 0

B&W gaussian 1

B&W gaussian 2

Color Laplacian 0

Color Laplacian 1

Color Laplacian 2

B&W Laplacian 0

B&W Laplacian 1

B&W Laplacian 2

Recreate history (figure 3.42)

This is part of a whole oraple thing, we'll get to specifics later. Also I got left and right mixed up but just ignore that

Laplacian 0 left image with mask

Laplacian 0 right image with mask

Laplacian 0 blended

Laplacian 1 left image with mask

Laplacian 1 right image with mask

Laplacian 1 blended

Laplacian 2 left image with mask

Laplacian 2 right image with mask

Laplacian 2 blended

Laplacian 3 left image with mask

Laplacian 3 right image with mask

Laplacian 3 blended

Laplacian 4 left image with mask

Laplacian 4 right image with mask

Laplacian 4 blended

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

WE HAVE MADE IT!!! Now we are going to blend 2 photos together. For regular credit there is a black and white oraple but also a color one because it is much cooler.

The fated oraple!!

The fated oraple in COLOR!!

Here are some funny blends I made :-)

He's never looked better

I'm going to show the Laplacian for this next one.

Troy

Windows Xp Bliss

mask

Laplacian 0 xp image with mask

Laplacian 0 troy image with mask

Laplacian 0 blended

Laplacian 1 xp image with mask

Laplacian 1 troy image with mask

Laplacian 1 blended

Laplacian 2 xp image with mask

Laplacian 2 troy image with mask

Laplacian 2 blended

Laplacian 3 xp image with mask

Laplacian 3 troy image with mask

Laplacian 3 blended

Laplacian 4 xp image with mask

Laplacian 4 troy image with mask

Laplacian 4 blended

finally... Troy Bolton on the windows xp screen

The most important thing I learnt this project was that working with frequencies wasn't boring. It was super fun to make all of these pictures! I am a lot better at debugging visually now too ): I also think I understand convolution now. (The verdict is out on that one though.)

Image of Troy from the disney channel; All animal crossing full body images (flora, chrissy, francine, cranston) from here; horse picture from here kim petras photo from pitchfork's coverage of the Met Gala; oski from californiagoldenblogs (i did the painting though)

AND THAT'S IT FOLKS!!