In this part of the project, we examine one of the simplest but most effective kernels: the finite difference filter. This aids us in many important tasks, including edge detection and straightening.
For detecting edges, we calculate the magnitude of the gradient for each pixel in the image. We do this by
first convolving our image with the Dx and Dy kernels. We then calculate the magnitude at each pixel using
this equation.
We then determine a
threshold and take all pixels with a larger magnitude as an edge pixel. Here is the result on the cameraman
image.
|
|
|
In search of better edge detections, we now turn to gaussian kernels. I first created a gaussian kernel and then convolved my image with it. This gave me a blurrier image which I then calculated the gradient magnitued of. This yielded much better results as shown below.
|
We can achieve the same effect by convolving a gaussian and the dx and dy kernels first, and then convolving our image with this new kernel. This works because convolutions are associative. Here are the derivative of gaussian filters that I calculated from this method.
|
|
Now by using these edge detections and gradient calculations, I implemented automatic image straightening. In order to do this, I rotate an image, calculate the angle of the gradient at each pixel, and count how many angles are "good" degrees. Since we like edges to look vertical or horizontal, I counted all 90 degree 180 degree and 0 degree angles. After trying rotations within [-10, 10] degrees, I then took the rotation with the highest number of good angles. Here is the result of my straightening function on the facade image.
|
|
|
|
Here are some other examples:
|
|
|
|
|
|
|
|
|
|
|
|
In this part of the project, we delve more into frequencies and having fun with them.
First, we show how increasing the higher frequencies of the image can result in a more sharp looking result. Convolving an image with a gaussian kernel will result in a low frequency image. Subtracting our original imace then gives us an image with only high frequencies. This can be added back to our original image in order to achieve the sharpening affect. This can also be done by use of the unsharp masking filter, which performs these same actions in a single convolution. Here is an example of the sharpening affect on the taj mahal.
|
|
|
|
Now we try to sharpen an image that has been severly blurred. Notice the affect is minimal since there are not many high frequencies, and the effect that we do see is not very good.
|
|
|
In this part, we create hybrid images by adding high frequencies from one image, to a low frequency image of another. Here are some examples of the results.
|
|
|
|
|
|
Here is a look into the process of combining these images. We show the images in the fourier domain in order to show the reduction of frequencies much clearer. We also show the laplacian and gaussian stack for these images in order to see which features of the images are being removed/contributed not in the fourier domain.
|
|
|
|
|
|
Now to gain more understanding of what these laplacian and gaussian stacks are, we show the stacks for an interesting photo with a lot of high and low frequencies. Notice how different the details are or lack of details are.
|
|
|
Here are some examples from the normal multiresolution blending technique.
|
|
|