Filters and Frequencies

Oleksii Volkovskyi - volkovskyi@berkeley.edu

Part 1.1: Finite Difference Operator

We can calculate a discrete derivative by taking the difference of two pixels in x and y directions.
This can be expressed as a 2d convolution and implemented with scipy.signal.convolve2d.
This shows us sharp features in x and y directions, as seen below.
We can also combine the 2 derivates into a gradient and use its magnitude (= (∂x2 + ∂y2)1/2) for edge detection.
We can then add a threshold to visualize edges while filtering out noise.

cameraman
Cameraman
dx
Partial Derivative in x
D_y
Partial Derivative in y
gradient magnitude
Gradient Magnitude
Edge image with threshold 0.3
Binary Gradient


Part 1.2: Derivative of Gaussian (DoG) Filter

After applying Gaussian filter:
The edges are thicker and smoother due to Gaussian blurr.
There is less noise in the gradient magnitude and thresholded images.

pdx
Partial Derivative in x
pdy
Partial Derivative in y
grad_mag
Gradient Magnitude
grad_mag
Binary Gradient

The DoG filters:

dogx
DoG Filter in X
dogy
DoG Filter in Y

Convolving the images against the DoG filters produces the same images as convolving against the derivative filter and then the gaussian filter (or in the other order).



Part 2.1: Image "Sharpening"

With unsharp masking:

taj
Original Taj
blur_taj
Blurred Taj
hf_taj
High Frequencies Taj
sharp_taj
Sharpened Taj

We can test out unsharp masking quality by taking an image, blurring it, and then attempting to sharpen it.

breath
Original Album Cover
blur_breath
Blurred Cover
hf_breath
High Frequencies of Blurred Cover
sharp_breath
Blurred then Sharpened Cover
cathedral
Original Cathedral
blur_cathedral
Blurred Cathedral
hf_cathedral
High Frequencies of Blurred Cathedral
sharp_cathedral
Blurred then Sharpened Cathedral

The two images above are blurred and then resharpened using unsharp mask.
The album cover has high frequencies on the right side of the middle. After blurring, the waves look blurry but still present.
Unsharp mask sharpens the waves on the right side of the face; however, does not eliminate the blurriness in the waves.

Furthermore, unsharp mask cannot restore details in people or architecture in the catherdral; however, makes the people higher contrast.



Part 2.2: Hybrid Images

cathedral
Derek
blur_cathedral
Nutmeg
hf_cathedral
Hybrid Image
cathedral
Efros
blur_cathedral
Lion
hf_cathedral
Hybrid Image

close
Efros FFT
smile
Lion FFT
blurred
Hybrid Image FFT

More examples:

cathedral
Forest
blur_cathedral
Deforestation
hf_cathedral
Hybrid Image
cathedral
Child
blur_cathedral
Cat
hf_cathedral
Hybrid Image


Part 2.3: Gaussian and Laplacian Stacks



Part 2.4: Multiresolution Blending

Circular Mask:

Elephant head mask:



Takeaway

Humans perceive separate frequencies within images differently. In order to blend images, the mask's gradient needs to be around the same order of magnitude as the feature.
This means that high frequencies should be blended quickly while small frequencies should be blended smoothly.
Laplacian stack allows us to break an image down into separate frequencies. Then, we can blurr two laplacian stacks by using bigger masks on smaller frequencies. Images can be interpreted in the frequency space to achieve visual and structural effects.