Seam Carving in AS3, with source
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 — geek that I am — 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, someone’s done it up in Java here.
Update: Additionally, as it turns out, Patrick Swieskowski has already put up an online seam carving Flash demo here.
Version: 0.8
Licensed under a Creative Commons Attribution 3.0 License.

September 2nd, 2007 at 1:05 pm
This is impressive! :O
I can’t believe my eyes!
September 2nd, 2007 at 1:58 pm
Links: September 3, 2007
Awesome Context Aware Image Sizing: Lots of people are talking about this Truly Great Innovation for photo editors! Hope for it in PhotoShop soon!
An Introduction to Erlang for Curly Brace Programmers: Good intro to massively parallel language …
September 2nd, 2007 at 4:24 pm
have a look at this one.
http://blog.je2050.de/2007/09/02/content-aware-image-resizing/
http://je2050.de/showroom.php?file=ImageResizing2
or this:
http://www.quasimondo.com/archives/000651.php
September 2nd, 2007 at 7:41 pm
mojave,
I love the experiments section on your portfolio website.
Lee
September 4th, 2007 at 11:10 pm
Nice implementation! Did you find the same problems with pictures with lots of straight edges? I found it worked fine when theres sky and bushes to delete but if its mainly buildings it seems to distort the edges too much.
September 5th, 2007 at 2:54 pm
Hector,
I’m also seeing the same issues with straight edges. Mostly, I’m thinking it’s intrinsic to the algorithm. Which is not to say there may not be an ingenious solution to the problem…
I’ve been wondering if the whole process could be ‘anti-aliased’ by scaling the image by 100% using a bicubic or bilinear filter, and then doing the seam carving from there. It would, of course, take 4 times as long…
Again, thanks for the writeup on your blog.
Lee
September 13th, 2007 at 6:13 am
Hi, I’ve also been doing a version of this, (but in python) - and I am trying to get the people who have done implementations together to compare the outputs on the same image- if you are interested email me, or see my blog. http://www.timwintle.co.uk
September 19th, 2007 at 6:04 pm
Nice implementation of seam carving, one of the first. The problem with geometric figures (lots of lines) is real, as people have pointed out. I would like to see how it behaves for people pictures, though.
September 28th, 2007 at 10:56 pm
Check out rsizr.com for a full-featured Flash-based implementation of seam carving that lets you resize your own images, both in height and width simultaneously, in real time. (You can rescale and crop images too!)
http://rsizr.com/about/gallery/ for example images
November 16th, 2007 at 2:40 pm
I just found the video - this seam carving lark is amazing!
November 22nd, 2007 at 9:12 am
Projectlinks gives a 404 - not found!
May 15th, 2008 at 8:08 pm
john deere…
imagefap
imbd
improve memory by selfhypnosis
…
May 16th, 2008 at 3:33 am
sensa bed…
gexo
giga galleries
gigagalleries
…
May 16th, 2008 at 11:04 am
aolmail…
drudge report
ducky porn
duckyporn
…