Project 4
Seam Carving
Note: Click on all images to view the full size version!
Basic Algorithm
The goal of seam carving is to produce an image of a new size which is visually very similar to the original. It differs from cropping in the sense that the all the elements of the the original image should be preserved in the new one, and from scaling because the results should look natural even when the scaling is non-uniform. (As you will see this is not always the caseā¦.)
Basically, I followed the paper and implemented a straight forward version of seam carving using the gradient as a basic energy function. I then iterated backwards over the gradient to find the best seam and would remove that seam from an image. To remove multiple seams I simple iterate, removing a single seam at a time. This is a rather slow process, but hey, it works alright.
Finally, I only implemented removing of vertical seams, (that is columns of pixels). To remove horizontal seams, I transpose the image, remove seams, then transpose it back to the original state.
All the images from this assignment, except for the first (below) are my own. They were taken at Berkeley or in San Francisco.
Here is an example of the Cabin image which I have shrunk by 150px.
Some Successes
Shrinking by 20% achieved a decent result:
Shrunk to 50% width is surprisingly OK!:
Shrinking by 20% actually turns out OK, except for one corner:
Large Vertical Carve works quite well! :
Some Failures
Shrinking Wheeler Hall by 50% was a bad idea:
Shrink the protester vertically fails: