Project 2

Part 1: Edge detection

Gradient Magnitude Computation

Gradient Magnitude Computation is a tool used to detect edges in an image. It works by taking the horizontal and vertical partial derivatives, and calculating the Euclidean norm of these derivatives. The idea is that an edge will occur in parts of the image where values change at a high rate, so thus a derivative/gradient magnitude would be used to measure this.

Demo

Original image
Partial Derivative for x
Gradient Magnitude
Partial Derivative for y
Binarized, finalized edge image

1.2: Derivative of Gaussian (DoG)

While the results above are able to capture edges, there’s still a lot of artifacts. One trick to solve this is to smooth out the original image first with a gaussian kernel before we run it through our Gradient Magnitude edge detection. Here are the results:

Original
Partial Derivative for x of blurred image
Gradient Magnitude of blurred image
Blurred
Partial Derivative for y of blurred image
Binarized, finalized edge image of blurred image
Instead of doing 3 separate convolutions on the image, we can skip the gaussian filter and instead use a gaussian kernel convolved with the original partial derivative kernels.

Using a gaussian filter convolved with the original partial derivative kernels results in similar edge images.

Main differences when using DoG vs Finite Difference Operator:

Part 2: Fun with Frequencies!

Image Sharpening

Below are some examples of images that were sharpened by simply subtracting a little bit of the low frequencies and normalizing back up (this essentially boosts the higher frequencies of the image).

Original

Sharpened

Changing the amounts of sharpness (for fun)

original
alpha=1.5
alpha=1.0
alpha=2.0

Hybrid images

Another cool thing you can do with frequencies is combine two images; when combining the high frequencies of an image image1 with the low frequencies of another image image2, you can get an image that looks like image1 up close, and image2 from afar. Here’s some examples:

From a far, the image looks like Derick, but up close the image looks like nutmeg.

A colored image, which sorta works, but kinda fails because the bread is too long.
bred.jpg
cat.jpg
Thunder cat, and a picture of a cat.
thundercat.jpg
catthunder.jpg

Multiresolution Blending

One really cool trick that can be done is blending two photos together. Essentially, you can take a mask, img1, img2, and take the laplacian stack of all the two images, and the gaussian stack of the mask. Then, you can combine the images on each of the layers of the stacks, and collapse the resulting stack into a single image.

orange + apple
cat + bread
celebrity mashing