Fun with Filters and Frequencies
Orange + Apple = Orapple
Overview
This project will explore Gaussian filters through 2D convolution, the application of filters and frequency, and the use of Gaussian and Laplacian stacks.
Finite Difference Operator
In this seciton, objective is to apply partial derivative of X and Y serpately so Using Dx Dy we can get edges in vertical and horizontal.
\( D_x \): $$ D_x = \begin{bmatrix} 1 & -1 \end{bmatrix} $$
\( D_y \): $$ D_y = \begin{bmatrix} 1 \\ -1 \end{bmatrix} $$
The image is convolved with \( D_x \) and \( D_y \) where \( A \) is an image: $$ A_x = A * D_x$$ $$A_y = A * D_y $$
To compute the gradient of these two, we simply take the square root of the sum of the squares of both images that were partially derived:
$$ \text{G} = \sqrt{ A_x^2 + A_y^2} $$
Then, we can apply a threshold to each pixel for binarization to suppress noise.
Derivative of Gaussian (DoG) Filter
In previous image, we found that its a bit noise; therefore, we investigate smoothing the image by applying gaussian filter and convolution after wards and compare result with applying gaussian to Dx and Dy .
$$ A_G = A * Gaussian $$ $$ A_{Gx} = A_G * Dx $$ $$ A_{Gy} = A_G * Dy $$
Then compute the gradient magitude of these two.
$$ G_a = \sqrt{ A_{Gx}^2 + A_{Gy}^2} $$
From the result, it is clear that the edges are more connected and visibly sharper. The Gaussian filter effectively reduced noise by smoothing out variations in pixel intensity.
Now, we are going to produce another result by applying derivate to gaussian. By Associative Property of Multiplication it should output the same result.
$$ D_{xG} = D_x * Gaussian $$
$$ D_{yG} = D_y * Gaussian $$
$$ A_{xG} = A * D_{xG} $$
$$ A_{yG} = A * D_{yG} $$
$$ G_a = \sqrt{ A_{xG}^2 + A_{yG}^2} $$
Comparison
Besides very small differencese in some pixsles, the binarized results approaches are identical.
Image Sharpening
In sharpening image, we explore the process of sharpening using the unsharp masking technique. Unsharp masking method helps enhancing the edges and details in an iamge by intensifies the high frequency pixels
To create unsharp masking and sharpen the image, I first need to separate the color channels. Then, I apply Gaussian filters to each one of them. After applying the filters, I subtract the blurred image from the original image to obtain the edges. For the final result, I add the edges multiplied by an intensity factor to the original image to produce the sharpened image.
Taj Mahal
Pictures
Headset in the River
By experimenting with the "Pictures" and "Headset in the River" images, I observed that the blurred image has softened edges and reduced the clarity of fine details. However, after sharpening, the edges are almost exactly the same as the original image, with slight noise introduced in the smooth regions.
Hybrid Images
A hybrid image is an image where two different images are combined into one. I generate the low-pass image using a Gaussian filter, and the high-pass image by subtracting the low-pass filtered image from the original image. This method creates an optical illusion: when viewed up close, the high-frequency image (with sharp details) is more prominent, but as you move further away, the low-pass filtered image (with smooth, broad features) becomes more noticeable.
Derek and Nutmeg
Cat and Mongoose
Smile and Frown (Favorite)
Frequency Analysis
Cat and Mongoose (Failure)
For this particular hybrid image, it was very difficult to align the two images because they were different, a mouse as the object and an animal. Additionally, using a high sigma for the high-frequency filter resulted in the mouse's edges being too visible.
Gaussian and Laplacian Stacks
Gaussian stack
A Gaussian stack is a series of images where each image is progressively blurred by repeatedly applying a Gaussian filter. Each level of the stack represents a smoother version of the original image.
Laplacian stack
The Laplacian stack is generated by subtracting consecutive levels of the Gaussian stack, specifically using the formula:\(L[i] = G[i] - G[i - 1] \) .
After getting Gaussian stack and Laplacian stack, we blend them by using this:
$$ blend_{i} = L_{left,i} * mask + L_{right, i} * (1 - mask) $$
Gaussian stack of Apple
Laplacian stack of Apple
Laplacian stack of masked Apple
Gaussian stack of Orange
Laplacian stack of Orange
Laplacian stack of masked Orange
Blended Apple and Orange
Multiresolution Blending
Straberry gummy bear + Orange gummy bear = Strange gummy bear
Apple + Orange = Orapple
Zebra + Oreo = Zereo
Masked Laplacian stack of Zebra
Blend of Zebra and Oreo
Masked Laplacian of masked Oreo
Reflection
I really enjoyed doing this project. It was interesting to see how Gaussians are actually used in different applications. I learned a lot, and it opened my mind to the possibilities of what I can do with such mathematical equations.
Acknowledgment
I used the Unemployables Portfolio Template for this website.