Project 3: Fun with Frequencies and Gradients

Overview

This project covers two parts: Frequency Domain and Gradient Domain Fushion. I will be applying concepts such as convolution, Gaussian, Laplacian, blending, and more.

Part 1 - Frequency Domain

Part 1.1: Warmup

For sharpening an image, I used the algorithm learned in lecture where the original image is convolved with a single filter. The equation I used for this is: f + α(f − f * g) which is the equivalent to f ∗((1+α)e−αg). I selected my α to be 1. I selected this image, though not blurry, I felt had multiple edges to enhance.

Before Image

I selected my favorite image of my apartment balcony.

After Image

As you can see, the many edges of this image have sharpened.

Part 1.2: Hybrid Images

For creating hybrid images, I used the technique discussed by blending the high frequency portion of one image with the low-frequency portion of another. In doing so, I created a filter for both the high and low frequencies and stacked the two together. I followed the same 2D Gaussian and convolution techniques for creating the filter as described in the project. I also computed the 2D Fourier transform images using the method described in the project spec: plt.imshow(np.log(np.abs(np.fft.fftshift(np.fft.fft2(gray_image))))).

Derek

Original Image

Nutmeg

Original Image

Derek+Nutmeg

Hybrid Image

Fourier Transform of Derek

Fourier Transform of Nutmeg

Fourier Transform of Derek Low Pass

Fourier Transform of Nutmeg High Pass

For the second set of images, I used similar photos of dogs. This output was not as clear and differentiatable. Thus, when they are stacked on top of one another, it is not that clear since they line up very similarly.

Dog 1

Original Image

Dog 2

Original Image

Dogs Combined

Hybrid Image

For the last set of images, I used Audrey Hepburn and an owl. This output better at differntiating between distances since they were disimilar enough. Also, the owl hand many sharp edges to be picked out which made this hybrid image have a better output.

Audrey Hepburn

Original Image

Owl

Original Image

Audrey Hepburn + Owl

Hybrid Image. Close up you see an owl, but afar you see Audrey.

Fourier Transform of Audrey Hepburn

Fourier Transform of Owl

Fourier Transform of Audrey Low Pass

Fourier Transform of Owl High Pass

Part 1.3: Gaussian and Laplacian Stacks

Like the project description, I implemented Gaussian and a Laplacian stacks by applying Gaussian at each level. These two combined creates an image that blurs and it progresses, and reduces the sharpness of the edges.

Stacks Applied to Salvador Dali Painting of Lincoln

Stacks Applied to Hybrid Image of Audrey Hepburn and Owl

Part 1.4: Multiresolution Blending

In this part of the project, I blended two images seamlessly using a multi resolution blending. This creates a smooth image spline. This is done by creating a mask and blur the image. I applied this to a few examples, including the oraple.

Apple

Original Image

Orange

Original Image

Oraple

Blended Image

This second set of images, my personal favorite, was combining two different humans. The images were similar enough that the image spline has a very gentle seam.

Girl

Original Image

Boy

Original Image

Girl + Boy

Blended Image

Laplacian's and Mask

The last set of images uses an irregular mask to put a lion on the beach. In order to make the mask blend, I had to add some blur. However, this reduces the overall sharpness of the image which can be a limitation.

Lion

Beach

Mask

Lion on Beach

Blended Image

Part 2 - Gradient Domain Fushion

Brief Description

This project explores gradient-domain processing, focusing on "Poisson Blending." The primary goal of this assignment is to seamlessly blend an object or texture from a source image into a target image. We formulate this goal as a least squares problem. Given the pixel intensities of the source image "s" and of the target image "t", we want to solve for new intensity values "v" within the source region "S":
Here, Poisson works with the gradient domain instead of the spatial, frequency, etc. domain other techniques use. However, in focusing on the gradient, the tradeoff is made in the intensity.

Part 2.1: Toy Problem

In this example we compute the x and y gradients from this toy image, then use all the gradients, plus one pixel intensity, to reconstruct the original image. First we write the objective function as a set of least squares constraints in the standard matrix form. After writing the minimizing objectives, we solve for v and copy the value into the appropriate pixel in the output image.

Original

Reconstructed

Part 2.2: Poisson Blending

For this blending technique, the goal is to transform the pixels in the source and target regions that correspond so that the boundary of the mask matches in the reconstructed image. This was done from the blending constraints summation equation in the project spec:

Favorite Image

For my favorite image, I used the algoirthm described in the project spec and elaborated above. I selected these images because sky diving is fun and fascinating, and the forewarning collision with the bird seems fitting.

Sky Divers

Bird

Sky Divers Diving With Bird

Blended Image

Additional Decent Image

Woods

Christmas Tree

Christmas Tree in Middle of Woods

Blended Image

Additional Bad Image

In this result, we can see that the image color is distored. This is because Poisson blending disregards the intensity. Thus, the color is not preserved when putting the source image onto the target. In this example, the water was intensely green, and the car intensely bright blue. When the car is put onto the water, some of the blue color is lost and appears almost green-ish.

Water

Car

Car in Water

Blended Image

Comparing Blends

In this example of the lion on the beach, poison blending turned out to be the more successful. This is because of the gradient and having the source image background similar to the color of the target image landscape. This allowed for smoother edges when blending. However, like in the bad example above, Poisson would not be ideal if you want to preserve the color of the source image. If intensity matters more, Laplacian blending would be more ideal.

Beach

Lion

Lion Mask

Multiresolution Blending

Poisson Blending