Seam carving in Python

I believe that the best algorithms are usually the simplest. Seam carving, an intelligent image resizing algorithm first introduced by Avidan and Shamir in SIGGRAPH’07, is the embodiment of such a statement – no expensive image descriptors or fancy deep learning required. Rather, seam carving employs dynamic programming to find connected (or semi-connected) seams of minimal energy. By removing and adding seams at these locations, the resulting image can be resized with minimal impact to the actual content in the image. Best of all, the algorithm can be customized with only a bit of user input: regions can be forcibly removed or kept if the user specifies such.

As a part of the larger panorama project that I’m currently undertaking, I decided to implement seam carving and use it in conjunction with multi-band blending to emulate parallax tolerance. Not sure how well it will work yet, but it’s always worth a try. You can grab the code here. Enjoy!

UPDATE 1: I’ve transitioned the seam carving code into radiant, a comprehensive image editing library that I’ve been working on. The link now takes you there, instead of the original codebase.