Project: Fun with Filters and Frequencies

Part 1: Fun with Filters

Part 1.1 Finite Difference Operator

In this section, we use two different operators to calculate the gradient in the x and y directions. We convolve the image with these operators and binarize the gradient magnitude, which can be expressed as sqrt(dx ^ 2 + dy ^ 2)).

Image

Part 1.2 Derivative of Gaussian Filter

In this section, we first apply a Gaussian filter before calculating the gradient using the x and y operators. We create the 2D Gaussian filter by taking the outer product of a 1D Gaussian with its transpose.

In the image below, we can see that the edge image after applying the Gaussian blur is smoother. This is because applying the blur first helps filter out noise in the gradient.

Image

The image below serves as a verification. We create the derivative of Gaussian filters, and it produces the same result.

Image

Part 2: Fun with Frequencies

Part 2.1 Image Sharpening

In this section, to extract the high-frequency signals, we subtract the Gaussian-blurred image from the original image. Here are the results we received:

We experimented with different lambda values—higher lambda places more weight on the high-frequency signals, resulting in a sharper image.

ImageImageImage

In addition, we also attempted to recover a sharp image from a blurred cat image, and here are the results:

Image

In this example, we can see that our algorithm successfully recovers the high-frequency information from the blurry image, making it similar to the original image.

Part 2.2 Hybrid Images

Image

Image

Image

Above: corresponding frequency visualization of the hybrid images for cats and dogs

Image

In rare failure cases, like the one above where we attempted to blend the goldfish with the cat, the issue arises from not filtering the low-frequency components enough. Implementing dynamic parameter adjustments could improve the results.

Part 2.3 Gaussian and Laplacian Stacks

Image

In the image above, both the Gaussian and Laplacian stacks are shown. We recursively apply the Gaussian filter to build the Gaussian stack, so as the levels go deeper, the stack contains more low-frequency signals. The Laplacian stack, on the other hand, is simply the difference between consecutive levels of the Gaussian stack

Part 2.4 Multiresolution Blending

We create a mask that vertically separates the frame. To ensure a smooth transition, we apply a Gaussian kernel to the mask. After merging all the Laplacian frames, we simply add them together to produce the final result.

Image

Here's are few other examples (the first one is iregular mask):

Image

Image