CS194 Project 3

David Dominguez Hooper 24828373

Frequencies and Gradients: The objective of this project is to blend images together using different approaches.

Part 1

Warmup 1.1

To sharpen an image, I first applied a gaussian filter (with a 5 x 5 kernel) on each of the 3 color channels of the image to create the blur filter and subtracted that result from the original image to get the high frequency details of the image. I multiplied the highpass detailed image by alpha and added it back to the original image. For this image I used an alpha of 3.

Original

1.1_fire

Blurred

1.1_fire_blurred

High Frequency

1.1_fire_high-frequency

Sharpened

1.1_fire_sharpened

1.2 Hybrid Images

These hybrid images were obtained by taking the low frequencies of one image and the high frequencies of the other and adding them together. I tried to find a Gaussian kernel that would work well on all of the images provided. I found that a [4 4] kernel does well as it doesnt blur the lowpass image too much and doesnt bring out too much detail of the high pass image.

Original Gray and FFT

1.2_man 1.2_man
1.2_man 1.2_man

Lowpass and Highpass

1.2_man 1.2_man
1.2_man 1.2_man

[4 4] Gaussian

Afterwards

hybrid_cat hybrid_cat_grey

Original Gray and FFT

1.2_man 1.2_man
1.2_man 1.2_man

Lowpass and Highpass

1.2_man 1.2_man
1.2_man 1.2_man

[4 4] Gaussian

Afterwards

hybrid_cat hybrid_cat_grey

Failure: Original Gray and FFT

1.2_man 1.2_man
1.2_man 1.2_man

Lowpass and Highpass

1.2_man 1.2_man
1.2_man 1.2_man

[4 4] Gaussian

Afterwards

hybrid_cat hybrid_cat_grey

Bells and Whistles: Color

1.2_man 1.2_man 1.2_man

The color images help the low pass filter part of the image become more pronounced. I would say that when only using color in the high pass image, you can barely see the color in the details, but in the low pass use of color, the color is more prominent.

Notes

The high pass images (details) can clearly be seen up close. As you move farther away from the image, you begin to see the low pass features of the image. In the last set of images, I found that a failure point is when the size of the images aren't well-correlated. The wolf's face is much bigger than the dog's and so it looks a tad bit off. I considered this a failure but the effect still works if you stand far away, you only see the wolf. Still, I think it's important to note that the images should also be proportional to each other.

1.3: Gaussian and Laplacian Stacks

Here, I implemented the Gaussian and Laplacian stack. The images are the same dimension every step. I applied the Gaussian filter at each level for the Gaussian stack with an increasing kernel size. The Gaussain kernel starts off at [1 1] and then doubles until the 5th stack when it becomes [16 16]. For the Laplacian Stack, I subtracted the Gaussian filter of that level from the level above. I set the number of levels of the stack to be N=5.

Original

lincoln

Afterwards

Lowpass

lincoln_lowpass1 lincoln_lowpass1 lincoln_lowpass1 lincoln_lowpass1 lincoln_lowpass1

Highpass

lincoln_lowpass1 lincoln_lowpass1 lincoln_lowpass1 lincoln_lowpass1 lincoln_lowpass1

Original

hybrid_cat_hermione

Afterwards

Lowpass

hybrid_cat_hermione_lowpass1 hybrid_cat_hermione_lowpass1 hybrid_cat_hermione_lowpass1 hybrid_cat_hermione_lowpass1 hybrid_cat_hermione_lowpass1

Highpass

hybrid_cat_hermione_high_pass0 hybrid_cat_hermione_high_pass0 hybrid_cat_hermione_high_pass0 hybrid_cat_hermione_high_pass0 hybrid_cat_hermione_high_pass0

Original

grumpycat

Afterwards

Lowpass

grumpycat_lowpass1 grumpycat_lowpass1 grumpycat_lowpass1 grumpycat_lowpass1 grumpycat_lowpass1

Highpass

grumpycat_lowpass1 grumpycat_lowpass1 grumpycat_lowpass1 grumpycat_lowpass1 grumpycat_lowpass1

1.4 Multiresolution Blending with color (Bells and Whistles included)

Original and mask

orange apple apple

Afterwards

oraple

Original and mask

kangaroo mouse apple

Afterwards

kangaroo_mouse

Trey and Daph Original

kangaroo mouse

Trey and Daph Aligned and Mask

kangaroo mouse mouse_mask

Afterwards

kangaroo_mouse

Part 2

Human vision cares much more about the gradient of an image than the overall intensity. So, when blending, we want the gradient of the composite inside the region to look as close as possible to the source image gradient, and the composite must match the target image on the boundary.

2.1 Toy Problem

For this part, I followed the instructions and recreated the toy image. I used the following equations:

2_1Equation

From here, this becomes a system of linear equations, and I used the format Ax = b to solve for x. Then, x is resized into the image and saved.

Original

toy_problem

Afterwards

toy_gradient_saved

2.2 Poisson Blending

For this part, I utilized the following equation:

equation

To do this, I created a matrix A and a vector b that would mimic the system of linear equations for Ax = b. Using these matrices, I solved for x, resized x and displayed the final result. For this part, since color is involved, I processed each color channel concurrently, and then put the results back together to create the final image.

Originals for Los Angeles skyline, airplane, and Mask

beach orange_drink im_s_beach mask_beach drink_copied_beach

Afterwards Using Poisson Blending

blending_beach

Originals for Trex on New York street with Mask

night_sky baymax_resized im_s_night mask_night night_baymax_copied

Afterwards Using Poisson Blending

blending_night

Originals for drone tattoo on my friend Trey's face (Failed)

night_sky baymax_resized im_s_night mask_night night_baymax_copied

Afterwards Using Poisson Blending

The drone looks extremely dark in the Poisson blending result. I think this is because the drone was already dark and the tanish/shaded color of my friend Trey's skin caused it to be even darker.

blending_night

Bells and Whistles (Extra Points) Mixed Gradients

Originals for Sweater, Cal logo, and Mask

beach orange_drink im_s_beach mask_beach drink_copied_beach

Afterwards Using Poisson Blending

blending_beach

The mixed gradients defintely helped with matching the background target texture to the source image. If you notice on the sweater, there are shaded parts due to the folds of the sweater. The mixed gradients was able to take this into account and creat the same fold on thd Cal logo.


Comparing to Laplacian blending in Part 1

Using the same images used during the Trey and Daph example, I ran it with the Poisson Blending and got the following results:

Afterwards Using Poisson Blending

blending_mouse

The blending is much better due to the Poisson using the Gaussian to determine the gradients.

Afterwards Using Poisson Blending with Mixed Gradients

blending_mouse

The blending is here is not good because of Daph's nose and eye features being more prominent than Trey's nose and eyes since the dog has darker features it takes more effect in the final result.



Overall, I had a great time with this project. I learned the importance of creating a system of equations to solve for gradients to be used to merge an image with another. I personally like Multiresolution blending because it has more predictable effects. I felt that Poission had more artifacts but resulted in better results because of how it integrates the target image's intensities uinto the source image.