Reputation: 1902
Most instructions on the web mention to do
convert *.tif -evaluate-sequence median output.tif
However, in recent versions of ImageMagick, this spits out a multi-page TIFF file that contains all the input images, one per page, instead of actually evaluating the median.
Upvotes: 2
Views: 1511
Reputation: 11190
As wuxiekeji says, you are probably running out of memory. IM will load every image into RAM before starting work, and expand them all to five channels of 16 bits, so it can need a lot. If you don't have enough, it'll start using disc and then processing can become very slow.
For fun, I tried in libvips, a streaming image processing library that doesn't load entire images into RAM. First with convert
:
$ for i in {1..100}; do convert ../k2.jpg $i.tif; done
$ /usr/bin/time -f %M:%e convert *.tif -evaluate-sequence median ../x.tif
2358840:38.02
Where k2.jpg
is a 1450x2048 pixel JPG. It needed 2.2gb of memory and took 38s on this four core 8 thread i7.
Then with libvips:
$ /usr/bin/time -f %M:%e vips bandrank "$(echo *.tif)" ../x.tif
438548:5.72
500mb of memory and 6s. You'd see a larger memory saving with larger images, a smaller saving with smaller ones.
Upvotes: 2
Reputation: 1902
I found out that this occurs only when evaluating a long list of images, because of memory/disk space quotas respected by ImageMagick, even though my system has much more resources than those quotas.
To change the quotas, edit /etc/ImageMagick-6/policy.xml, particularly these two lines:
<policy domain="resource" name="memory" value="512MiB"/>
<policy domain="resource" name="disk" value="2GiB"/>
and increase them based on how much system resources you have. After that it worked for me. The "disk" quota is probably the most important one if evaluating the median of a long list of images.
I'm sharing this information here in case anyone else happens upon it by Googling.
Suggestion to the ImageMagick authors, in case they happen upon this by Googling: It would have been nice if ImageMagick produced an error message saying to edit the above file instead of dying with a multi-page TIFF, but thanks anyway!
Upvotes: 5
Reputation: 53154
It works fine for me on IM 6.9.10.64 Q16 Mac OSX with libtiff 4.0.10. I get only one page in my output TIFF.
Input:
convert lena.jpg lena.tif
convert mandril3.jpg mandril.tif
convert zelda1.jpg zelda.tif
convert *.tif -evaluate-sequence median result.tif
What is your ImageMagick version, platform and version of libtiff? Perhaps you need to upgrade. Or might you have mistyped either -evaluate-sequence or median?
Post your TIFF files and I will test them for you.
Upvotes: 2