Project 2: Filters and Frequencies

CS 194-26: Intro. to Computer Vision & Computational Photography, Fa21

Doyoung Kim


Overview

  In this project, we have discovered how filters and frequency plays a role in image processing. Starting from finite difference operator and gaussian filter, we discover how we can create a edge filter in part 1. Then, we discover how we can use the gaussian filter as a low-band filter to create image sharpening filter followed by blending two different images seamlessly using Laplacian and Gaussian stack.



Part.1 Gaussian filters and finite difference operators


Part. 1.1 Finite Difference Operator

  Using the image above, we apply each of finite difference operator, dx, dy on the cameraman image. Then, I computed the gradient magnitude of the two images filtered by dx and dy. At last, binarization is done on the gradient magnitude, which turns out to be a edge detecting image.

Original
dx filter
result
Original
dy filter
result
Gradient Magnitude
Binarized Gradient Magnitude


Part. 1.2 Derivative of Gaussian(DoG) Filters

  As the results of purely applying the difference operator are quite noisy, we try to apply the gaussian filter on the image first, and then do the same thing as 1.1 to see if the result is less noisy.
On top of that, we want to discover if convolving the gaussian filter with difference operator reserves the property of the gaussian and gives us the same result as the early results where we applied guassian filter on the image first, and then applied difference operator.

  Following images uses the Gaussian filter and dx, dy operators separately on the image.

Original
Cameraman
Gaussian
Filtered
dx operator
on Gaussian
dy operator
on Gaussian
Grad. Mag.
on Gaussian
Binarized Grad.
Mag. on Gaussian


  Following images uses the Gaussian filter that are convolved with dx, dy operators on the image.

Gaussian Filter
Convolved with dx
Gaussian Filter
Convolved with dy
DoG Convolved
dx
DoG Convolved
dy
Dog Convolved
Grad. Mag.
DoG Convolved
Binarized Grad. Mag.



Part.2 Fun with Frequencies!

Part. 2.1 Image "Sharpening"

  Using the Gaussian filter, there is a way to sharpen the image, which makes the higher frequency part of the image more clear. This is doen by extracting the higher frequency part of the image which is done by: orignal image - gaussian filtered image. Then, we add this back to the original image stack up the higher frequency.
 After sharpening the image with separate steps, we can also construct an unsharpen-filter, which sharpens the image with single step. And this filter is constructed as: f+α(f−f∗g)
 The following are the images that sharpening are done separately.

Original
Image
Low Frequency
Part of Image
High Frequency
Part of Image
Sharpened
Image


  The following image is sharpened with the unsharpen-filter in single convolution.

Original
Image
Sharpened
Image


Part. 2.2 Hybrid Images


  In this part of the project, we can discover how human eyes are more sensitive to the high-frequency part of the image when seeing at close, but low-frequency part of the image at distance. We first get two images. And take the only higher frequnecy part of one image, and get lower frequency part of the other image and add them together. This way, we can create an image that shows two different images differeing by the viewer's distance from the image.

 One process necessary before adding the images is to align two images so they look alike.

 Following are some process of creating a hybrid image:

Original
nutmeg
Original
Derek
Aligned
nutmeg
Aligned
Derek
Hybrid
Image


  The hybrid image above is created with the high frequency part of the cat and low frequency part of the person.

  Following are some more examples:

Original
Mars
Original
Apple
Aligned
Mars
Aligned
Apple
Hybrid
Image


  In the following examples, frequency analysis is done. Take a look on how the frequency domain changes.

Original
Cartoon
Original
Tahoe
Aligned
Cartoon
Aligned
Tahoe
Hybrid
Image

Cartoon
Frequency
Tahoe
Frequency
High-band
Cartoon Freq.
Low-band
Tahoe Freq.
Hybrid
Freq.

Part. 2.3 Gaussian and Laplacian Stack


 For part 2.3 and 2.4, we will discover a method to blend two different images seamlessly. As cutting two images into half and putting them together would create a seam between two images, we approach with gaussian and laplacian stacks. Gaussian stack is a stack of gaussian filtered single image, but as we go down the stack, the image is convolved with the gaussian filter again and again. So the 4th image of the stack would have been convolved with the gaussian filter 4 times.

 The idea is similar to the Laplacian stack, however, for Laplacian stack, each image is a subtracion between each stacks from gaussian stack. For example, Laplacian_stack[0] = gaussian_stack[0] - gaussian_stack[1]. This way, Laplancian_stack[0] only contains the image of higher frequency from guassian_stack[0], which is not contained in gaussian_stack[1].

 We also use a mask that allows us to distinguish the regions of two images that are supposed to be blended to each other. And as we are applying gaussian filter to the original images, in order to remove the discrepancy, we also apply the gaussian filter to the masks being used as well for each depth of the stack being created.

 At the end, by adding up all the images from the Laplacian stack creates a well blended image of both images.

 Following are the two images we are trying to blend:

Apple
Orange


 Following are the images from the apple's Gaussian Stack:

Depth 1
Depth 2
Depth 3
Depth 4



 Following are the images from the orange's Gaussian Stack:

Depth 1
Depth 2
Depth 3
Depth 4



 Following are the images from the apple's masked Laplacian Stack:

Depth 1
Depth 2
Depth 3
Depth 4
Depth 5



 Following are the images from the orange's masked Laplacian Stack:

Depth 1
Depth 2
Depth 3
Depth 4
Depth 5



 Following are the images adding the masked Laplacian stacks of apple and orange:

Depth 1
Depth 2
Depth 3
Depth 4



 After adding up all the images from the masked Laplacian Stack, we get the final blended result:

Final
Oraple
     

Part 2.4 Multiresolution Blending



 Following are some of the examples of blended image of my own:

Tahoe + Ocean


Tahoe
Ocean
Filter
Blended!



Yankee Candle + 7 up


7 up
Yankee
Blended!