Project 2: Fun with Filters and Frequencies!

Part 1: Fun with Filters

Part 1.1: Finite Difference Operator

We compute changes in our image in the x and y direction by convolving them with the following filters Dx = [1,-1], Dy = [1,-1].T:

We can use the result to detect edges by finding the gradient magnitude by taking the L2 norm of the partial derivatives. Choosing a threshold, we binarize the result to magnify edges and eliminate unwanted noise.

Threshold = 0.16

Part 1.2: Derivative of Gaussian (DoG) Filter

Here, we first blur the cameraman image by convolving it with a Gaussian filter. Then, we find the partial derivatives of the blurred image and use that instead to find the gradient magnitude. Observe that through blurring, we avoid picking up a lot of noise and can detect more detail edges by picking a lower threshold compared to the previous method.

Threshold = 9; kernel size = 2; sigma = 0.05

We can obtained the same result by first convolving the Gaussian filter with Dx and Dy separately, then apply this filter without blurring the image. This saves computation since we only convolve with the larger cameraman image once:

Part 2: Fun with Frequencies

Part 2.1: Image "Sharpening"

Sharpening is performed by emphasizing the high frequency component of an image, which captures edges. This is done by first taking an original image and passing it through a Gaussian kernel to created a blurred version. Then, the high frequency component is obtained by subtracting the blurred image from the original. Finally, the sharpened image is made by adding a fraction alpha of the high frequency component to the original.

Kernel size = 9; sigma = 2 ; alpha = 4

Extra images:

Low resolution dog image

High resolution bridge image

Blurred and resharpen image:

Part 2.2: Hybrid Images

We make hybrid images by taking two images, aligning them and passing one through a low-pass filter and the other to a high-pass one. Then the two are added together. This creates a visual illusion where one would see the first image at a distance but as one get closer to the screen, the second image is perceived. This is because far away, our brain sees the low frequency component of an image while nearby we focus on the high frequency component.

sigma_derek = 9; sigma_nutmeg = 8.

Frequency Analysis:

Extra images

Bells & Whistles

To create color hybrid images, both the low-pass and high-pass filter were applied to each color channel. Then a hybrid image is created for each RGB channels, then combined into a color image.

Observe that color works better for low frequency component. Although the high frequency component also displays some color, the effect is more substantial for the low frequency component. Thus, one might want to save on computation by only colorizing the low frequency component.

Part 2.3: Gaussian and Laplacian Stacks

The Gaussian stack is generated by repetitively blurring the image with a Gaussian kernel with increasing sigma at each level. From there, I make the Laplacian stack by subtracting consecutive images in the Gaussian stack. Finally, the last image of the Laplacian stack is taken from the last image of the Gaussian stack. Bellow is the Gaussian and Laplacian stack applied to the Orange and Apple at each level. I will discuss blending the two in the next section. To visualize the Laplacian stack, I first normalize the result.

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

To perform multiresolution blending, I first create the Gaussian and Laplacian stacks for both the left and right component images. This time, a mask applied at each level to block out the other half image. Then, I add the two halves together at each level to create the blended images in column three of Part 2.3. The final blended image is created by adding all levels of the blended images together.

Bells & Whistles

To create color images, I process blending at each level in separate color channels. Then the blended image is combined into a color image to calculate the Laplacian layer. Finally, a mask is applied to the color image.

Extra images

Irregular Mask