In this project, I explore the properties of filters and frequencies when applied to different images, and use the techniques described to create cool and interesting images. Enjoy!
Let's start with our image of the cameraman. We can apply the finite difference operator in the x and y direction as a filter by convolving it with the original image to get the partial derivatives of the image in the x and y direction.
We can now create a gradient magnitude image, which will be an effective edge detector! To compute the gradient magnitude, we first get the image of the partial derivative in the x direction, then get the image of the partial derivative in the y direction. Then, for each pixel, we compute the gradient magnitude at that pixel as in the equation below, where f_x is the partial derivative in the x direction and f_y is the partial derivative in the y direction.
Once we have the gradient magnitude image, we can increase the contrast by taking all the pixels with a value above a certain threshold and make them white, and make all other pixels black.
This makes for a fairly good edge detector, but we can make it better by blurring the image using a gaussian filter before we take the gradient magnitude. This smooths the edges over a longer distance, and makes the edges thicker.
Oftentimes the photos we take are not straight, which most people fix by manually rotating the image to fix it. For this part, I wrote an algorithm which finds a rotation that will yield the highest amount of horizontal and vertical lines, automating the process of rotating an image to the correct angle, as shown in the sample images below. For each image, the algorithm
As a first foray into the world of frequencies, we will "sharpen" images! By taking only the high frequency parts of an image and adding them into the original image, we can make images appear sharper since images with stronger high frequencies will pop more and appear sharper. Note that this does not actually make the image sharper and is just an illusion, since no additional information is being added to the image. We can implement this using one filter, known as the unsharp mask filter. When applied, we get the results shown below.
The result of trying to sharpen an already sharpened image is that the image appears darker, and appears as more of an outline than an image . In the case of black and white images, this does make it look sharper. An example of applying the filter three times is shown on the pinapple below
Hybrid images are images that look like one thing from up close, and something different from far away. This affect is achieved by taking the high frequency components of one image and the low frequency components of another image and stacking them. From up close the viewer notices the high frequencies, and from far away the viewer can only make out the low frequencies. Here are some examples of such images. This is based on a paper here
This is a failure case because from a distance, the pineapple is not very distinguishable as more than just an outline. This is because the pineapple contained a lot of high frequency content, and after being passed through a low pass filter, that content went away. This shows that high frequency content does not work well for the background of these types of images.
A Gaussian stack is a set of image where each level of the stack gets progressively blurrier as it is passed through a low pass filter each time. A Laplacian stack is a stack where each layer represents a specific band of frequencies within that image. Here are examples of a gaussian and a laplacian stack on the painting "Lincoln in Dalivision" by Salvador Dali.
The Gaussian and Laplacian stacks in the previous section can be used to create smooth splines, as described in the paper here.
One of the most interesting things I learned over the course of this project was