Computational Photography: Fun with Frequencies and Gradient

By Aneesh Akella

Introduction:

For this project, several different blending and photo manipulation techniques were implemented. These included sharpening, hybridization, multiresolution blneding, poisson-blending, and mixed gradient blending.

Sharpening:

Sharpening, by definition, is the accentuation of the details of the photo. In theory, this means edges, lines, corners should stand out in the image. The laplacian of the image is useful for edge detection and gathering said features. To do this, we simply subtract the blurred gaussian version of the image from the original. This will create the laplace of the original image, which will contain the features. By adding these features back by a desired magnitude, the edges, lines, and corners are accentuated. The photo is now sharpened. There are two important parameters to distinguish. σ which denotes how blurry to make the photo that will be subtracted from the original. Another is, α, which is the desired magnitude for the extracted features.

City Landscape: Original Photo

Example 1: σ = 3 & α = 3

Example 2: σ = 3 & α = 6

Example 3: σ = 3 & α = 9

Example 4: σ = 6 & α = 3

Example 5: σ = 9 & α = 3

Comparing Example 5 to Example 3, we can see that the Example 5's features appear to much more defined and rigid.

Hybrid Images:

Here we blend two images together: the laplacian of one image and the gaussian blur of another image.

Here is a photo of my roomate Ki, who has a resemblance to Psy

Ki

Psy

FFT: Ki

FFT:Psy

FFT: Laplacian Psy

FFT: Gaussian Ki

FFT: Combination!

THE RESULT:

If you look closely, you see strictly Psy. However, move back several feet and you will see Ki. Quite frankly, this is my best result. Part of the reason, they may blend so well is perhaps because Ki and Psy have similar skin tones and both are wearing sunglasses.

Failure Case/Bells and Whistles Explanation:

While I would not call this a pure "failure", this result is definitely not as good as the other. Here I combine the Notrious BIG with my roomate, Arya. If you look closely you see can still kind of see Arya, which is why I consider it a failure. The hybrid images still work the same ways above: look closely, you see BIG; look farther way you see Arya. However, it is not as opitmal as the other. I could have made the BIG stand out more by increasing the images respective sigma value. However, Arya, then becomes less noticeable at a distance. Therefore, color is definitely important when hybrid blending, but not an all determining factor. You can still create interesting images even if the people you are trying to blend have different colors.

 

Arya

 

Notrious BIG

 

The Combination

Laplacian Stacks/Gaussian Stacks

In order to do multiresolution blending, I needed to create several layers of gaussian blurs and laplacian images. Here they are:

Dali Gauss 1

 

Dali Gauss 2

 

Dali Gauss 3

Dali Laplace 1

 

Dali Laplace 2

 

Dali Laplace 3

Hybrid Image: Gauss and Laplacian

       

Multiresolution Blending:

Ultimately, one of the problems with blending images is that an apparent seam is noticeable after the images are blended together. Multiresolution blending tries to work around this by using laplacian pyramids and gaussian pyramids. For the two images, both laplacian and gaussian pyramids are constructed. Laplacian and gaussian pyramids are then constructed for the blended images. There are two images: the source and the transfer. We are trying to put the source into the transfer. The white area in the mask corresponds to what segment we want to paste on the transfer. To form the blended image at a given level, we combine the laplacian and gaussian information from the same level in the source's and transfer's respecitve pyramids.

Source

 

Transfer

 

Mask

 

Result

 

Source

 

Transfer

 

Mask

 

Result

 

Laplacian Stacks for Multiresolution Blending:

Source

 

Source 2

 

Source3

 

Transfer1

Transfer2

 

Transfer3

 

Result1

 

Result2

Toy Problem:

Through knowledge of the gradient, we able to reconstruct a picture. Treat each pixel as a variable and by taking the gradients there are 2N + 1 equations. Ultimately, to solve for N variables we need N equations. Either way, we have a fully-sepcified system. By creating a coefficient matrix A and another vector b that contains the gradients themselves, a solution vector x can be calculated, which has the correct pixel values. From that information the image can be reconstructed as shown below. My error was on the scale of e-6.

Original Image

Reconstructed Image

 

Poisson Blending:

Using the same principles as in the toy problem, the gradients can be utilized to create seamless blending. Similar to multiresolution blending, a mask, a source image, and a transfer image are needed. However, instead of using a laplacian or gaussian pyramid, the gradients of the source image are strictly needed. A search region around the white area of the mask is created. The number of pixels in this search region will be the length and width of the coefficient matrix, A. Each row and column will be designated for a specific pixel within the region. The gradient between the specific pixel and its 4 neighbors (up, down, left, right) in the source image is calculated and summed. By calculating vector x, we get the new pixel values. The reasoning behind this that the x-and-y gradients are minimzed through this least-squares procedure.

 

Iron Man

Original Image

Mask

Transfer Image

Naive Blend

Result

         

Lion

Original Image

Mask

Transfer Image

Naive Blend

Result

 

Berkeley: FAILURE CASE

Mask

Mask #2

Transfer Image

Result

Spiderman turned out ok. The dragon not so much. Ultimately, poisson blending works better with images, when the background of the source region is similar color to the transfer region.

Comparison between Poisson and Multiresolution

<

Left is the multiresolution picture. Right is the Poisson picture.

To make it easier to analyze, I cropped part of the shark picture and showed both the poisson result and the multiresolution result above. Ultimately, multiresolution still has some light blue aura, probably stemming from the original source. Additonally, with the lion picture, there is very clear a seam . The poisson distributon looks more realistic and blends in better with the environment. This can be due to the fact that the gradients between the transfer and source region are minimized.

Mixed Gradient Blending:

Ultimately, poisson blending does not perserve reflectance primarily because strictly the gradients in the source image are used. To add a level of transparency, mixed-gradient blending should be utilized. In poisson blending, the gradients between the source pixels were strictly computed. However, in mixed gradient blending, if the gradient between a pair of transfer pixels are greater than that of a pair of source pixels, thn the transfer gradient will be added instead of the source gradient.

Mixed Blending

Poisson Blending

Mixed Failure Case

Transparency is indeed perserved as we can see the water more clearly in the mixed-blending version than the poisson version. However, transparency can be a bad thing as show shown in the above photo.