Fun with Filters and Frequencies!

Name: Tzu-Chuan (Jim) Lin

Part 1 - Fun with Filters

Part 1.1: Finite Difference Operator

img * Dximg * Dy
dimg magnitudeBinarized dimg magnitude

Notice:

  1. The gradient magnitude = sqrt((dimg/dx)**2 + (dimg/dy)**2)

Part 1.2: Derivative of Gaussian (DoG) Filter

 Only Dx/DyBlur and Dx/Dy
Dx
Dy

A:

I find there are less visual artifacts on the edges and somehow these edges are more connected.

And the ground's part without blurring is more like pepper noise. But after blurring, the ground looks smoother and visually pleasant.

 Blur and then Dx/Dyimg * (gaussian * Dx/Dy)
Dx
Dy

A:

They are almost the same. One interesting thing is: I originally use cv2.filter2D(gaussian, cv2.CV_32F, Dx) to convolve the original image. However, I found that the result is always very different from using signal.convolve2d.

I think this is caused by: The convolution associativity only holds when using full mode convolution (cv2.filter2D is always the "same" mode) Otherwise, the associativity will not hold. (The easy way to think of it is by polynomial multiplication: (f*g)*h == f*(g*h))

Part 2: Fun with Frequencies!

Part 2.1: Image "Sharpening"

 Originalalpha = 1alpha = 2alpha = 3
taj.jpg

Image source: https://unsplash.com/photos/dqXiw7nCb9Q

 parkinglot.jpg
Original
Blurred
alpha = 1
alpha = 3
alpha = 5

A: Observations:

  1. alpha = 1 and alpha = 3 are still a little blurry.
  2. alpha = 5 almost contains no blurry parts. But the lines in the images become thicker due to the sharpening effect.
  3. As alpha becomes greater, the image becomes brighter.

Part 2.2: Hybrid Images

DerekNutmeg
Derek frequency magnitudeNutmeg frequency magnitude
 Blurred DerekHigh frequency Nutmeghybrid
Spatial Domain
Frequency Domain
ParrotOwl
Parrot frequency magnitudeOwl frequency magnitude
 Blurred ParrotHigh frequency Owlhybrid
Spatial Domain
Frequency Domain
NikeAdidas
Nike frequency magnitudeAdidas frequency magnitude
 Blurred NikeHigh frequency Adidashybrid
Spatial domain
Frequency domain

Observations:

  1. The blurred image in frequency domain clearly gets rid of high frequency components
  2. You can notice the Adidas image that is filtered by Laplacian of Gaussian in frequency domain has larger white region because its lower frequency components are removed by the high-pass filter and high frequency components are strengthened.
  3. It is hard to align owl and parrot well because they stand in a slighly different posture.

Part 2.3: Gaussian and Laplacian Stacks & Part 2.4: Multiresolution Blending (a.k.a. the oraple!)

OrangeGaussian stacksLaplacian stacks
depth = 0
depth = 1
depth = 2
depth = 3
depth = 4
AppleGaussian stacksLaplacian stacks
depth = 0
depth = 1
depth = 2
depth = 3
depth = 4

NOTE: The last level of Laplacian is the same as the Gaussian's last one. But I apply normalization. That is why they look different to each other.

I implemented the algorithm according to the algorithm presented on the paper and the lecture slide:

The intermediate result (similar to Figure 3.42)

And the Orapple:

CarMeMerged

The intermediate result:

ParrotAlpaca
MaskDirect PasteMerged

The intermediate result:

Conclusion:

Conclusion

From this homework, I learn that:

  1. Human perception of whether a thing is natural or not is highly related to frequency domain!
  2. How to manipulate images in frequecy domain! Before this homework and related lectures, I don't know we can maninuplate image in such way!