Here we experiment with finite derivative operators and their effect on an image. We take the partial derivative in the x and y direction and get the results below:
dx operator
dy operator
gradient magnitude
The third image displays the gradient magnitudes of the image, which is the square root of the sum of the partial derivatives, as seen in the equation below:
Part 1.2 Derivative of Gaussian (DoG) Filter
The edge detection in the first part saw some noise in the edges. Here we use a gaussian smoothing filter to decrease this noise. We then convolve the image with the two finite difference operators above to obtain a derivative of gaussian filter. In the image below, we see that the edges of figures are much more pronounced, with less noise in the lines. We also see clearer edges in the background buildings, which we were unable to pickup strongly in the previous part.
Part 1.3 Image Straigtening
In this part, we use our previous gaussian magnitude definition to detect horizontal and vertical edges in images and straighten the image. We define a gradient as horizontal or vertical if arctan(dy/dx) is in [0, 90, -90, 180, -180] and only count the angle if the gradient magnitude is above a certain threshold. This differentiates true vertical / horizontal edges from areas of images that are just the same color (in which dx and dy are both 0). We can see here that the room rotation is a failure case due to the strange angle the picture was taken at.
Before Rotation
After Rotation
Before Rotation
After Rotation
Before Rotation
After Rotation
Here we use our gaussian filter from before and subtract it from an image to get the high frequencies of an image. Adding layers of high frequency to the original image will make an image appear "sharper". An example on the taj is shown below as well as an example of Emma watson.
Before Sharpening
After Sharpening
Before Sharpening
After Sharpening
As another experiment, I tried blurring an image and sharpening an image to see if we could obtain the original. Below are the original, blurred, and resharpened images. As we can see, the filter did a pretty good job of recreating the original photo.
Original
Blurred
Resharpened
In this part, we use a low pass filter for one image and a high pass filter for another image and combine the two to get a hybrid image. The low pass filtered image can be seen at a distance while the high pass filtered image is more prominent upclose. We see in the third example, that this is a failure, as the image proportions simply do not line up (the creepy dog's face shape does not match with the girl's face no matter what).
hybrid cat man
hybrid young and old woman
hybrid Nina Tucker
My favorite result is the old woman and young woman hybrid image. At a distance, you see the young woman, but up close, you see the old woman. The fourier images for the process are seen below:
woman
old woman
low pass
high pass
hybrid
In this part, using the previous gaussian filter, we have one stack with an additional gaussian filter at each step, and another stack, with an additional gaussian filter subtracted at each step.
Gaussian StackUsing the previous gaussian stacks and laplacian stacks, we are able to blend two images together with an additional mask image. The mask image I chose for the orange-apple example below is vertical split mask, where half the image is black and half the image is white. We then create one laplacian stack each for the apple image and the orange image and a gaussian stack for the mask image. Using the mask as part of a weighted function, we then add the two laplacian images at each level of the stack, and sum up the images at the end. The gaussian stack for the mask image allows us to create a smooth transition rather than a clear divide between the two images.
The most interesting thing I learned from this project is how versatile the gaussian filter is. I've seen terms like 'gaussian blur' in digital art tools but never thought about it in terms of finite difference operators or for example, using gaussian blurs in sharpening images. In this project, almost every single part used a gaussian filter, and that's really cool.