Project description

This project deals with transforming images with a variety of convolutions filters as well as algorithms to blend images together.

1.2 Hybrid Images

High frequency tends to dominate perception when it is available, but, at a distance, only the low frequency (smooth) part of the signal can be seen. By blending the high frequency portion of one image with the low-frequency portion of another, you get a hybrid image that leads to different interpretations at different distances.

We get the low pass image using a gaussian filter, and the high pass of another image by subtracting the gaussian-blurred from itself. Then we simply add these 2 images together to get the hybrid. Here is an example of combining low frequency part of Bran with the high frequency part of the Night King. We see Bran from far away, but when we get closer, we realize it is the Night King!

Many other interesting results are shown below.

More results

The first set of images use average Chinese male face (top left) and average Swiss male face (mid left) to generate hybrid images. The left result was using Chinese male face as low pass image and Swise male face as high pass image; the right reuslt was the opposite.

The second set of images use average Chinese female face (top left) and average Swiss female face (mid left) to generate hybrid images. The left result was using Chinese female face as low pass image and Swise female face as high pass image; the right reuslt was the opposite.

The third set of images use average male face (top left) and average female face (mid left) to generate hybrid images. The left result was using average male face as low pass image and average female face as high pass image; the right reuslt was the opposite.

In all 3 cases, the high pass image dominates in close distance, and low pass imange dominates in far distance.

Frequency Analysis of Male Female Face Hybrid

the log magnitude of the Fourier transform of the two input images, the filtered images, and the hybrid image

Male Face

Female Face

Low Pass Male

High Pass Female

Hybrid

1.3 Gaussian and Laplacian Stacks

Part 1.4: Multiresolution Blending

The goal of this part of the assignment is to blend 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.

In my example, I try to blend Jon Snow (upper left) with Daenarys Targaryen (upper right). Bottom left demontrates bruteforce seam, and bottom right uses multi resolution blending, which gives much better result.

Laplacian Stacks

Part 2: Gradient Domain Fushion

The primary goal of this assignment is to seamlessly blend an object or texture from a source image into a target image. The simplest method would be to just copy and paste the pixels from one image directly into the other. Unfortunately, this will create very noticeable seams, even if the backgrounds are well-matched. How can we get rid of these seams without doing too much perceptual damage to the source region?

One way to approach this is to use the Laplacian pyramid blending technique we implemented earlier. But here we take a different approach. The insight is that people often care much more about the gradient of an image than the overall intensity. So we can set up the problem as finding values for the target pixels that maximally preserve the gradient of the source region without changing any of the background pixels. Note that we are making a deliberate decision here to ignore the overall intensity! So a green hat could turn red, but it will still look like a hat. Therefore we can formulate a least-square problem.

Here, each "i" is a pixel in the source region "S", and each "j" is a 4-neighbor of "i". Each summation guides the gradient values to match those of the source region. In the first summation, the gradient is over two variable pixels; in the second, one pixel is variable and one is in the fixed target region. This method is called "Poisson Blending".

Part 2.1 Toy Exmaple

In this example we simply compute the x and y gradients from an image s, then use all the gradients, plus one pixel intensity, to reconstruct an image v. As we can see the input (left) appears exactly the same as the reconstructed output (right).

Part 2.2 Poisson Blending

Step 1.

Given a source image and a target image, we manually select the boundaries of a region in the source image and specify a location in the target image where it should be blended. Then, transform (e.g., translate) the source image so that indices of pixels in the source and target regions correspond. Ideally, the background of the object in the source region and the surrounding area of the target region will be of similar color.

Step 2.

Solve the above-mentioned optimization problem.

Step 3.

Copy the solved values v_i into your target image. For RGB images, process each channel separately. Show at least three results of Poisson blending. Explain any failure cases (e.g., weird colors, blurred boundaries, etc.).

Result

Here we try to blend Jon Snow into a scene in the video game, Witcher 3. The scenes' colors are not similar, but as we can see, the algorithm still does its best to blend the two images to a semi-believable state. However the result is still not perfect. For example, Jon Snow's face is turned to a weird color so that its gradients become similar to the background. [Source Image (Upper Left), Target Image (Upper Right), Blended Image (Lower)]

Better example

In this example, the background of the object in the source region and the surrounding area of the target region are very similar. So the result is a lot more realistic. In the image, the US mothership U.S.S John C. Stennis appears in the water of Game of Thrones.