Fun with Frequencies and Gradients!

CS194-26 Proj 3 (Project Web Page) : Gradient and Frequency Image Manipulation

Project Overview

In this project, we used various image processing techniques to do image blending, partial morphing and frequency analysis using the properties of discrete gradients and the fourier domain.

Part 1.1: Image Sharpening

This part of the project required taking interesting blurry images and using an unsharp mask, try to sharpen the image.

Effectively the math is straigtforward and is as follows: for a blurry image b, apply a gaussian blur and get a even blurrier image g. Calculate the difference between b and g and add the difference back to b. This effectively adds definition to the features of the image that 'survived' the Gaussian blur so it should theoretically sharpen the key characteristics of the image.

Another way to think about it is the Gaussian blurr is a low pass filter. The Gaussian blur subtracted from the dirac identity (the funciton to get the original image we subtract from) is a laplcian filter which is a high pass filter. Applying a high pass filter to the original image accentuates the high frequency features such as edges and corners so this adds definition when added back to the original image.

Kareem Abdul Jabbar

Original Kareem
Sharpened Kareem

Magic Johnson

Original Magic
Sharpened Magic
These were taken off of Youtube. I was watching some of the low quality low highlights and thought it'd be cool to try to sharpen them.

Part 1.2: Hybrid Images

For hybrid images, we want to merge two images so that you can see only one of the two or both overlayed depenind on how far you are. The concept is simple. From the previous part, we know a Gaussian filter is a high pass filter and laplacian is a low pass filter. If we apply a low pass on one image, high pass on another and add them together, we will get the desired hybridized affect.

Code was provided to align the images before the filters were appleid

Derek + Cat

Original Derek
Original Cat

Hybrid Derek + Car

Derek and Cat Black and White
Derek and Cat RGB

Visualization of Derek + Cat in Fourier Domain

Derek with High Pass
Cat with Low Pass

Snoopy + SnoopDogg

Original Snoopy
Original SnoopDogg

Hybrid Snoopy + SnoopDogg

Snoopy + SnoopDogg Black and White
Snoopy + SnoopDogg RGB

Visualization of Snoopy + SnoopDogg in Fourier Domain

Snoopy with High Pass
SnoopDogg with Low Pass

Prius + Camaro

Original Prius
Original Camaro

A Sporty Hybrid! Hybrid Prius + Camaro

Prius + Camaro Black and White
Prius + Camaro RGB

FAILED PRIUS + CAMARO

Prius + Camaro Failed

Visualization of Prius + Camaro in Fourier Domain

Prius with High Pass
Camaro with Low Pass

Part 1.3 Gaussian and Laplacian Stacks

This section visualizes the laplacian and the gaussian applied repeatedly to the image of interest. If we apply it to any hybridized image, we should be able to see the source images that make up the hybridized image

Visualization of Guassian and Laplacian Pyramids

Derek Cat Pyramid
Snoopy Snoop Dogg Pyramid
Cheetah Pyramid

Why a cheetah? Because I thought their extra blur and seeing their edges running fast would look cool

Part 1.4

Now we'll try to blend two images across a particular line.

Oraple
Clownshark
Camaro Prius
Shark Swimming

Here's the pyramid for an the clownshark

Clownshark Pyramid

You can kind of see the details of both the clownfish and the shark as they came together

Part 2: Gradient Domain Fushion

Part 2.1: Toy Problem

In this part of the project, I simply used the toy image and reconstructed using itself as the background

The point of this part of the project is to implement Poisson pyramid blending. The idea behind this type of blending is to try to place a source image in a particular specific location in the other image. Ideally, we would have trimmed the source image accordingly and get rid of the extraneous borders. But, this technique still works with a limited boundary. Assume the source image was in a very bright area, while the background image is in a dark area. One important fact decided empirically is that humans cannot really discern the intrinsic brightness of an object. Rather, they identify and segment objects based on relative differences i.e. the gradients. So we can reshade the source image so that it kind of matches the relative intensity of the background and maintains the intrinsic changes in pixel intensity.

It worked

Toy Example from Data .jpg
Toy Example Generated From Algorithm

Part 2.2: Poisson Blending

Penguin Injection
Toy Example Generated From Algorithm
My friend, Kavi, in Trump's State of the Union original
My friend, Kavi, in the State of the Union

This one does not look as good because of the source iamges background and high contrast as opposed to the background, but you can see the adjustments made to try to get Kavi to fit in

Putting a shark in a pool
The shark is in the pool!

The shark in the pool is pretty cool

The source image and background image:

Source Shark
Background Pool

The image integration works as follows. We basically set up an optimization problem. For every pixel, you try to measure the difference between the current pixel and the adjacent pixels, and try to set up the optimization problem so that the difference between each pixel and each of the adjacent pixels is as close to the difference between the pixels in the background image.

Why the shark image works? It works because the background color of both images was pretty similar and uniform. The fact that the colors were the same was probably not main reason for the succesfful integration but rather the gradients of the backgrounds were in the same. The one that turned down very poorly was the one where I tried to put my friend Kavi's face on Trumps state of the union speech. It was largely because of the background that was in a white classroom and he stood out whereas in the state of the union the people did not really stand out relative to the background. So everytime I tried to adjust the source intensity using gradient matching, he would turn out really dark relative to the background--way darker than the other people in the screen. I then tried to add a bunch of black to the background of his image so that he stood out lesss but due to my lack of artistic capability he turned out glowing. For the shark and swimmer, I tried multiple locations, tried to match histograms by equalizing both, and then put the shark on the swimming pool.

Which approach works best--the one above or the one below? This or the multiresolution blending? Definitely this one because I could adjust the location, not just blur the edges to make it seem continuous so don't lose details. Though the shark swimmer below looks pretty neat

Shark Swimming