Project 2: Image Resizing by Seam Carving
15-463: Computational Photography Zuye Zheng
Energy Function
Original Energy Map  
For my energy function I used the e1 energy function presented in the paper. I separated the image into its RGB layers and for each layer I took the difference between each pixel with its adjacent neighbors and finally took the sum of the difference for all 3 layers. This was simply achieved by translating the image [-1, +1] in both the vertical and horizontal directions and then taking the absolute difference of all the translated images. I also experimented on a variation of the e1 function using a gaussian filter. I first convoluted the original image with a gaussian filter and then subtracted the convoluted image with the original which resulted in a similar energy map except it took into account not only its adjacent neighbors but the neighbors within the range of the gaussian filter. This method was slower and resulted in similiar results so I decided to just use the original faster and simpler method.
Cost Function
Vertical Cost Map Horizontal Cost Map  
For my cost function I simply used dynamic programming to calculate a cost map. Depending on if the seam was vertical or horizontal I started at one side of the image with initial values for the first row (or column) equal to that of the same row in the cost map. I then progressively iterated from this first row to the end of the image by calculating the new value by adding each pixels energy value with the lowest cost of its 3 (or 2 in the case of edges) adjacent neighbors from the previous row. Some sample resulting cost maps are to the left. Then to find the lowest cost seam I started at the opposite row (or column) than that of which I used to calculate the cost map and found the lowest cost pixel. From there I iterated back to the starting row by tracing through the lowest cost adjacent neighbors one row or column at a time.
Results Part 1: Images That Worked
Below are some photos I took this summer in China and San Francisco that took particularly well to my seam carving algorithm. For the most part large pattern like landscapes or images where there is a central object with blurred or indistinct background worked the best. I scaled the images below by 5/6 in both dimensions using seam carving and then resized them to be the same size for display and evaluation purposes.

Original Seam Carved
Results Part 2: Images That Didn't
Like the images above, I also scaled these images by 5/6 in both dimensions using seam carving and then resized them to be the same size for display and evaluation purposes. As you can see, these images did not produce desired or optimal results, although some are still very interesting. The first, third, and forth images show many sean carving artifacts that distorted the original images undesirably. These images are much more complex and have more points of interest than the ones above which resulted in a very busy energy function which then also resulted in a cost map that had no clear low cost seams. One interesting seam carving result was the second image where I feel if you had not seen the original image, the seam carved image would almost appear "authentic". Although it is clear the center gargoyle became distorted, it still looks "real".

Original Seam Carved