CS 194-26 Computational Photography

Fun with Frequencies and Gradients!

Victor Vong, CS194-26-acq




Overview

In the first part of the project we messed around with bands of frequencies to sharpen, create hybrid images, and do a multiresolution blend of two images. In order to sharpen we took the original image minus some a gaussian blur of the image to get the highest frequencies of the image. We then added those highest frequenices back to the image in order to sharpen it. In order to create hybrid images we took the lower band(s) of frequencies for one image and the higher band(s) of frequenices for the other image and combined them. That way when you look closely you will see the higher band(s) of frequencies and when you move farther away you would need the lower band(s) of frequenices. In the final part of part one we use a combination of the gaussian stack and laplacian stack in order to create multiresolution blended images with no noticable seam in the middle.

In the second(last) part of the project we explore gradient-domain processing, a simple technique with a broad set of applications including blending, tone-mapping, and non-photorealistic rendering. For the core portion of this project, we will focus on "Poisson blending". We construct sparse matrices (to lessen computational power needed) in order to solve and blend different gradient mappings between images in order to place a source image onto a target image and have the source gradients match the target gradients (and vice versa) after copying over the source image onto the target image. For some extra work we implemented mixed gradients using portions of both the target and source gradients to blend the target and source image.

Section I: Sharpening an Image using UnSharp Mask Technique

In order to sharpen the image we use a gaussian filter to get the low frequenices of the image. We then subtract the original image by the gaussian blurred image in order to get the highest frequency band. We then add that highest frequency band back to the original image in order to sharpen the image.


Section 2: Creating Hybrid Images

In order to create hyrbid images we simply take the lower frequenices of one image and combine them with the higher frequencies of another image. We used some alignment methods in order to achieve some of these images.


Original Gandalf Log magnitude of the Fourier transform
Gaussian Blurred Gandalf Log magnitude of the Fourier transform
Original Tiger Face Log magnitude of the Fourier transform
Gaussian Blurred Tiger Face Log magnitude of the Fourier transform
Original Hybrid Face Log magnitude of the Fourier transform

Derek and Gandalf
Nutmeg and Derek
Failed attempt at tiger face and penguin

The above attempts were more or less succesful. The last hybrid failed. The lowest frequencies of the tiger were still more prominent than the penguins body. The face of the penguin is more or less visible, but there is actually a ton missing because of the gaussian blurred tiger face.

Section 3: Gaussian and Laplacian Stacks

This is the starting point to doing multiresolution blending. Usually, gaussian and laplacian pyramids resize the images at each level, but we don't want to resize so we create stacks of equivalent sized images. At each stack level we either gaussian blur (sigma=2**i where i denotes level) and or do another layer of the laplacian stack (subtracting the different frequency bands of the images to get congruent sized frequency bands) using the gaussian stack for different frequency band creation (i.e gaussian blurred at some level minus gaussian blur of the current level to achieve a frequency band). Underneath are my gaussian and laplacian stacks for my tiger face image.



Gaussian Blurred (Sigma=1) Tiger Face
Gaussian Blurred (Sigma=2) Tiger Face
Gaussian Blurred (Sigma=4) Tiger Face
Gaussian Blurred (Sigma=8) Tiger Face
Gaussian Blurred (Sigma=16) Tiger Face
Gaussian Blurred (Sigma=32) Tiger Face
Laplacian Layer (Original - Gaussian Blurred Original (Sigma=1)) Tiger Face
Laplacian Layer (Gaussian Blurred Original (Sigma=1) - Gaussian Blurred Original (Sigma=2)) Tiger Face
Laplacian Layer (Gaussian Blurred Original (Sigma=2) - Gaussian Blurred Original (Sigma=4)) Tiger Face
Laplacian Layer (Gaussian Blurred Original (Sigma=4) - Gaussian Blurred Original (Sigma=8)) Tiger Face
Laplacian Layer (Gaussian Blurred Original (Sigma=8) - Gaussian Blurred Original (Sigma=16)) Tiger Face
Laplacian Layer (Gaussian Blurred Original (Sigma=16) - Gaussian Blurred Original (Sigma=32)) Tiger Face

Section 4: MultiResolution Blending

This part of the project utilizes the previous section. In order to achieve multiresolution blending we created a laplacian stack for both images A and B. We then created mask with 1's where we want A/B to appear and 0's where the other will appear. We then create a gaussian stack for the mask in order to use the nodes as weights for each layer of both Laplacian Stack(s) of A and B. We then proceed to add final stack of weighted images from Laplace A, Laplace B, and Gaussian Mask R where for each layer LS[l] = GR[l]*LA[l] + (1-GR[l])*LB[l]. For the bottom example we used stacks with 5 Layers and Sigma=2**i for the Gaussian Stack of the Mask. We also replaced the final laplacian stack layer with the final Gaussian Layer of either image A or B in order to bring back the lowest frequencies.


TIger LS layer 1
TIger LS layer 2
TIger LS layer 3
TIger LS layer 4
TIger LS layer 5
Summation of All Previous Layers

Irregular Masked Penguin on an Apple cause why not
Penguin and Tiger Blend
Nutmeg and Tiger Face Blend
Orange and Apple

Section 5: Toy Problem

As we switch directions the beginning part of this portion is leading to Poisson Blending. This first task is aimed at showcasing how we can solve sparse Matrices in order to find an image to match the gradient map of an image. The kernel used for x gradients is [-1,1], and the kernel for y gradients is [[-1], [1]]. These gradients are calcuated and appended to form a list of x gradients along with y gradients. We then add an extra constraint that the top left corner of the new image is the same for the new image to match this gradient map and the original image. In this example we use a picture of Woody and Buzz Lightyear. If done successfully we should get the original image, because we are not using any mask. So it only makes sense the the only image that could map to the original images gradient map is itself.


The original image
The image which is equivalent to the gradient map of the original image (itself)

Section 6: Poisson Blending

This section is similar to the previous section. We do a modified process using the laplacian matrix [[0, -1, 0],[-1, 4, -1],[0, -1, 0]] as the constraints in order to create an image which can be made from the combination of both the original target image and some portion(s) of a source image copied onto the target image. This forces the gradients of the source image to match the target image and essentially be blended into the target image seamlessly. This of course can experience errors depending on the mask of the image as we will see below. Erorrs of the blending are noticable if the source portion isn't just the object and includes a previous background which clashes with the target background. Errors can also occur from gradient changes to the source image as Poisson Blending doesn't preserve color of the source portions.


Target Image
Source Image
Mask used on Source Image
Directly copying Source onto Target
Poisson Blended Source onto Target

Penguin Overlord
Beta Fish In the Sky
Failed Dinosaur with mask that alters surrounding area to much
Failed Boat with differing water and boat color changes from red to blue/black

Apple
Penguin
Penguin Blended onto Apple using MultiResolution Blending
Penguin Blended onto Apple using Poisson Blending
Penguin Blended onto Apple using Mixed Gradient Blending

Mixed Gradient Blending is superior to Poisson Blending which is superior to MultiResolution Blending. As we can see MultiResolution still preserves the original Source Image Color. Poisson Blending darkens the penguin to much, but Mixed Gradient Blending succeeds in keeping the penguins intensities, but still blend him into the apple. Mixed gradients succeeds because it uses a combination of both target and source image gradients to match. Poisson uses only the target gradients and MultiResolution Blending uses weights of a gaussian blurred mask at each layer.