CS 180 Project 2

Finite Difference Operator

The finite difference kernel was used in the x and y directions to find the partial derivatives with respect to x and y. Those results were then treated as a 2D vector, and its magnitude was produced by finding its L2 norm. We then In other words, if the image was denoted by , its gradient/edges, , is computed by

Then we threshold this value to remove as much noise as possible without compromising the true edges.

thresholded
Pasted image 20240926233910.png Pasted image 20240926233915.png Pasted image 20240926233925.png Pasted image 20240926234359.png

Derivative of Gaussian Filter

Since the image is still somewhat noisy, smoothing/blurring the image prior to convolving with the finite difference kernel helps remove some of that noise. Essentially, given a gaussian kernel , we have

Because convolution is associative, we can either:

  1. Apply the gaussian filter to the image and then find the gradients of the blurred image
  2. Compute the derivative of the gaussian (DoG) by convolving the finite difference operators with the gaussian filter. Then, we can directly convolve the DoG filter to the image.
    The results are as follows:
Approach 1 Approach 2
Pasted image 20240927231645.png Pasted image 20240927231844.png
Pasted image 20240927231821.png Pasted image 20240927231858.png

Notice that the results are less noisy, and produce practically identical.

Image "Sharpening"

The approach is to filter the high frequency values, and emphasize them by "adding" it to the original image. To find the high frequency values, we compute details = image - blurred, and thus our result becomes image + alpha * details, where alpha is a tunable constant. This can be computed by performing a single convolution. If we denote as the identity convolution (an odd kernel with all zeros except for the center element being 1).

Taj Mahal

Original
Pasted image 20240927234727.png Pasted image 20240927234802.png Pasted image 20240927234848.png

The details of the tiles and path are much more prominent in the case, and overemphasized in the case.

Original
Pasted image 20240927235241.png Pasted image 20240927235300.png Pasted image 20240927235329.png

Again, here we can see that the mountain's features are more visible.

Resharpening a Blurred Image

Taking the image of the pyramids, I blurred it to see if the process could add back in some of the details lost in the process.

Original Blurred Reconstructed
Pasted image 20240927235837.png Pasted image 20240927235853.png Pasted image 20240927235950.png

The reconstructed image has quite a few artifacts since a lot of the finer details are lost to the blurring process. However, most of the features aren't washed away, unlike the blurred image.

Hybrid Images

To achieve a blurred image, I overlayed a low frequency and high frequency image. The low frequency image was produced by applying a gaussian blur. For the high frequency image, I took the difference between the original image and a blurred image.

Superman

I utilized a sigma of 12 for the low frequency and 6 for the high frequency.

Original Superman
Pasted image 20240929191636.png
Original Clark Kent
Pasted image 20240929191652.png
Low Pass Superman
Pasted image 20240929191706.png
High Pass Clark Kent
Pasted image 20240929191713.png

Pasted image 20240929191741.png

These are the Fourier transforms of each step of the process

Original Superman
Pasted image 20240929191833.png
Original Clark Kent
Pasted image 20240929191850.png
Low Pass
Pasted image 20240929191840.png
High Pass
Pasted image 20240929191914.png

Pasted image 20240929192123.png

Failure

This set of images just didn't seem to work since the retro Mario was much larger than the modern Mario. As such, a lot of the details got washed away in the background.

Pasted image 20240930232334.png Pasted image 20240930232346.png Pasted image 20240930232359.png

Multiresolution Blending

Each level of the Gaussian stack is produced by blurring the previous level. The Laplacian stack is formed by taking differences of adjacent layers of the Gaussian stack. The last layer of the Gaussian stack is appended to the end of the Laplacian stack, so both end up with the same number of layers.

Pictured are layers 0, 2, and 4 of each layer of the Laplacian stack.

Pasted image 20240930232834.png Pasted image 20240930232841.png Pasted image 20240930232847.png
Pasted image 20240930232857.png Pasted image 20240930232911.png Pasted image 20240930232927.png
Pasted image 20240930232938.png Pasted image 20240930232942.png Pasted image 20240930233017.png

End Result - Oraple:
Pasted image 20240930233214.png

Duck in the city:

Pasted image 20240930235239.png Pasted image 20240930235248.png Pasted image 20240930235253.png

Result:
Pasted image 20240930235321.png

Purr-fect Conefection

Pasted image 20241001171555.png Pasted image 20241001171545.png Pasted image 20241001171536.png

Result:
Pasted image 20241001171524.png