Fun with Frequencies

1.1 Sharpening

following this simple equation: sharp = orig + a(orig - blurry)

my results were produced using a 45x45 gaussian kernel with a sigma = 1 and alpha = 1



 

                                                                        1.2 Hybrid Images

First I gathered images that I wanted to turn into hybrid images. A hybrid image is an image that looks like one image the closer are to the image and like another the farther away you are. To create this, we need to low pass filter (gaussian blur) one image and high pass filter (Laplacian) the other image. Then we merge the two by adding the filtered images together. The cut-off frequencies varied for each result but overall, I found that a sigma of 3 worked the best for more images (using the same 45x45 kernel).

Image to be Low Pass Filtered

Image to be High Pass Filtered

Merged Image

FAILURE CASE

 



Image looks nothing like the original. Images should be fairly similar in both shape and color for hybrid effect to hold.


­­


 

To illustrate the process, I have included the log magnitude of the Fourier transform of the input images, filtered images, and the resulting hybrid image.

Im 1 no filter

Im 2 no filter

Im 1 low pass filtered

Im 2 high pass fliter

Hybrid

 

                                                                        1.3 Gaussian and Laplacian Stacks

                                                                                         
To prepare for our multi-resolution blending we first implemented gaussian and Laplacian stacks. A stack is very similar to the idea of an pyramid only that we don’t down sample. For my implementation I started the gaussian stack with a length of 45 and a sigma of 1. I multiplied the sigma on every level down the stack.

Lincoln!

Gaussian: Looks like Lincoln

 

Laplacian: can more clearly see the contents of each square.

 

Mona Lisa!

The smile gets clearer and clearer the more we filter out the high frequencies! The frown in very noticeable when only looking at the high frequencies.
                                                                                          Gaussian:

Laplacian:

 

Joseph: Now lets take a look at the stacks for the hybrid image above we will see the clearly the two images

Gauss:

Laplacian:

 

1.4 Multi-Resolution Blending

Essentially to create these images we build Laplacian stacks of both images. Then we a gaussian stack of the mask (representing the region that we want to blend) and sum them to combine the stacks into one. From there we add back in both gaussians of the image to recreate the blended image with the feathered laplacian’s.

LS = sum( mask[i]Laplacian1[i] + (1 – mask[i])Laplacian2[i] )

 

 Irregular Mask

 

Laplacian of the Yacht

 

2.1 Toy Problem

For this project we want to reconstruct and image given a single pixel value from the original image and the gradients of the original image. The best way to do this is to simply set up a system of linear equations. Av = b
A is a spare matrix with dim(2 * h * w + 1, h * w), the first h * w rows correspond to the x gradients, the next h * w rows correspond to the y gradients. v is a vector of length (h * w), b is a vector of length (2 * h * w) corresponding to the gradient values of the original image and the last row being the value of pixel (1,1)

                                                                                          Simply use a least square solver (of a spare matrix for efficient time) to calculate the reconstructed image.

 

2.2 Poisson Blending

Now we move into a more advanced blending called Poisson blending. We want to blend in the gradient domain. Essentially, we want to find values for target pixels to preserve the gradients of the source while keeping the background of the target the same.

This is best described by the equation described in class. Using the example professor demonstrated in lecture I created a sparse A matrix that for all pixels outside of the mask just match the pixel intensity of the background and for all pixels inside the mask I set up a linear equation that minimizes the difference in the source gradients and the background gradients.

 

 

Failure Case:

The background of this image is simple too complex (it contains a lot of weird lines and objects, including a person). This causes nemo to not blend as smoothly into the background

 

Now we will attempt to blend an image that we used previously with our new poisson blending algorithm.

Laplacian Pyramid:

Poisson Blending

Overall the poisson works a lot better, the image is sharper and brighter and the image blends really nicely into the background. I think that multiresolution blending works better when you want to keep the start contrast between two images. On the other hand, poisson blending is perfect when the source and target have relatively similar and empty backgrounds and we want to seamlessly blend one image into another. I think overall multiresolution works better for regular masks and poisson works better for irregular masks.

 

I learned that linear algebra can be fun and is really useful in the field of image processing!