CS 180: Computer Vision and Computational Photography, Fall 2024

Project 2: Fun with Filters and Frequencies!

Zackary Oon



Overview

In this project, we deal with finite difference operators and Derivative of Gaussian Filters (DoG) to do edge detection. Then, we deal with image sharpening, hybrid images, and multiresolution blending. The most important thing I learned from this project was how algorithms could be. For example, the multi-resolution blending works well with the apple and orange images given, but for other images, you have to really choose carefully, else the seam colors either don't blend well, the images are offset (even with alignment) due to different object dimensions, etc.

Part 1: Fun with Filters

Part 1.1: Finite Difference Operator

Here we use the finite difference operators (a vector of 1 and -1, of dimension 2x1 for Dx and 1x2 for Dy) and convolve them with the cameraman image, to view the partial derivative in the x and y directions of the cameraman image. With these, we then obtain a gradient magnitude image by adding the magnitudes squared, of the gradient values in the Dx and Dy images, then taking the square root.
dx_cameraman

Cameraman's partial derivative in the x direction

dy_cameraman

Cameraman's partial derivative in the y direction

Gradient Magnitude

Gradient magnitude of Cameraman image

Part 1.2: Derivative of Gaussian (DoG)

The edges are thicker in this part, compared to 1.1. With this gaussian blurring step, there's less noise in the edge image, and it doesn't sacrifice the edge visibilty. Note that the difference between these two images is on the left, we run a gaussian blur, then do what was described in part 1, and on the right, we do convolution between the Dx with the Gaussian Kernel, and Dy with the Gaussian Kernel, then convolve that with the cameraman image.
Blurred Edge Cameraman

Blurred edge of Cameraman image

DoG Edge Cameraman

DoG edge detection on Cameraman image


Part 2: Fun with Frequencies!

Part 2.1: Image "Sharpening"

Here, we extract the higher frequencies by doing the original image - the low pass filtered image. Then, we multiply the high frequency image by some alpha value (in our case, 2), and add that to the original image to obtain a sharpened image.
Original Taj Mahal

Original Taj Mahal

Sharpened Taj Mahal

Sharpened Taj Mahal

Original Breath of the Wild

Original Breath of the Wild

Sharpened Breath of the Wild

Sharpened Breath of the Wild

Part 2.2: Hybrid Images

Here, we have two images, one that is designated to contain mainly its high frequencies and the other containing its low frequencies. We then add them. The higher frequencies are more prominent upclose, and the lower frequencies are more prominent farther away, giving us the impression of a hybrid image. Note the failed 3rd example, as the positions are different, which tells us that this approach doesn't work well to show displacement between images.

Note that the first image is the lower frequency image, and the second image is the higher frequency image.
Grouper

Grouper

Goldfish

Goldfish

Hybrid Grouper and Goldfish

Hybrid of Grouper and Goldfish

Apple

Apple

Orange

Orange

Hybrid Apple and Orange

Hybrid of Apple and Orange

Sprint Start

Sprint Start

Sprint Continue

Sprint Continue

Hybrid Sprint Start and Continue

Hybrid of Sprint Start and Continue (failed example)

Log Magnitude Fourier Plots

This is the log magnitude fourier plots of the 1st example (the fishes).
Hybrid Fourier

Hybrid Image Fourier Transform

Grouper Fourier

Grouper Image Fourier Transform

Goldfish Fourier

Goldfish Image Fourier Transform

Part 2.3 and 2.4 Gaussian and Laplacian Stacks and Multi-Resolution Blending

Here, we make suse of gaussian and laplacian stacks (like the pyramids, but rather than subsampling, we just keep it the same size). Note that gaussian stacks show the cumulative blurring of the image as we go further and further, while the laplacian stack shows the difference between the current level and its next level. We generate these stacks for the two images and the to be applied. To finally combine them, you just need to combine the laplacian stacks of the images using the weighting given by the mask's gaussian stacks. Finally, given the intermediate blended images at each level, add them up for the final result.

Note that the cats don't seem to blend as well as expected due to their head size being different. I decided to keep this in since it displays how the multi-resolution blending requires very curated iamges (even if the two objects/things are already similar)
Apple

Apple

Orange

Orange

Gaussian Stack Gallery

Gaussian Stack Gallery

Laplacian Stack Gallery

Laplacian Stack Gallery

Blended Apple and Orange

Blended Apple and Orange (Orapple)

Orange Cat

Orange Cat

Brown Cat

Brown Cat

Blended Cat

Blended Orange and Brown Cat

Blended Cat Gallery

Blended Cat Gallery

Vaporeon

Vaporeon

Water Bottle

Water Bottle

Blended Vaporeon and Water Bottle

Blended Vaporeon and Water Bottle