Project 2

Fun with Filters and Frequencies! Ft. a lot of Professor Efros' face. Note: will require side scrolling to see some images

cathedral cathedral

Part 1: Fun with Filters

Part 1.1

The binarized gradient magnitude image of the cameraman. The threshold I chose was 0.1. To compute the gradient magnitude image, I simply took the magnitude of each vector (a, b) for pixel a and corresponding pixel b in the convolved images. Then, I mapped the pixels to 1 if they passed the threshold and 0 if they did not.

binarized gradient magnitude image original gradient magnitude image
cathedral monastery

Part 1.2

Here, I convolved the original images with the 2d gaussian before doing the above procedure. The gaussian I chose had a size of 7 and an alpha of 2, as this seemed to work well. The original gradient magnitude image and the thresholded image are shown. The lines are much thicker, and the noise from the field is now gone. On the far right, I convolved the gaussian filters with the finite difference filters first, before convolving the derivative of gaussian filter with the original image. The result is basically the same, with some minor differences likely due to pixel offsets from the convolution operation.

binarized gradient magnitude image original gradient magnitude image binarized gradient magnitude image with DoG horizontal DoG filter
cathedral monastery cathedral monastery

Part 2: Fun with Frequencies

Part 2.1

I created the unsharp mask filter based on the equation shown in class. With a single convolution, it is a simplification of taking the original image and subtracting a gaussian blurred image, then adding back the original image. The result is the original image + the highest frequencies of the image, making it look sharper.

Images of the given Taj:

Original taj Blurred taj Sharpened taj Blurred then sharpened taj
cathedral monastery cathedral monastery

Doing the same procedure on a tiger:

Original Blurred Sharpened Blurred then sharpened
cathedral monastery cathedral monastery

As described above, the images to the far right are the blurred images (original convolved with gaussian) which are then sharpened with the same unsharp filter. Compared to the original image, there is clearly a lot less detail, which makes sense as the gaussian filter causes some loss of information. However, when looked at peripherally or when squinting, the sharpened blurred image looks much more similar to the original image than the blurred image. This might be because the frequencies of the blurred then sharpened image are more similar to the original image. With the tigers, the black stripes are faded in the blurred image, but look pretty similar to the original in the sharpened blurred image.

Part 2.2

To create hybrid images, I created a low frequency image and high frequency image out of two aligned images. The low frequency image simply was convolved with a gaussian filter, with the spread of the gaussian as a hyperparameter (i.e. the cutoff frequency). For the high pass image, I convolved the image with another gaussian with a different alpha (another hyperparameter) then subtracted the blurred image from the original. Note that for these images, I only used one grayscale channel for the hybrid images. Adding the two images together produced such results:

Original image of Abbeel Original image of Efros Hybrid
cathedral monastery cathedral
Fourier transform of Abbeel Fourier transform of Efros Fourier transform of low-pass Abbeel Fourier transform of high-pass Efros Fourier transform of hybrid
cathedral monastery cathedral monastery cathedral

Note: the first two fourier transforms are of all 3 channels in the original images, hence being in color despite the other ones being grayscale and single-channel.

Here are some other images (may need to zoom out or scroll horizontally due to size, I am bad at html). The last one of Berkeley and the other school doesn't work that well, because Berkeley and Stanford can never mesh (and because of the lack of distinctive features in the image and overlap):

tiger cat hybrid
cathedral monastery cathedral
nutmeg derek hybrid
cathedral monastery cathedral
stanturd berkeley hybrid
cathedral monastery cathedral

Part 2.3

I created the gaussian stack by iterating through alphas between 0 and a given alpha, dividing it into 5 levels of blur (i.e. I used max alpha = 10, so the gaussians had alphas of 0, 2, 4, 6, 8, and 10). For each alpha, I appended a blurred image (original convolved with gaussian with the respective alpha) to the pyramid/stack. Then, to create the laplacian pyramid, I simply took the difference between each of these images, with the final image as the most blurred image in the gaussian pyramid. i.e., the laplacian pyramid had the original image minus the image blurred with alpha = 2, then the image blurred with alpha = 2 minus the image blurred with alpha = 4, and so on. The sum of the images in laplacian stack thus becomes the original image. Below are images from the resulting laplacian stacks of the orange and apple:

original orange, for reference
cathedral cathedral cathedral cathedral cathedral cathedral cathedral
original apple, for reference
cathedral cathedral cathedral cathedral cathedral cathedral cathedral

Part 2.4

To blend the two images, I made a mask that was just a step function: all 1s on the left and all 0s on the right, with the same dimensions as the given images. I made a mask stack by blurring the mask with different gaussian alphas as in the process of making the gaussian stack above, except I used a higher max alpha (30) because it yielded better results. There were still 6 total images in the stack. To blend the orange and apple, at each level in all of the stacks, I multiplied the apple by the mask and the orange by the inverse of the mask (1 - mask), then added these two results together to get a final laplacian stack of the oraple. Then, all I had to do was sum up the images in the stack to get a perfectly blended oraple. See the laplacian stack of the oraple, as well as the final result:

Final oraple!
cathedral cathedral cathedral cathedral cathedral cathedral cathedral

Here are a couple fun images with the same vertical line filter

Stanford Berkeley Stankeley
cathedral cathedral cathedral
Fall Spring Fring
cathedral cathedral cathedral

Are you ready for an abomination?

Live action pickle rick (padded the rick image to make this work) (same procedure with gaussian and laplacian stack, just different mask):

Pickle Rick Mask LOOK MORTY I'M PICKLE RIIIIICK
cathedral cathedral cathedral cathedral

Efros the Tank Engine

Efros Thomas Mask choo choo computer vision
cathedral cathedral cathedral cathedral