Project 2
Class | CS 180 |
---|---|
Type | project |
Person | Sam Huang |
Fun With Filters and Frequencies
This project explores filters and frequencies of images and aim to achieve creative effectives through convolution, Gaussian filters, and Gaussian and Laplacian stacks.
Finite Difference Operator
This part is to detect edge of an image through convolution and gaussian filter. We take the partial derivative of the image in both x and y directions by convolving the image matrix with and , respectively. Then we get the gradient from which will get us the edge of the image. Sometimes, this would be better if we blur the image through a Gaussian filter which would smooth the edge and give us better result (the edge would be more continuous).
Original
Gaussian
DoG
dx
dy
gradient
binarized
You can see that the binarized version of the gradient is the same for Gaussian and derivative of Gaussian, this is because of the associative property of convolution: .
Image Sharpening
This part focus on sharpening the image using the blurry version of the image through Gaussian filter. We first get detail by subtracting the blurry image from the original, and add a specific amount of detail back to the origin, creating a sharpening effect.
original
blurry
enhance
Hybrid Images & Fourier Transform
We can actually combine two images into one where you can only see one of them far away and another close up. This is because we can filter the high frequency from one and low-frequency from another. For low-pass filter, we can use the standard 2D Gaussian filter. For high-pass filter, we can use the impulse filter minus the Gaussian filtered image. In my implementation, I finds using sigma value of 20 for low-pass and 10 for high-pass while keeping the kernel_size equals three times the sigma value generally work pretty well. Here you can see some examples.
nutmeg
broccoli
dog
derek
mushroom
horse
dermeg
mushccoli
hordog
For mushccoli, it is kind of a failure because even close up the mushroom might appear more obvious than broccoli, this is probably due to the red color of the mushroom, which hides the detail of broccoli, and a high contrasct by the white dot on mushroom. Hordog is my favorite, you can see some Fourier Transform frequencies of the process that makes hordog.
dog
horse
dog_low_filter
horse_high_filter
hybrid: hordog
Images Blending
This part use Gaussian and Laplacian Stacks two blend two images together. We create Laplacian Stacks of a certain layer amount for each image, and multiplies each layer with the corresponding layer of Gaussian stack for the mask. We then add all them together on each layer, and then collapse the result stack. Specifically, for each RGB channel of each layer of the result stack,
Then we can have the final output by collapsing the result stack: .
Besides Oraple, I creates two extra blended images Sprike and Liger. Sprike is more like a failure comparing to Liger, this is because the red and green colors are too contrasting to each other, and thus make the blending effect looks bad. Also, the word printed on two cans are not aligned to the same height and thus look off. But Liger looks a bit too real!
Oraple
Normalized Laplacian Stack for orange and apple
Gaussian Stack for regular shape mask
Result Stack
Oraple
Sprike
Sprite
Coke
Sprike
Liger
Tiger
Lion
Irregular Mask
Liger