Programming Project #2 (proj2)
15-463: Computational Photography

Seam Carving

By Ekapol Chuangsuwanich


The preliminary energy function chosen to produce the results is the one mentioned in Avidan and Shamir's paper.

where I is the gray scale image

Good Results (All pictures taken by myself unless mentioned otherwise)

Note: If an image set only has a shrink in one direction, the other direction looks so awful that I decide to drop it. Image with both dimension shrinks (if any) are produced by first carving the vertical direction first. This might not produce the best result, which is why I will introduce the optimal carving in the bell and whistles section.




source



 



source




VERY BAD results



Discussion on why the implementation works on some pictures but not the others

Types of picture that work well

1. Big uniform background. These can be cut easily.

2. Nature. Man-made objects which are out of their original shape is easier noticeable than natural ones. The beetle in the leaves is a good example of this. Even though some of the leaves are distorted, it does not stick out as much as the distorted buildings.

From the set of pictures I run the code on, two types of picture usually does not work well.

1. Picture with noticeable straight lines (the saw picture). Since the  lines usually loses it's straightness which can provide bad results

2. Picture with a large subject compare to the background. Large subject usually consist of large uniform parts. These are usually recognized by the algorithm as the lowest energy by the algorithm. When they are removed, it is very noticeable since they are suppose to be what we are suppose to look at.


Bells and Whistles

Make it fast!

The horizontal and vertical seams are pre-computed and store in a .map file associated to that picture. When the function is called, it removes the seam according to the order given by the map. In my implementation, optimal carving (carving horizontal and vertically at the same time) is not implemented in the pre-computed version since it involves more storage. Shown below are the vertical and horizontal seams store in the .map file of the tiger picture. Red correspond to the first seams to be removed. On the other hand the blue tones are removed last.

Other Energy functions

To be added later.

Optimal resizing

Instead of removing on dimension at a time to do a two dimensional resizing, we can do both at the same time to increase the quality (the run time is much worse though).

For each seam removal, find the minimum seams in both direction. Cut in the direction that has least energy. Repeat until there are no seam left to remove in one direction. Do the other direction until done.


Left: Vertical -> Horizontal. Right: Optimal carving

Image stretching

Instead of removing the seams, pixel are added instead by averaging the pixel of the seam and the next pixel.

Note that the characters on the wood is not skewed by the vertical only resizing because pixels are added somewhere else.


Object Removal

Using a mask on the picture, we can tell the program to remove certain parts of the picture. The mask will add negative weights to the part of the picture, forcing the seams to past through that area. The size is reduced until all the pixels in the mask is removed.


The picture and the mask. We want to remove the giraffe.


Image de-giraffed!

To get the original size back, seam insertion is used on the image.


Object removed, compare to the original.

Just for fun. - Using the negative mask as a start, it is easy to create a positive mask as well. Using the positive mask, we can protect certain part of the picture from being cropped.


Image and the positive mask.


With mask. Without mask.