In this project, I used various convolutions and filtering in order to produce gradient maps of input images. I also appled these methods to blur, straighten, and sharpen images. I also explored image manipulation further by creating hybrid images and blended images, with the help of low / high-pass filtering and Gaussian / Laplacian stacks.
This section of the code convolves the input image with the finite difference filter. I used two convolutions, one for dx and one for dy, and combined their magnitudes to produce the gradient magnitude image. Afterward, I binarized the gradient magnitude using a threshold. I experimented with various thresholds and found that .25 worked best to give a clear outline of the camera and the man while not detecting noise.
|
Here I took a length-5 1D Gaussian filter courtesy of Stack Overflow and multiplied it with its transpose in order to derive a 2D Gaussian filter. This then only requires a single convolution to produce the same result as the previous part which required two convolutions. As above, I binarized the gradient magnitude using a threshold which I found to be .1 here, which is lower than the previous. Given these different thresholds, I am able to produce a result very similar to before.
|
|
|
|
I went about writing the code for straightening images by first thinking about the search radius. I originally tried a search from [-20, 20] but found that the rotation was much greater than what it is needed for the average tilted picture, and decided that a search range of [-10, 10] would still succeed in most use cases while only taking half of the time. I iterated through all of the selected angles (chosen with approximate step size of 2) and I computed the gradient angle by convolving the image with the Gaussian filter. I then summed up all angles close to [0, 90, 180, 270] in the image. Inception is a failure case and park and facade are success cases.
|
|
|
|
|
|
|
|
|
I sharpened these images by applying a low pass filter to the original image and subtracting it from the original. Additionally, I add back in some of the high frequencies. This is known as the unsharp mask filter.
|
|
|
|
I also implemented hybrid images using the starter code and implementing my own low pass and high pass filters and averaging the resulting images.
|
|||
|
|
|
|
|
|
|
|
I implemented Gaussian and Laplacian stacks on the sample image of Lincoln and Gaia.
|
|
|
|
I implemented blending as described in the paper.
|
|
|