Seam carving — the recently unveiled technique by Shai Avidan and Ariel Shamir to intelligently resize images (YouTube; white paper) — really captured my imagination when I came across it last night, as it has for many others.
Like Hector Yee (whose writeup was very useful), I decided to try my hand at an implementation of it just for the hell of it, but in Actionscript 3.
The attached demo only resizes images vertically, not horizontally. I wish I could have, but didn’t bother including a dynamic image loader. It’s also, well, very pokey, but the code is readable and the output seems accurate. If you can stand the wait, press [M] a few times to load up the seam calculation queue.
But the most valuable thing about this demo is its publicly available source code under a Creative Commons license:
So if you’re so inclined, please improve, extend, optimize, and/or port this code. I’m not planning on doing any further work on it. Just let me know if you find the code useful, and share your work.
If you’re interested in a more fully-realized online demo of seam carving, here’s one that’s been done in Java.
Update: Additionally, as it turns out, Patrick Swieskowski has already put up an online seam carving Flash demo here.
Licensed under a Creative Commons Attribution 3.0 License.