Fun with Filters and Frequencies!

By Joshua Levine

Fun with filters

In this section, after some experimentation, I decided to use kernel_size=6*sigma for each Gaussian kernel

Finite Difference Operator

In this section, I convolved the image with the finite difference operators. The convolutions with D_x and D_y, respectively, are shown below.

cm_dx cm_dy

Below are the gradient magnitude and edge images. The former was computed by taking the magnitude of the gradient (the euclidean norm of the image), and the latter by binarizing the gradient magnitude image with a threshold of 0.02, which was chosen after plenty of experimentation. Note that the pixel values were between 0 and 1 rather than 0 and 255. I decided that sigma=2 produced the best results.

cm cm

Derivative of Gaussian Filter

In this section, I produced improved versions of the results in the previous part. This was done by convolving the gaussian with D_x and D_y, respectively. The resulting filters are shown below.

D_x and D_y

cm_dx cm_dy

Magnitude and edge images

cm cm

Filters using D_x and D_y, respectively:

cm cm

I decided that sigma=2 produced the best results for this part.

The implementation in this part worked much better than the previous part. The magnitude image is less noisy, so the edge image is much more accurate, capturing more edges, and less noise.

When I switched to using just one convolution, the results were the same as the original way this part was implemented.

Sharpening

In order to sharpen images, we blur the image using a gaussian filter, then subtract the blurred image from the original. The first image was sharpened using a gaussian with sigma=1, and the second two with sigma=3. The results are shown below:

cm cm

For the following image of Luciano Pavarotti, I first blurred then sharpened it. Below are the original, blurred, and sharpened images, respectively.

cm cm cm

Fun with Frequencies

In this part, after much experimentation, I decided to use kernel_size=min(2 * sigma1, 40) - 1 to improve runtime without sacrificing too much quality.

Hybrid Images

In this section, I produced hybrid images by aligning two images and using a low-pass filter to get the low-frequency portion of one image, and a high-pass filter to get the high-frequency portion of another. I then added the two images together to get a hybrid. In this part, I struggled to find images that worked well together. I realized that it was best to choose images that were somewhat similar, to begin with, so that the alignment would look good. It also took some experimentation to settle on good sigma values for the filters, but I settled on sigma=5.

For some hybrids, I also included color from both images. I found that this works better than only using color from one. I implemented color hybrid images by applying the process described above to each color channel. The results are shown below, along with the 2D Fourier transforms for my favorite hybrid image

Derek and Nutmeg (vertical mask):

cm cm cm cm

Bulldog and Koala:

cm cm cm cm

pavarotti and verdi:

cm cm cm

Steve and Erlich (my favorite pair):

cm cm cm cm

Below are the 2D Fourier transforms of each image, shown as images.

Image 1

cm

Image 2

cm

Below are the Low, High, and Hybrid 2D Fourier transforms, respectively, as images, of my favorite pair.

Low

cm

high

cm

hybrid

cm

singing and pavarotti (failure):

cm cm cm

The last image is a failure. That is likely because the colors in the backgrounds were too similar to the colors in the foregrounds of each image. It also didn’t align very well, likely because the positions in the two images were very different.

Multi-resolution Blending and the Oraple journey

In this part, after much experimentation, I decided to use kernel_size=min(2 * sigma1, 40) - 1 to improve runtime without sacrificing too much quality.

Gaussian and Laplacian Stacks

In this section, I produced gaussian stacks by repeatedly convolving the image with a gaussian. The Laplacian stacks were produced by subtracting each level of the stack from the next lowest level. Below are the results from the Oraple. It shows the laplacian stack for the apple, orange, and oraple images, respectively.

Laplacian stack of first image

cm

Laplacian stack of second image

cm

Laplacian stack of combined image

cm

Multiresolution Blending

In this section, I used the stacks from the previous section to produce a blended laplacian stack using the following formula at each level, l: LS_l(i,j)=GR_l(i, j) LA_l(i,j) + (1 - GR_l(i, j)) LB_l(i,j), where LA and LB are the laplacian stacks for the first and second images, and GR is the gaussian stack for the mask. The final image was produced by summing over all levels of LS. The hard part of this assignment was finding good pairs of pictures, because many looked bad together, or had different aspect ratios. The results are below, starting with my favorite, for which I showed the laplacian stacks of the first, second, and combined images, respectively. Unless otherwise specified, I used a vertical mask.

I also added a color feature by applying the process described above to each color channel.

apple and orange:

apple orange cm cm

lilies2 and lilies1:

cm cm cm

monet2 and monet1:

cm cm cm

paris1 and paris2 (this was my favorite):

cm cm cm

Laplacian stack of first image

cm

Laplacian stack of second image

cm

Laplacian stack of combined image

cm

beach1 and beach2:

cm cm

Mask:

cm cm cm

sky1 and sky2:

cm cm

Mask:

cm cm cm

Bells And Whistles

Throughout the development of this project, I kept in mind that I eventually wanted to add color, so my implementations mostly changed the color image, then converted it to grayscale for the result. When blending images, using color seemed to washout the images, so it didn't work very well. This is likely due to the high sigma values I used.

The most interesting thing I learned on this project was how much frequency alters my perception of an image. I think it is really cool that I can apply an identical process to many pairs of images to produce the effect that it looks like one image up close, and another from afar.