CS 194-26: Project 2
Fun with Filters and Frequencies!
Frederick Kim, CS194-26-ABO
Overview
This project introduces the usage of filters and frequencies in image manipulation. I modified images by blurring, sharpening, and merging, while also creating hybrid images.
Part 1: Fun with Filters
Finite Difference Operator
The gradient magnitude image can be found by taking the square root of the sum of the square of the partial derivatives. The formula is also written below.
G=√(Dx)2+(Dy)2
The partial derivatives of the image can be found by taking the convolution with the image and the respective partial derivative kernel as shown below.
Dx=[1−1]Dy=[1−1]
partial dx
partial dy
gradient magnitude
binarized gradient magnitude
threshold=0.2
Derivative of Gaussian (DoG) Filter
We are able to find a better edge image by blurring the image beforehand using a Gaussian filter. Using the same process as explained above to find the gradient magnitude but on a blurred version of the image, we are able to create an edge image that is a lot sharper. Although the gradient magnitude image is darker, with the correct threshold, we can highlight the edges in a way that stands out by making it thicker.
blurred partial dx
blurred partial dy
blurred gradient magnitude
blurred binarized gradient magnitude
threshold=0.05
One Convolution Verification
We are able to create a reusable method of creating more pronounced edge images by taking the partial derivative on the Gaussian filter beforehand. This allows us to simply convolve using the filter derivatives each time rather than having to blur the image. The resulting edge image is roughly the same as blurring the image. The only noticeable difference is that more detail is picked up when using the same threshold.
gaussian partial dx
gaussian partial dy
blurred partial dx
blurred partial dy
blurred gradient magnitude
blurred binarized gradient magnitude
threshold=0.05
Verification
blurred binarized gradient magnitude with blurred image
blurred binarized gradient magnitude with gaussian derivative
Part 2: Fun with Frequencies
Image Sharpening
Below, you can see the progression in the sharpening of the Taj Mahal, a funny man, and a cityscape images. At lower alpha values, the sharpening makes a appreciable difference in the image. However, the higher the alpha, the more grainy the image becomes, making it less appealing.
Sharpening was done by running a high pass filter on the image then adding it to the original image. The high pass filter is done by running a Gaussian filter on the image to find the low frequency then removing it from the image. All blurring with the Gaussian filter was done using a kernel size of 9 and sigma of 2.
For the cityscape image, the image was blurred then sharpened for comparison between the original image and the sharpened image. While there is a noticeable “sharpening” of the image from the blurred version, it does not bring back all the detail to make it the same as the original. The re-sharpened image is not as well-defined with graininess being introduced as the alpha value goes up.
original image
alpha=1
alpha=5
alpha=10
original image
alpha=1
alpha=5
alpha=10
Blur then Sharpen
original image
blurred image
alpha=1
alpha=5
alpha=10
Hybrid Images
Hybrid images are images that show different images at different view distances. To create them, we run a low pass filter on one of the images and run a high pass filter on the other then we combine them together.
For colored images, it is better to use color for the low frequency because it is basis of the hybrid image with the high frequency creating the illusion on top.
nutmeg input
derek input
hybrid nutmeg derek, grayscale
the joker input
christian bale input
hybrid joker christian
lion input
cat input
hybrid cat lion
FFT Analysis
This is the FFT analysis of lion and cat hybrid image
fft of lion
fft of cat
fft of high pass filtered lion
fft of low pass filtered cat
fft of hybrid
Multi-Resolution Blending and the Oraple Journey
Below are the Laplacian stacks in combining the images of an apple and orange.
Regular Masks
lateran obelisk
lateran washington
washington monument
Irregular Mask
This is a multiresolution blending of a cherry tree onto UC Berkeley’s campus. This was done by creating a custom mask in Figma then using it to go through the same process as above.
berkeley
tree in berkeley
tree
Conclusion
The most interesting thing I learned from this project was the multiresolution bending. Although it was difficult to wrap my head around, it was truly fascinating to see how the combination of many different Gaussian filtered images could create such a seamless blending. It was mind blowing when I learned it lecture, and it was even more interesting to see how it is applied in code.
One of the most important things I learned from this project is how convolutions are used as the basis of filters in images. The many use cases of the Gaussian filter was surprising with convolution providing the foundation of those filters. The many different usages of these filters truly opened my eyes to the vast possibilities of image manipulation.
CS 194-26: Project 2
Fun with Filters and Frequencies!
Frederick Kim, CS194-26-ABO
Overview
This project introduces the usage of filters and frequencies in image manipulation. I modified images by blurring, sharpening, and merging, while also creating hybrid images.
Part 1: Fun with Filters
Finite Difference Operator
The gradient magnitude image can be found by taking the square root of the sum of the square of the partial derivatives. The formula is also written below.
G=√(Dx)2+(Dy)2
The partial derivatives of the image can be found by taking the convolution with the image and the respective partial derivative kernel as shown below.
Dx=[1−1]Dy=[1−1]
Derivative of Gaussian (DoG) Filter
We are able to find a better edge image by blurring the image beforehand using a Gaussian filter. Using the same process as explained above to find the gradient magnitude but on a blurred version of the image, we are able to create an edge image that is a lot sharper. Although the gradient magnitude image is darker, with the correct threshold, we can highlight the edges in a way that stands out by making it thicker.
One Convolution Verification
We are able to create a reusable method of creating more pronounced edge images by taking the partial derivative on the Gaussian filter beforehand. This allows us to simply convolve using the filter derivatives each time rather than having to blur the image. The resulting edge image is roughly the same as blurring the image. The only noticeable difference is that more detail is picked up when using the same threshold.
Verification
Part 2: Fun with Frequencies
Image Sharpening
Below, you can see the progression in the sharpening of the Taj Mahal, a funny man, and a cityscape images. At lower alpha values, the sharpening makes a appreciable difference in the image. However, the higher the alpha, the more grainy the image becomes, making it less appealing.
Sharpening was done by running a high pass filter on the image then adding it to the original image. The high pass filter is done by running a Gaussian filter on the image to find the low frequency then removing it from the image. All blurring with the Gaussian filter was done using a kernel size of 9 and sigma of 2.
For the cityscape image, the image was blurred then sharpened for comparison between the original image and the sharpened image. While there is a noticeable “sharpening” of the image from the blurred version, it does not bring back all the detail to make it the same as the original. The re-sharpened image is not as well-defined with graininess being introduced as the alpha value goes up.
Blur then Sharpen
Hybrid Images
Hybrid images are images that show different images at different view distances. To create them, we run a low pass filter on one of the images and run a high pass filter on the other then we combine them together.
For colored images, it is better to use color for the low frequency because it is basis of the hybrid image with the high frequency creating the illusion on top.
FFT Analysis
This is the FFT analysis of lion and cat hybrid image
Multi-Resolution Blending and the Oraple Journey
Below are the Laplacian stacks in combining the images of an apple and orange.
Regular Masks
Irregular Mask
This is a multiresolution blending of a cherry tree onto UC Berkeley’s campus. This was done by creating a custom mask in Figma then using it to go through the same process as above.
Conclusion
The most interesting thing I learned from this project was the multiresolution bending. Although it was difficult to wrap my head around, it was truly fascinating to see how the combination of many different Gaussian filtered images could create such a seamless blending. It was mind blowing when I learned it lecture, and it was even more interesting to see how it is applied in code.
One of the most important things I learned from this project is how convolutions are used as the basis of filters in images. The many use cases of the Gaussian filter was surprising with convolution providing the foundation of those filters. The many different usages of these filters truly opened my eyes to the vast possibilities of image manipulation.