A .NET-based implementation of seam carving.
If you're not familiar with seam carving
, you should first watch the
short 4 1/2 minute video demonstratration
. The technique was presented at the SIGGRAPH 2007 conference by Shai Avidan and Ariel Shamir. For all of the details, check out the paper they presented called
Seam Carving for Content-Aware Image Resizing
(20MB PDF). Shai and Ariel outline a relatively simple algorithm for finding a "seam" of pixels that is least likely to be missed when it's removed
from an image. The algorithm looks for connected pixels of low energy, where
refers to a measure of visual detail. By iterating the algorithm, an image can be resized while maintaining its general structure. Unlike a typical stretch operation in your favorite graphics application, the seam carving technique resists squashing
or distorting the image. The algorithm can also be used to remove specific content (like a person or object) from a scene by using a bias map.
The code has evolved from a very simple prototype to something a bit more robust. As these things go, the architecture is a bit shaky at the moment, but it does work. The early version of the application can only open JPG files, doesn't support image expansion,
and the user interface is pretty minimal. However, it's far enough along that someone might find it interesting.
In lieu of documentation, I encourage you to watch the
8 minute video introduction
I recorded to quickly get up-to-speed (note that you may need to download the
TechSmith Screen Capture Codec
to properly view this video).
All of the image manipulation functionality is encapsulated in a DLL, so it should be usable in most scenarios. There is a lot of opportunity for improvement and optimization in these algorithms.
Here are two images that have been resized using both SEAMonster and Photoshop. Note the "squashed" features in both of the bicubic versions.
Some other seam carving resources that you may find interesting: