Fun with Filters and Frequencies!

Catherine Chu

Part 1.1: Finite Difference Operator

orig_cam

To begin, the cameraman image is convolved with both finite difference operators D_x and D_y. The gradient magnitude is calculated by taking the magnitude, or norm, of these gradient components: grad_mag = np.sqrt(dx**2 + dy**2). This gradient magnitude image is binarized with a selected threshold, where values above the threshold qualify and are displayed as edges.

dx
dx
dy
dy
gm
Gradient Magnitude
bgm
Binarized

Part 1.2: Derivative of Gaussian (DoG) Filter

Seeing that the edges detected above are rather noisy, the cameraman image can be blurred before performing the process, as shown below. The differences that we see include the edges being thicker and smoother, as well as less noise on the man, camera, and background.

blur_cam

Blurred cameraman image

blur_dx
dx
blur_dy
dy
blur_gm
Gradient Magnitude
blur_bgm
Binarized

Blurring and computing the gradient magnitude can also be completed in a single convolution: by convolving the blurring/gaussian filter with D_x and D_y, the resulting DoG filters can be directly applied to the original cameraman image.

gdx_filter gdy_filter

DoG filters: with respect to x on the left, y on the right

gdx
Gaussian dx
gdy
Gaussian dy
dog_gm
Gradient Magnitude
dog_bgm
Binarized

Part 2.1: Image "Sharpening"

Images can be "sharpened" using the unsharp masking technique. This can be done in two ways:

Below are results for different values of alpha, showing the progression of the original to sharpened images.

taj
Taj Mahal
taj1
alpha=1
taj2
alpha=2
taj4
alpha=4
bridge
Golden Gate Bridge
bridge1
alpha=1
bridge2
alpha=2
bridge4
alpha=4

The following progression tries first blurring, then sharpening an image. The sharpened image clearly loses a lot of the original's detail, is noisy, and contains artifacts.

ny
Little Island, NY
blur_ny
Blurred
ny4
Sharpened
(alpha=4)

Part 2.2: Hybrid Images

Hybrid images (are static images! that) change with the viewer's distance to the image. From the blending of high frequencies of one image with low frequencies of another, the viewer sees the first image when they are up close, and the second when they are far.

nutmeg
Nutmeg (High)
derek
Derek (Low)
gm
Nutmeg + Derek
puppy
Puppy (High)
nugget
Nugget (Low)
puppy_nugget
Puppy + Nugget

This is an example of a failure. Since the shapes of Eren's normal face and Eren's Titan face are different sizes, it was difficult to align the two images (the final attempt tries to align the noses), resulting in a less convincing hybrid image.

titan
Titan (High)
old
Eren (Low)
titan_old
Titan + Eren

The following also demonstrates a Fourier analysis. The two filtered versions of the input images keep the respective high and low frequencies, which are then combined for the final hybrid image.

young
Young Eren (High)
old
Old Eren (Low)
young_old
Young + Old
fa_in_young
Young Eren
fa_in_old
Old Eren
fa_fil_young
Young Eren Filtered
fa_fil_old
Old Eren Filtered
fa_hybrid
Young + Old Filtered

Part 2.3: Gaussian and Laplacian Stacks

Before multi-resolution blending, Gaussian and Laplacian stacks are created. Gaussian stacks involve repeatedly applying the Gaussian filter at each level of the stack, and Laplacian stacks involve subtracting a level of the Gaussian stack from the previous level. However, the final level of the Laplacian matches the final level of the Gaussian so that the original image can be reconstructed by collapsing the Laplacian stack.

Stacks of an apple:

apple
apple_g1 apple_g2 apple_g3 apple_g4 apple_g5

Gaussian stack of apple

apple_l1 apple_l2 apple_l3 apple_l4 apple_l5

Laplacian stack of apple



Stacks of an orange:

orange
orange_g1 orange_g2 apple_g3 orange_g4 orange_g5

Gaussian stack of orange

orange_l1 orange_l2 orange_l3 orange_l4 orange_l5

Laplacian stack of orange

Part 2.4: Finite Difference Operator

To perform multi-resolution blending, each level of the Laplacian stacks across two images are blended together. This blending works best with similar Gaussian blurring of a mask. The combined layers are finally compressed into the blended image.

oraple
oraple_l1 oraple_l2 oraple_l3 oraple_l4 oraple_l5

Combined Laplacian stacks to create oraple

mario
Mario
peach
Peach
princess_mario
Princess Mario
prin_mario1 prin_mario2 prin_mario3 prin_mario4 prin_mario5

High-resolution blending of Mario and Princess Peach



The following blending example involves an irregular mask:

irreg_mask

Irregular mask

cat
Cat
avengers
Avengers
angry_avengers
Angry Avengers
ang_aven1 ang_aven2 ang_aven3 ang_aven4 ang_aven5

High-resolution blending of Angry Cat and Avengers