Final Projects

Aditya Yadav


Project 1: Seam Carving:

Background

This project is inspired by the paper Seam Carving for Content-Aware Image Resizing by Shai Avidan and Ariel Shamir. Essentially the goal was to shrink images by removing pixels, while keeping everything important. This is done by first using an energy function and figuring out which pixels are most important.

Energy Function

The energy function used in this project was simply the magnitude of the gradient vector for each pixel. The image was convolved with a [-1,1] and [-1,1]^T filter to figure out the x and y derivatives and then they were squared and added together, then square rooted.

Finding the Seam

The seam was then found using dynamic programming. Basically, for each pixel i,j in the energy matrix we want to find the cost of the lowest energy path from the top of the image to that pixel. To start, the top most pixels are just set to their energy. Then for each pixel below them, we compare to see the value of the pixel above them, and above and to the sides. The min of these 3 are chosen and added. Finally you traverse up from the bottom to find the least path and remove it.

Example 1

The first example of seam carving is done on this photo:


First a seam is found, this is an example:

The seams are them removed. In this case, 100 seams were removed here to give this:
Then the image is rotated and a new energy matrix is found and more seams are found.
They are removed to give the result. Here 50 seams in this direction were removed.

Example 2

The next example of seam carving is done on this photo:


First a seam is found, this is an example:

The seams are them removed. In this case, 75 seams were removed here to give this:
Then the image is rotated and a new energy matrix is found and more seams are found.
They are removed to give the result. Here 50 seams in this direction were removed.

Example 3

The next example of seam carving is done on this photo:


First a seam is found, this is an example:

The seams are them removed. In this case, 100 seams were removed here to give this:
In this case none were cut from the top and bottom.

Example 4

The next example of seam carving is done on this photo:


First a seam is found, this is an example:

The seams are them removed. In this case, 100 seams were removed here to give this:
Then the image is rotated and a new energy matrix is found and more seams are found.
They are removed to give the result. Here 100 seams in this direction were removed.

Example 5

The next example of seam carving is done on this photo:


First a seam is found, this is an example:

The seams are them removed. In this case, 50 seams were removed here to give this:
Then the image is rotated and a new energy matrix is found and more seams are found.
They are removed to give the result. Here 100 seams in this direction were removed.

Example 6

The next example of seam carving is done on this photo:


First a seam is found, this is an example:

The seams are them removed. In this case, 100 seams were removed here to give this:
Then the image is rotated and a new energy matrix is found and more seams are found.
They are removed to give the result. Here 150 seams in this direction were removed.

Notes:

As you can see, all of those examples were pretty good. Some, like the last one, were pretty drastic differences where around 50% or more in one of the dimensions was cut off. But it worked pretty well. However, that is not always the case. Here are some bad examples where it didn't work as well.

Bad Example 1:




First a seam is found, this is an example:

The seams are them removed. In this case, 100 seams were removed here to give this:
Then the image is rotated and a new energy matrix is found and more seams are found.
They are removed to give the result. Here 100 seams in this direction were removed.
The house has been cut apart.

Bad Example 2:




First a seam is found, this is an example:

The seams are them removed. In this case, 50 seams were removed here to give this:
Then the image is rotated and a new energy matrix is found and more seams are found.
They are removed to give the result. Here 100 seams in this direction were removed.
The top of the image has a lot of weird artifacts from the cutting.

Most Imporant Things Learned:



Project 2: Not Done