0%

### Part 1: Fun with Filters

#### How gradient magnitude computation works

First, we calculate the partial derivative $dx$ and $dy$ respectively in x and y direction of the cameraman image by convolving the image with finite difference operators D_x and D_y. Then we take square sum of the two derivatives to get the gradient magnitude image, using the fomula $\sqrt[]{dx^2 + dy^2}$. #### Part 1.2: Derivative of Gaussian (DoG) Filter

We noted that the results with just the difference operator were rather noisy. Thus by convolving with a 2d gaussian, I created a blurred version of the original image and repeated the same thing as the previsous part.

### What differences do you see?

Comparing gradient magnitude images, I noticed that after gausssian, there is less noice (for example, fewer dots in the lower half the image), but the borders are thicker/more blurred because we are using a low pass filter and each pixel contains information from neighboring ones.

Also, instead of convolving the image with a 2d gaussian and getting the partial derivatives (method 1), we can first take the x y derivatives of the gaussian kernel and then apply those two derivative of kernals to the image(method 2). The two methods give same result.

#### Verify same result

method 1 method 2  #### Part 1.3: Image Straightening

Since human beings have a preference for vertical and horizontal edges in most images. I coded up an algorithm trying to rotate the image so as to maximize the number of vertical and horizontal edges.

First, I proposed a range of angles. Then, I rotated the image by the proposed angle, used $arctan(dy/dx)$ to get the gradient degrees for the rotated image, graphed a histogram, and counted sum of horizontal and vertical edges. After iterating over the proposed set of angles, and pick the angle that produces the highest number of edges to straighten the image. The first four look quite good. However, my algorithm failed on the fifth one. Looking into the reasons, I think human (at least me) care more about the straightness of the water pipe, since the wall is mainly a background. However, the algorithm accounts both the water pipe and the lines on the wall.

### Part 2: Fun with Frequencies!

#### Part 2.1: Image “Sharpening”

We can make an image looks sharper by adding more high frequency to it. Specifically, we subtract the blurred version from the original image to get the high frequencies of the image, add the difference back to the original image (scaled by alpha). For evaluation, I also picked a sharp image (taken at Amazon), blur it and then try to sharpen it again. Observing the images below, we may notice that the sharpened image is sharper than the blurred one, but still not as good as the original. After all, blurring takes away information from the original image.

#### original vs blurred vs sharpened #### Extra images  #### Part 2.2: Hybrid Images

Low-pass filter (implemented with gaussian) is the part we see far apart and the high-pass one (implemented by substracting low pass from the original) is what we see closely. Hybrid image is created by summing up low-pass and high-pass.

Below are a few hybrid images.

nutmeg Derek hybrid 1 (nutmeg of derek)   big cat little cat hybrid 2 (big cat or little cat)   eat not eat hybrid 3 (Eating or not)   #### failure example #### Fourier analysis

The fourier analysis show how hybrid images works in the frequency domain.

The big cat passes through a low-pass filter and gets rid of much high frequency. The little cat passes through a high-pass filter and only keeps high frequency. The frequency distribution of the hybrid image look similar to the two original images, since low and high frequencies both exist in the hybrid images.

Show the log magnitude of the Fourier transform of the two input images, the filtered images, and the hybrid image.  #### Part 2.3: Gaussian and Laplacian Stacks

Gaussian stack is generated by repeating convolving with gaussian while a Laplacian stack is generated by subtracting two layers of gaussian stacks.

I applied my Gausssian and Laplacian stacks to Mona Lisa. Please find the result beneath. #### Part 2.4: Multiresolution Blending (a.k.a. the oraple!)

For this part, I blended two images seamlessly using a multi resolution blending as described in the 1983 paper by Burt and Adelson. An image spline is a smooth seam joining two image together by gently distorting them. Multiresolution blending computes a gentle seam between the two images seperately at each band of image frequencies, resulting in a much smoother seam.

There are a few examples.

image1 image2 oraple   image1 image2 blended   image1 image2 blended    