I convolve the cameraman image with D_x = [1, -1] and D_y = [1, -1].T using scipy.signal.convolve2 with mode='same', boundary='symm' to get the partial derivatives. With the partial derivatives computed, I calculate the gradient magnitude by np.sqrt(partial_x**2 + partial_y**2). At the end, I use a threshold of 0.27 to binarize the graident magnitude image.
Now, I try to use Gaussian filter G to blur the image first (by convolving the image with a Gaussian) and then repeat what I have done in part 1 to compute the gradient magnitude and binarize the graident maginitude. There is less noise.
I used a Gaussian filter first to blure the image and then compute the partial derivatives and gradient magnitude. Now I convolve the finite difference operator D_x and D_y first with the Gaussian filter and then compute the gradient magnitude. The results are identical.
To sharpen an image, I first convolve the image with a Gaussian to blur the image which gives a low frequency image. Then, I subtract the low frequency image from the original image to get a high frequency image. Finally, I add the high frequency image (by a factor of alpha) to the original image to get the sharpened image.
The first example is Taj Mahal. The original image is on the left and the sharpened image is on the right. The alpha value is 3.
The second example is a porcelain piece. The original image is on the left and the sharpened image is on the right. The alpha value is 3.
The third example demonstrated are the original image of a swallow, the blurred image, and the sharpened image from the blurred image. The alpha value is 3. We can see that the sharpened image looks identical to the original image but not as smooth as the original one. The edges look more artificial.
Here I am going to make a hybrid image from two images by combining the low frequency part of an image (obtained by passing through a Guassian filter) and the high frequency part of another.
A quick frequency analysis of the hybrid image of cat in low frequency and msn in high frequency.
The first image is a hybrid peach and cat, kind of a failure
The second image is a hybrid hotpot and noodle, kind of a success I think
In this section, I will build a Gaussian stack and a Laplacian stack for an image. The Gaussian stack is built by applying a Gaussian filter to the image multiple times. The Laplacian stack is built by subtracting the Gaussian stack from the original image. The Laplacian stack is used to reconstruct the original image.
Here we apply a mask stacks (a Gaussian stack of masks)
With the Laplacian stacks of both images and the mask image stack built, we can now blend two images together by blending each stage of the stacks and then reconstruct the final image by summing them up. Then we have an oraple!
Here is a blended image of lacroix grapefruit and lacroix lime
To blend this two images, we build a laplacian stacks of both images and a mask image stack. Then we blend each stage of the stacks and reconstruct the final image by summing them up. Here is the result.
Here is a blended image of sun and moon
Here is a blended image of a toy and a potato mine from Plant vs. Zombies. The mask is irregular.