Project 2: Fun with Filters and Frequencies!

Student Name: Kelvin Huang

Part 1: Fun with Filters

Part 1.1: Finite Difference Operator

In this part, we apply the finite difference operator using the humble finite difference as our filter in the x and y directions. This method is essential for calculating image gradients, which help us detect edges and changes in intensity. For edge detection, a threshold of 25 is used.

$$ D_x = \begin{bmatrix} 1 & -1 \end{bmatrix}, \quad D_y = \begin{bmatrix} 1 \\ -1 \end{bmatrix} $$
Gradient X (gx)
Gradient X (gx)
Gradient Y (gy)
Gradient Y (gy)
Gradient Magnitude (gm)
Gradient Magnitude (gm)
Edges
Edges (Threshold = 25)

The gradient magnitude represents the strength of the gradient at each pixel and is essential for detecting edges in an image. It is computed by combining the gradients in the x and y directions. After calculating the partial derivatives \( D_x \) and \( D_y \) using the finite difference operators, the gradient magnitude at each pixel is given by the formula:

$$ \text{Gradient Magnitude} = \sqrt{(D_x)^2 + (D_y)^2} $$ This magnitude provides a scalar value representing how much the intensity is changing at a particular point, with higher values corresponding to sharper transitions (edges). By applying a threshold to the gradient magnitude, we can create a binarized edge image that highlights the most prominent edges while reducing noise.

Part 1.2: Derivative of Gaussian (DoG) Filter

In this part, we apply a Gaussian smoothing filter before taking the gradient to reduce noise and improve the robustness of edge detection.

Smoothed Image
Smoothed Image
Gradient X Smoothed
Gradient X Smoothed
Gradient Y Smoothed
Gradient Y Smoothed
Gradient Magnitude Smoothed
Gradient Magnitude Smoothed
Edges Smoothed
Edges Smoothed (Threshold = 20)

Differences I see: These images appear smoother with reduced noise, while the edges are cleaner and more pronounced. Note: I use a lower threshold here compare to the previous section.

Single Convolution with DoG Filters

Instead of applying two separate operations (smoothing and then calculating gradients), we can use a single convolution with Derivative of Gaussian filters. Here, we create filters by convolving the Gaussian with \(D_x\) and \(D_y\) to compute the gradients directly. Below are the DoG filters and the corresponding gradient and edge images.

DoG Filter (X direction)
DoG Filter (X direction)
DoG Filter (Y direction)
DoG Filter (Y direction)
Gradient X (DoG)
Gradient X (DoG)
Gradient Y (DoG)
Gradient Y (DoG)
Gradient Magnitude (DoG)
Gradient Magnitude (DoG)
Edges (DoG)
Edges (DoG, Threshold = 20)

We can see that the result of DoG is same as the method above. Clear and smooth.

Part 2: Fun with Frequencies!

Part 2.1: Image "Sharpening"

Taj Mahal

Original Image
Original Image
High Frequencies (DoG)
High Frequencies (DoG)
Alpha = 0
Alpha = 0
Alpha = 2
Alpha = 2
Alpha = 4
Alpha = 4
Alpha = 6
Alpha = 6

Motorcycle

Original Image
Original Image
High Frequencies (DoG)
High Frequencies (DoG)
Alpha = 0
Alpha = 0
Alpha = 2
Alpha = 2
Alpha = 4
Alpha = 4
Alpha = 6
Alpha = 6

Sharpened After Blurred: Fishermans

Original Image
Original Image
Blurred Image
Blurred Image
Sharpened Image
Sharpened After Blur

Sharpened After Blurred: My Friend Harry on a Kayak

Original Image
Original Image
Blurred Image
Blurred Image
Sharpened Image
Sharpened After Blur

The blurred and sharpened image, in contrast to the original, shows more noise and visual artifacts. Although the edges become sharper and more defined, there’s a noticeable reduction in the clarity of fine details. Many of the intricate elements from the original are either blurred or entirely lost. The sharpening process enhances edge contrast but also introduces unwanted noise, giving the image a more artificial appearance and compromising its overall quality.

Part 2.2: Hybrid Images

Derek and Nutmeg

Low Frequency Image
Low Frequency Image
High Frequency Image
High Frequency Image
Hybrid Image
Hybrid Image
Hybrid Image (Small)
Hybrid Image (Small)

Curry and Fox

Low Frequency Image
Low Frequency Image
High Frequency Image
High Frequency Image
Hybrid Image
Hybrid Image
Hybrid Image (Small)
Hybrid Image (Small)

My Girlfriend Jessi and Panda (Fail Case) (Hopefully, she won't beat me up.)

Low Frequency Image
Low Frequency Image
High Frequency Image
High Frequency Image
Hybrid Image
Hybrid Image
Hybrid Image (Small)
Hybrid Image (Small)

Pizza and Jellycat (Favorite)

Low Frequency Image
Low Frequency Image
High Frequency Image
High Frequency Image
Hybrid Image
Hybrid Image
Hybrid Image (Small)
Hybrid Image (Small)

Frequency Analysis

Fourier High Frequencies
Frequencies

Part 2.3: Gaussian and Laplacian Stacks

Image 2.3.1
Gaussian Stack
Image 2.3.2
Laplacian Stack
Image 2.3.3
Recreation of Figure 3.42
Image 2.3.4
Final Blended Result

Part 2.4: Multiresolution Blending (a.k.a. the oraple!)

Apple
Apple
Orange
Orange
Mask (Left to Right)
Mask (Left to Right)
Oraple
Oraple
Minion Resized
Minion
Avengers Resized
Avengers
Minion Mask Resized
Minion Mask
Avengers + Minion
Avengers + Minion
TNT Resized
TNT
Warriors Resized
Warriors
TNT Mask Resized
TNT Mask
Warriors + TNT
Warriors + TNT

The avengers and minion is my favorite. Below are the Laplacian stacks for this blended image.

minion_avengers_procedure
Laplacian stacks

Takeaways: One of the most important things I learned from this project is how critical different frequency components are in shaping an image's appearance. Low-frequency components capture the overall structure and smooth transitions, while high-frequency components define sharp edges and fine details. Through tasks like hybrid images and multiresolution blending, I realized that manipulating these frequencies allows us to control which parts of an image dominate perception, depending on the viewing distance or how the image is processed. For example, high frequencies are key to enhancing sharpness and edges, but too much can introduce noise. On the other hand, low frequencies give an image its general shape but can obscure important details if overused. This project deepened my understanding of how balancing these frequencies is essential to achieving both clarity and visual appeal in image processing.