CS194 Project 3

Kristine Lin 25523003

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 took the gaussian filter and subtracted the result from the original image to get the high frequencies. I multiplied the highpass by alpha and added it back to the original image. For this image I used the alpha of 3.

Original

blurry_girl

Afterwards

blurry_girl_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. For many of the results, I needed to play around with the sigmas in order for the image to come out looking blended. The cat and bunny ended up being a failure since the head sizes did not quite match up and did not overlap when aligned using the eyes.

Original

nutmeg DerekPicture

Sigmas 2, 4

Afterwards

hybrid_cat hybrid_cat_grey

Original

grumpycat rabbit

Sigmas 2, 2

Afterwards (failure)

hybrid_cat_bunny hybrid_cat_bunny_grey

Original

grumpycat hermione

Afterwards

Sigmas 2, 4

hybrid_cat_hermione1 hybrid_cat_hermione_grey1

Original

frisbee happy_face

Sigmas 2, 8

Afterwards

hybrid_frisbee_happy_face hybrid_frisbee_happy_face_grey1

Although there are vague results using this technique, the blending is only clear from a distance. Up close, the blending is not seamless. In addition, a down side to this is that in the case of blending faces, the face size and shape need to be similar in order for blending to be more seamless.

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. For the Laplacian Stack, I subtracted the Gaussian filter of that level from the level above. To create these images, I scaled the images by the min and max of that image. I set the number of levels of the stack to be 5.

Original

lincoln

Afterwards

Lowpass

lincoln_lowpass1 lincoln_lowpass2 lincoln_lowpass3 lincoln_lowpass4 lincoln_lowpass5

Highpass

lincoln_high_pass0 lincoln_high_pass1 lincoln_high_pass2 lincoln_high_pass3 lincoln_high_pass4

Original

hybrid_cat_hermione

Afterwards

Lowpass

hybrid_cat_hermione_lowpass1 hybrid_cat_hermione_lowpass2 hybrid_cat_hermione_lowpass3 hybrid_cat_hermione_lowpass4 hybrid_cat_hermione_lowpass5

Highpass

hybrid_cat_hermione_high_pass0 hybrid_cat_hermione_high_pass1 hybrid_cat_hermione_high_pass2 hybrid_cat_hermione_high_pass3 hybrid_cat_hermione_high_pass4

Honestly, the last picture is going to give me nightmares. Let's fix this by using grumpy cat again.

Original

grumpycat

Afterwards

Lowpass

grumpycat_lowpass1 grumpycat_lowpass2 grumpycatlowpass3 grumpycat_lowpass4 grumpycat_lowpass5

Highpass

grumpycat_high_pass0 grumpycat_high_pass1 grumpycat_high_pass2 grumpycat_high_pass3 grumpycat_high_pass4

1.4 Multiresolution Blending

Original

orange apple

Afterwards

orapple

Original

minnie poo

Afterwards

minnie_poo_tsum

Kangaroo Mouse

kangaroo mouse

Kangaroo Mouse 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 Story

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 created the equation for each individual color, and then put the results back together to create the final image. For many of the results, you can see the slight outline of the masks involved.

Originals for drink on the beach and Mask

beach orange_drink im_s_beach mask_beach drink_copied_beach

Afterwards Using Poisson Blending

blending_beach

Originals for drink on the baymax and night and Mask (Failed)

night_sky baymax_resized im_s_night mask_night night_baymax_copied

Afterwards Using Poisson Blending

Because the background of the Baymax image was white, it was more difficult for Poisson blending to blend the night sky and the background of Baymax, causing the result to be super grey instead of the deep color of the night sky.

blending_night

Originals for Baymax Head and Tokyo and Mask

To try to fix the problem from the previous example, I tried to find a picture with a more drastic background of Baymax and put him in the sky of Tokyo.

baymax_red Tokyo im_s_tokyo mask_tokyo baymax_head_tokyo

Afterwards Using Poisson Blending

blending_tokyo

Comparing to Laplacian blending in Part 1

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

Afterwards Using Poisson Blending

blending_mouse

You can definitely see the blue sky blending into the head of the mouse, but there was definitely less of the mouse's curr blending onto the sky.

Overall, in my opinion, Laplacian blending generally worked better than Poisson blending since it's rare that the background colors are drastically different. There were many examples in Poisson blending where the background color would interfere with the entire image and the edges of the masks became visible. However, if background was not taken into account and the images are drastically different, it seems that Poisson blending would be a better choice as it is able to blend more seamlessly. For the multi-resolution blending, while the transitions (seams) may not be visible, the intensity or the color of the source cutout area may be different from the background/target image. Therefore, the cutout area in the composite image may still be noticeable. With the Poisson blending, since only the gradients are kept the same, there is no sudden change in intensity or color, thus, preserving the color/intensity consistency of the composite images.