Background

This project uses filters and frequencies manipulate images in various ways. For example, we can blur an image, create a hybrid image between two images, and blend two images together. Some concepts applied include finite difference operators, derivative of Gaussian filters, Gaussian stacks and Laplacian stacks. Scroll down to read more!

1.1 Finite Difference Operator

Approach

I set Dx and Dy to be 2D numpy arrays and convolved each of them with the 0th channel of the cameraman image using scipy.signal.convolve2d, setting mode=same. Afterwards, I took the gradient magnitude of the two images post-convolution using the distance formula sqrt(image1 ^ 2 + image2 ^ 2). Finally, I binarized the gradient magnitude image, setting the threshold to 75.

1.1 Images

Dx.jpg
Dx
Dy.jpg
Dy
gradient_magnitude.jpg
Gradient Magnitude
binarized.jpg
Binarized

1.2 Derivative of Gaussian (DoG) Filter

Approach

I used get_gaussian_kernel_2d from discussion and set kernelSize=10 and sigma=1.5 to create my Gaussian. For the first part, I blurred the original image by convolving it with the Gaussian. Next, I convolved the blurred image with Dx and Dy, before finding its gradient magnitude and binarizing it. For the second part, I convolved my Gaussian with Dx and Dy before convolving the original image with the derivative of Gaussian. I then found the gradient magnitude and binarized, as usual.

Observations

Using this approach, we can see that the binarized edges are more defined (thicker and rounder). There is also less noise, especially near the bottom of the image. However, we also lose some details of the camera. We can also see that our two approaches yield the same output image, as expected.

1.2 Images

cameraman.jpg
Cameraman
blurred.jpg
Blurred
blur_Dx.jpg
Dx of Blurred
blur_Dy.jpg
Dy of Blurred
blurred_gm.jpg
Blurred Gradient Magnitude
blurred_bgm.jpg
Blurred Binarized
DoG.jpg
DoG
BinDoG.jpg
Binarized DoG

2.1 Image "Sharpening"

Approach

I used the formulas from lecture to derive image sharpening. Let B be the blurred image (convolving the original image with Gaussian(10, 1.5)), img be the image and alpha be the sharpening factor. Then, our sharpened image is img + alpha * (img - B). I used alpha=1 for all images below.

Observations of Sharpening, Blurring and Sharpening Again

I chose to blur and sharpen the already sharp image of the dam. It turns out that this resulting image is more blurry than the original sharpened image, due to the blur losing information in the image.

2.1 Images

taj.jpg
Taj Mahal
sharp_taj.jpg
Sharpened Taj Mahal
dam.jpg
Dam
sharp_dam.jpg
Sharpened Dam
blurdam.jpg
Sharpened, Blurred, then Sharpened Dam

2.2 Hybrid Images

Approach

First, I used the skeleton code to align my images. I used Gaussian(60, 10) as the kernel for my high frequency image and Gaussian(6, 1) for my low frequency image. I blurred the images with their respective Gaussians. I averaged the blurred low frequency image and the difference between the high frequncy image and its blurred version to get a hybrid photo. I then converted it to grayscale using the rgb2gray function from discussion.

2.2 Images

nutmeg.jpg
Nutmeg
DerekPicture.jpg
Derek
Cat_Man.jpg
Cat Man
jacob.jpg
Jacob
sean.jpg
Sean
Pookies.jpg
Pookies Hybrid Image
uniqloroo.jpg
Uniqloroo
kingaroo.jpg
Kingaroo
Kangaroo.jpg
Kangaroo

Failed Hybrid

A hybrid I tried was combining the Kingaroo with a boba drink - however, that unfortunately failed. It was difficult to align it, and even more difficult to find fitting Gaussian parameters to make a good hyrbid considering the shapes of the two figures in question.

uniqloroo.jpg
Uniqloroo
boba.jpg
Kingaroo
bobaroo.jpeg
Bobaroo

Fourier Analysis of Kangaroos

I chose to display the 2D Fourier transform of the Kingaroo and Uniqloroo Hybrid.

Kingaroo_FFT.jpg
Low Frequency Image FFT
Uniqloroo_FFT.jpg
High Frequency Image FFT
Hybrid_FFT.jpg
Hybrid Image FFT
Filtered_Low_FFT.jpg
Filtered Low Frequency Image FFT
Filtered_High_FFT.jpg
Filtered High Frequency Image FFT

2.3 Gaussian and Laplacian Stacks

Approach

I used the lecture slides as inspiration for creating my Gaussian and Laplacian stacks. For each level of the Gaussian stack, I blurred the previous level by Gaussian(36, 6). To make my Laplacian stack, I subtracted the value in index i-1 from the value in index i of my Gaussian stack, then added the highest level of my Gaussian stack to the end.

2.3 Images

apple_gauss.jpg
Apple Gaussian Stack
apple_laplace.jpg
Apple Laplacian Stack
orange_gauss.jpg
Orange Gaussian Stack
orange_laplace.jpg
Orange Laplacian Stack
oraple_gauss.jpg
Oraple Gaussian Stack
oraple_laplace.jpg
Oraple Laplacian Stack

2.4 Multiresolution Blending

Approach

To build my Laplacian stack for a blended image, I used the formula A[i] * mask[i] + B[i] * (1 - mask[i]) from the lecture slides as inspiration, where A and B correspond to the Laplacian stacks of the two images. To complete the blend, I summed the values in the stacks, which returned the desired image.

2.4 Images

apple.jpeg
Apple
orange.jpeg
Orange
vert_mask.jpeg
Mask
oraple_blend.jpg
Oraple
arnold.jpg
Arnold Schwarzenegger
jacobface.jpg
Jacob (Housemate)
facemask.jpg
Mask
jarnold.jpg
Jarnold
hojicha.jpg
Hojicha
anna.jpg
Anna
annamask.jpg
Mask
annahojicha.jpg
Anna Hojicha

Laplacian Stack of Anna Hojicha

anna_laplacian.jpg
Anna Laplacian Stack
hojicha_laplacian.jpg
Hojicha Laplacian Stack
annahojicha_laplacian.jpg
Anna Hojicha Laplacian Stack
annahojicha.jpg
Big Anna Hojicha!!!