First, I convolved the image of the cameraman with the finite difference operators D_x = [1, -1] and D_y = [[1], [-1]] to get the image's x-partial derivative and y-partial derivative. I then used the gradient magnitude formula to create the gradient magnitude image of the cameraman. The gradient magnitude formula is sqrt(xpartial**2 + ypartial**2). In order to generate the edge image of the cameraman, I used a threshold = 0.2.
In this part, I convolved the image of the cameraman with a gaussian filter in order to blur the image. The 1d gaussian kernel was created using cv2.getGaussianKernel() with a kernel size = 2 and a standard deviation = 10. The 2d gaussian kernel was created by taking an outer product of the 1d gaussian with its transpose. I then repeated the same steps for the previous part using the blurred image. The most notable difference between part 1.2 and 1.1 was that the edges were much more defined in the edge image of 1.2. The blurring effect also made the edges smoother in 1.2.
Another approach I took with this part was to convolve the gaussian filter with D_x and D_y. Then, I used these Derivative of Gaussian filters in the same process as 1.1. I convolved these DoG filters with the original cameraman image. After producing these images, I can confirm that both methods produce the same results.
First, I created a 2d gaussian kernel using cv2.getGaussianKernel() with a kernel size = 10 and a standard deviation = 2. I then convolved this gaussian kernel with the original image of the Taj Mahal to blur it. I then subtracted the blurred image from the original image to produce an image of the high frequencies. I then multiplied the high frequency image with an alpha value which I declared as alpha = 2, and added this back to the original image. Formula: Sharpened_image = original_image + alpha * high_frequency_image.
Here are the results of the sharpening effect on a picture of myself. This time I used a kernel size = 30 and a standard deviation = 100. Alpha was still set to a value of 2.
The goal of this part is to take two different images and create a hybrid image. In this hybrid image, the viewer will be able to see one picture from up close and the other picture from far away. To do this, I applied a high pass filter to one image and a low pass filter to the other image. For the low_pass, I convolved a gaussian kernel to the image to create a blurred version of that image. For the high_pass, I first created the blurred version of the image and then subtracted the blurred version from the original version. I then blended the high frequency image with the low frequency image to create the hybrid image.
Here's another example with two different images along with the Fourier analysis, which shows the log magnitude of the Fourier transform for each image.
Here's an example of a failed hybrid image between Mike Wazowski and Mario. This hybrid image failed due to Mike Wazowski only having one eye to Mario's two eyes. This made it difficult to effectively align the images.
In this part, I created Gaussian and Laplacian stacks for the images that I want to blend together. For the apple and orange images, I first created Gaussian stacks with 5 levels each. I used a Gaussain kernel with a kernel size = 10 and a standard deviation = 10 to create increasingly blurred images at each level. I would take the image at the current top level and then apply the blur to that image. I then placed the newly blurred image at the top of the stack. To create the Laplacian stack, I took the Gaussian stack and subtracted the layer of the next index from the layer of the current index to create a series of high frequency images. The last layer of the Laplacian stack is the same as the last layer of the Gaussian stack.
To finish up the set up for the blending of images, I created another Gaussian stack for the mask that I would be using to combine the images of the apple and orange. For this mask, I used a kernel size = 100 and a standard deviation = 5000. I then iterated through the layers of the Gaussian stack of the mask along with the layers of the apple and orange Laplacian stacks. For each layer, I multiplied the image of the apple Laplacian with (1 - Gaussian mask) and added that to the product of the orange Laplacian with (Gaussian mask). After iterating through all of the layers, I then summed up all of the layers of the resulting stack to produce the final oraple image.
Here are some other example images!
Overall, I really enjoyed this project. It was really interesting to learn about all of the flitering and blending techniques. The most important thing I learned from this project is becoming familiar with all of the necessary steps that go into blending an image. I was able to gain a good understanding of Gaussian and Laplacian stacks, and I was also able to gain expertise in tweaking parameters to improve upon an image's outcome.