Project 2: Fun with Filters and Frequencies!

CS 194-26 Fall 2021

Bhuvan Basireddy



Overview

The goal of this project was to have fun creating filters for edge detection and sharpening. We also create hybrid images and blended images together.

Finite Difference Operator

To find the partial derivatives with respect to x and y for the image, we convolve the image with finite difference operators D_x and D_y. Then, we found the gradient magnitude by summing the squares of the partial derivatives and taking the square root of that sum. To binarize the image, we use a threshold to get rid of noise while keeping the actual edges.
Partial derivative in x
Partial derivative in y
Gradient Magnitude
After Thresholding

Derivative of Gaussian Filter

A lot of the noise from before is removed by using the Gaussian filter, and we are mostly left with the real edges. We have 2 approaches with the Gaussian. We can either convolve the Gaussian with the image first, then Dx and Dy, or we can convolve the Gaussian with Dx and Dy first, then apply this to the image at the end. The difference here is that there is less noise after applying the Gaussian, and edges are thicker and more defined. As I show below, both approaches result in the same image at the end.
Gaussian convolved with Dx
Gaussian convolved with Dy
Image convolved with above
Image convolved with above
Gradient magnitude
Convolved image with gaussian first
Convolved gaussian with Dx, Dy first

Image Sharpening

To sharpen an image, we subtract a blurred version of the image (containing the low frequencies) from the image, so we can retain the higher frequencies and remove these lower frequencies. This is achieved by subtracting the Gaussian filter from the identity filter and convolving the resulting filter with the image to get the mask filter, which can be added to the original image to get a sharpened image.
Original Image
Blurred Original Image
Sharpened Blurred Image

Sharpening the blurred image results in a better image compared to the blurred image, but it is still blurrier than the original image.

Hybrid Images

First, we align the images together. Then, we get the low frequencies from one image by convolving with a Gaussian filter, and we get the high frequencies of the other iamge by convolving the image with a Gaussian and subtracting this from the original image. Then, we combine the high and low frequencies to get our hybrid image. The idea is that frequencies we perceive change as distance to an image changes, so the image changes as we vary our distance from it.
Cat Man Hybrid
Blue Spirit
Zuko
Hybrid
Momo
Aang
Hybrid (Failure)

Fourier Analysis of Blue Spirit Zuko

Blue Spirit
Zuko
Blue Spirit (Filtered)
Zuko (Filtered)
Hybrid

Gaussian and Laplacian Stacks

We create the Gaussian stack by repeatedly using the Gaussian filter on the image, doubling the sigma value at each subsequent level, and storing these blurred images to a stack. We create the Laplacian stack by subtracting consecutive levels in the Gaussian stack with the last level of the Laplacian being the last level of the Gaussian.

Multiresolution Blending

We do the multiresolution blending using the Laplacian and Gaussian stacks from the previous part. We create 2 Laplacian stacks for the 2 images that we're blending and create a Gaussian stack for the mask. For each level in the stacks, we combine the stacks by doing a weighted sum on the 2 Laplacians using the Gaussian (LS = G * LA1 + (1-G) * LA2). Then, we add all the levels in the combined stack to get our blended image. The irregular mask is applied to the tiger and sun below. I used color to enhance the images.
Gray Oraple
Color Oraple
Anakin
Darth Vader
Blended
Irregular Mask for below images
Tiger
Sun
Blended

Laplacian stack of Tiger performing Hyper Beam


The most important thing that I learned is the usefulness of the Gaussian filter in playing with frequencies and manipulating images.