Consider OctreeQuantizer as a replacement for NeuQuant
Status: Alpha
Brought to you by:
sbridewell
Try using the OctreeQuantizer from http://www.eggheadcafe.com/articles/stripimagefromanimatedgif.asp instead of the NewQuant quantizer - supposed to be faster.
A few problems with this...
The OctreeQuantizer quite happily quantizes any image you pass to it, but getting the colour table / palette of the quantized image is proving a bit problematic.
I don't think it can cope with quantizing and creating a colour table / palette for multiple images, as is needed if it is to be used when creating an animation with a single global colour table. I'm sure it could be made to cope with this, although it would need changing in order to do so.
Whilst looking into this, I've decided that the PixelAnalysis class is a bit of a mess and could probably be optimised in a few places, so I'm going to concentrate on that for now, as that's what sits between the AnimatedGifEncoder and whatever quantizes the images.
Comparison of encoding times and image quality using NeuQuant and Octree quantizers
I believe I've got the Octree quantizer working with local colour tables now. No code committed just yet as I want to get it working with global colour tables too, plus there's some tidying up still to do. In the mean time I've produced some metrics comparing the time taken to encode and the amount the colours have changed, when using both quantizers to encode a single frame 250x250 image with more than 256 colours. The Octree quantizer changes the colours by the same amount as NeuQuant on its highest quality setting, but in just over half the time. The other results for NeuQuant don't seem to make much sense - all quality settings except 1 take just over half a second, but a quality of 1 takes just over 1 second, yet the variation in colour is the greatest at a quality of 9, but is almost the same with a setting of 20 as it is with a setting of 1.
Either way, I think the Octree quantizer wins out, if I can get it to work with global colour tables too.
I think it might be quite a substantial piece of work getting the Octree quantizer to work with global colour tables, so I guess I won't be implementing that any time soon.
One thing I've just noticed though is that the Octree quantizer seems to be rather more aggressive than necessary. It should adjust images with more than 256 colours so that they have only 256 colours (being the maximum supported by the GIF standard), however in my tests it seems to be reducing images to 128 or 180 colours. Ideally it should reduce images to 256 colours and no less, to keep degradation of image quality to a minimum.
Changes committed to support encoding with local colour tables using the Octree quantizer. Still no support for global colour tables using the Octree quantizer I'm afraid - if the AnimatedGifEncoder's QuantizerType is set to Octree and the ColourTableStrategy is set to UseGlobal then the QuantizerType setting is ignored and NeuQuant is used instead.
Option to use Octree quantizer with local colour tables has been included in version 0.1.3711.28220 of the MSI installer, uploaded today.
Still no support for global colour tables I'm afraid.