Large image dimension causes slow dithering

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Locked
Jason S
Posts: 103
Joined: 2010-12-14T19:42:12-07:00
Authentication code: 8675308

Large image dimension causes slow dithering

Post by Jason S »

I think it's the dither operation that's very slow when I create certain images with one very large dimension. The time it takes seems to be exponential (correction: quadratic) based on image's larger dimension, and jumps way up at each power of 2(?). Maybe there is a legitimate reason for this, but I'm reporting it because it seems wrong.

Steps to reproduce:

Code: Select all

$ convert logo: -resize '640x1!' -resize '32767x1!' test32767.ppm
$ convert logo: -resize '640x1!' -resize '32768x1!' test32768.ppm

$ time convert test32767.ppm test.pbm
real	0m11.681s
user	0m8.664s       ←
sys	0m0.056s

$ time convert test32768.ppm test.pbm
real	0m36.347s
user	0m32.996s      ←
sys	0m0.068s

$ time convert test32768.ppm +dither test.pbm
real	0m0.087s
user	0m0.020s       ←
sys	0m0.012s

$ convert -version
Version: ImageMagick 7.0.5-5 Q16 x86_64 2017-05-01 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP 
Delegates (built-in): jng jpeg png zlib
Last edited by Jason S on 2017-05-02T07:30:15-07:00, edited 1 time in total.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Large image dimension causes slow dithering

Post by snibgo »

You may find that FloydSteinberg gives as good results as Riemersma, as is much faster.
snibgo's IM pages: im.snibgo.com

Locked