First, I convolved the cameraman.jpg image with the finite difference filters Dx = [1, -1] (row) and Dy = [1, -1] (column) in order to find the partial x and y derivatives.
Next, I computed the gradient magnitude of the image by summing the squared partial derivatives Dx and Dy and then taking the square root.
Finally to create an edge image, I binarized the gradient magnitude image by selecting a threshold for which where values are greater than or equal to the threshold, we set it equal to 1 and otherwise we set the value equal to 0.
To create a 2 dimensional Gaussian filter, I used the function cv2.getGaussianKernel() to create two 1 dimensional kernels and took the outer product.
I then convolved the cameraman image with this 2D Gaussian filter and repeated the steps outlined in part 1.1 to create another gradient magnitude image and binarized edge image.
This method of using a Gaussian filter first yields a clearer image with less noise.
Another method that I tried was to create a derivative of gaussian filters and convolve the Gaussian filters with Dx and Dy. Then I convolve the cameraman image with this DoG filter. It turns out that we get the same result as before!
To get a sharper image, I first blur the image and convolve it with a Gaussian filter. To isolate only the high frequencies in the photo, I then subtract the blurred image from the original image. Finally, I add the high frequencies to the original images to enhance them and get the sharpened image. The sharpened image contains more detail than the original image.
To create a hybrid image of two images, I combine the high frequencies of one image with the low frequencies of the other. I get the low frequencies by blurring the image with a Gaussian filter. I get the high frequencies by subtracting the low frequencies from the original image.
I attempted to make a hybrid image of Mark Wahlberg and Matt Damon. However, the picture of Matt Damon seems to be much concentrated and we can't really see any detailed features of Mark Wahlberg that well.
I incorporated color into my hybrid images to enhance the effect. To accomplish this, I applied the method above of combining low frequencies and high frequencies of each image to all 3 color channels. For the images I used, it seemed to work better to use color for both low frequency and high frequency components.
To create the Gaussian stack, I convolved the original image with a Gaussian and kept convolving for each level. To create the Laplacian stack, for each level, I took the difference between images in same level of the Gaussian stack and the previous level of the Gaussian stack.
Apple Gaussian Stack Images: Orange Gaussian Stack Images: Apple Laplacian Stack Images: Orange Laplacian Stack Images:To blend two images, I create a mask, a Gaussian stack of the mask, a Laplacian stack of the first image, and a Laplacian stack of the second image. Then, I combine the Laplacian stacks with weights from the mask's Gaussian stacks.
Oraple Mask# 1 Blending a daytime background with a night time background
Mask# 1 Blending a doorway with a nebula background.
Mask Blended Nebula Door Laplacian Stacks