Discussion:
tilt-shift... but faster?
Aidan Feldman
2011-05-17 03:33:29 UTC
Permalink
Hi all-
So first I wanted to announce a Ruby gem I created called magickly, which
essentially offers Imagemagick as a web service. Please take a look - would
love any feedback:

https://github.com/afeld/magickly

As part of that plugin I include some pre-defined
effects<https://github.com/afeld/magickly/blob/master/lib/shortcuts.rb>,
i.e. tilt-shifting. I pretty closely mimicked the tilt-shift
tutorial<http://www.imagemagick.org/Usage/photos/#tilt_shift>on the
Imagemagick site, essentially running the following command:

convert source.png \\( +clone -sparse-color Barycentric '0,0 black
0,%[fx:h-1] white' -function polynomial 2,-2,0.5 \\) \

-compose Blur -set option:compose:args 15 -composite output.png


The result image looks good, but the app is serving photos on demand and it
takes forever (upwards of 30 seconds for a 640x480 on my Mac). Turnaround
time is more important than image quality here, so I was wondering if anyone
had any ideas for how to speed this up? Here are a few ideas I had - no
idea if they would make a difference:

- linear gradients, as mentioned in the tutorial
- storing the gradient map
- using variable blur
mapping<http://www.imagemagick.org/Usage/mapping/#blur> by
creating two gradient:black-white squares to get something parametric-ish

Any help would be appreciated. Thanks!
-Aidan
Anthony Thyssen
2011-05-17 04:39:36 UTC
Permalink
On Mon, 16 May 2011 23:33:29 -0400
magick-users-***@imagemagick.org wrote:
| Hi all-
| So first I wanted to announce a Ruby gem I created called magickly, which
| essentially offers Imagemagick as a web service. Please take a look - would
| love any feedback:
|
| https://github.com/afeld/magickly
|

I suggest you make the announcement in the IM Forum Announce area

A link to some basic documentation (not the project page) would be helpful!

| convert source.png \\( +clone -sparse-color Barycentric '0,0 black
| 0,%[fx:h-1] white' -function polynomial 2,-2,0.5 \\) \
|
| -compose Blur -set option:compose:args 15 -composite output.png
|
Hmmm that sparse-color line is a little wrong but not to any visible
degree in the results. Updating usage example

For general speedups see...
http://www.imagemagick.org/Usage/api/#speed

However the blur is very slow.. and for a short period, a patch to fix
blurs of less that 1 sigma caused it to be 3 to 5 times slower still.

That patch was removed until I can re-think the problem.
If you IM is between versions 6.6.7-7 and 6.6.8-4 and Upgrade your IM.

Perhaps a run-time switch to remove the use of a LUT for EWA filtering,
which was the cause of the the slow down in that patch.

Sorry thinking out loud!

Anthony Thyssen ( System Programmer ) <***@griffith.edu.au>
--------------------------------------------------------------------------
Philosophy (n): unintelligible answers to insoluble problems.
--------------------------------------------------------------------------
Anthony's Castle http://www.ict.griffith.edu.au/anthony/
Aidan Feldman
2011-05-18 08:43:10 UTC
Permalink
Oh, found the biggest culprit: was using "-set option:compose:args 15".
Lowering that to 8 cut the time down significantly. I assume that's the
blur radius? Thanks!

-Aidan
Post by Anthony Thyssen
On Mon, 16 May 2011 23:33:29 -0400
| Hi all-
| So first I wanted to announce a Ruby gem I created called magickly, which
| essentially offers Imagemagick as a web service. Please take a look - would
|
| https://github.com/afeld/magickly
|
I suggest you make the announcement in the IM Forum Announce area
A link to some basic documentation (not the project page) would be helpful!
| convert source.png \\( +clone -sparse-color Barycentric '0,0 black
| 0,%[fx:h-1] white' -function polynomial 2,-2,0.5 \\) \
|
| -compose Blur -set option:compose:args 15 -composite output.png
|
Hmmm that sparse-color line is a little wrong but not to any visible
degree in the results. Updating usage example
For general speedups see...
http://www.imagemagick.org/Usage/api/#speed
However the blur is very slow.. and for a short period, a patch to fix
blurs of less that 1 sigma caused it to be 3 to 5 times slower still.
That patch was removed until I can re-think the problem.
If you IM is between versions 6.6.7-7 and 6.6.8-4 and Upgrade your IM.
Perhaps a run-time switch to remove the use of a LUT for EWA filtering,
which was the cause of the the slow down in that patch.
Sorry thinking out loud!
--------------------------------------------------------------------------
Philosophy (n): unintelligible answers to insoluble problems.
--------------------------------------------------------------------------
Anthony's Castle http://www.ict.griffith.edu.au/anthony/
_______________________________________________
Magick-users mailing list
http://studio.imagemagick.org/mailman/listinfo/magick-users
Continue reading on narkive:
Loading...