melinath / django-daguerre

On-the-fly image manipulation for Django.
http://django-daguerre.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
85 stars 15 forks source link

Add support for seam carving #6

Open melinath opened 12 years ago

melinath commented 12 years ago

Although seam carving is ostensibly supported through https://github.com/sameeptandon/python-seam-carving/blob/master/CAIS.py, the code providing it is way out of date, and the implementation itself is two years old and extremely slow. Seam carving would be great to have, once we have things like out-of-band image adjustments, but it should be done right when that time comes.

melinath commented 11 years ago

I've added experimental seam carving support in the seamcarve branch. Times are given for my 1.7GHz Macbook Air, which is running a bunch of other programs at the time.

The current bottleneck is in recalculating the cost matrix; I am out of ways to make it faster. The implementation also doesn't take areas into account, which it should. I should add that the program is currently bound by the CPU on my computer. With a more powerful machine, it would presumably go faster. However, I still don't think this is a practical implementation for a website. Unless someone else can find a way to make this faster, I'm leaving it as is: an experimental branch.

Original (512x341) castle_original

450x300 (~15 seconds, 103 seams) 450x300

200x200 (~45 seconds, 453 seams) 200x200

harrislapiroff commented 11 years ago

Whoaaa.

harrislapiroff commented 11 years ago

We could always implement it, warn heavily in the documentation, and encourage people to use preadjustments if they're using seam carving?

Although, I guess without a serious use case, our only real motivation to do that is that it's AWESOME.

melinath commented 11 years ago

Yeah... I think the main reason we wanted this was the awesomeness factor. ;-) We could offer it with preadjustments, but that wouldn't help the case where someone uploaded an image which was viewed immediately. We'd need some sort of "fast version" which could placehold while the slow version was computed.

melinath commented 11 years ago

Apparently Image Magick has a plugin for seam carving. And there's at least one python library for interfacing with Image Magick. So maybe that would be an option.