CS 194:-26 Image Manipulation and Computational Photography, Fall 2018

Project 3: Fun with Frequencies and Gradients

Jun Zhou, CS194-26-abm



Part 1

Unsharp Mask Enhancement

By constructing a Gaussian filter from signal.gaussian and convolving an image with the filter, it acts as a low pass filter. This smooths out the edges because high frequencies (i.e edges) are filtered out in the convolution. However, by subtracting the original image and the Gaussian image, we can get the high frequency signals (i.e edges) and stack it on top of our original image to get the unsharp mask enhancement.

Hybrid Images

Success
Success
Failure
Success

By mixing high and low frequencies from the Laplacian and Gaussian respctively from two images, we can get a hybrid image that appears as different images, depending on distance.

Fourier Analysis

Gaussian/Laplacian Stack

In this famous painting by Dali, we use a Gaussian/Laplacian stack to reveal the different textures of frequencies present in the image.

Multiresolution Blending

Part Two

Toy Problem

To create a seamless transition between a source and target image, we need to minimize the gradients in the mask region. To practice doing such a technique, we first approach the toy problem. By building a sparse matrix A that represents all the linear combinations of the gradient on target image v, and the known gradient vector v which is calculated from the original image, we can reconstruct an approximate target image to the source by running linear least squares. By using a Sparse matrix which is densely packed with zeros, we speed up our computation of the target image.

Poisson Blending

Following the same line of reasoning, we now can design Poisson blending. We compute a Sparce matrix A that enumerates over the mask indicies of the source image, filling in the matrix for corresponding indicies: 4 in [i, i] and -1 in [i += 1, j += 1 ]. For neighbor indicies of points on the border, we do not fill in a -1 in the corresponding A matrix and instead add the target's pixel value at the corresponding mask index to the corresponding index in b. This provides the minimization for a seamless blending of source into target. We run linear least squares on Av = b, for sparse matrix A, target image v, and gradient vector b.

Favorite

I wanted to try to see if complimentary colors would blend well together so I chose a blue-dominated stamp picture of Waldo and a diplomatic embassy in Germany. I wanted to blend Waldo into the grass near the building to make the picture look like a post card. The mask is over the post card with waldo's face, and as shown by the naive superposition it is a terrible mix. However, the poisson mixture seems to be quite seamless; the only fallback is that the colors are desatured. This might be due to how I clip the image to fit between [0, 1], but nonetheless I like this image because it mixes reality with fantasy.

Poisson Spread

As shown by the space whirlwind, when you try to blend of high frequencies with each other, the result is a sharp boundary between the two. This failure is due to the high threshold for minimization between two frequencies. Using an L2 norm punishes deviation whereas possibly using an L1 norm might creat a smoother image. Another difficulty faced is the difference in colors. The penguin is white and poissonb lending it into the pink sakura trees results in a pink penguin. The best fit was the penguin on the snow because the source and target masks are close in color.

Multi Resolution Poisson Comparison

The multi-resolution blending failed miserably for this concept-image. Because of the high variance, blending the two images with a binary-alpha mask results in this superpositioned image that looks like a naive solution. However, for the case of poisson blending, it transitions seamlessly, making it look like a UFO in space. The large differences in colors of both techniques showcases the strenght of both methods. For high variance pictures, we should use poisson blending to create a better seam; whereas for images with similar backgrounds, the aesthetic shadows that transfer between the seam has more subjective value than poisson which might make an image's appearance as fake which poses as real.