Color dithering with a thresold matrix (ordered dithering).

Namespace:  AForge.Imaging.ColorReduction
Assembly:  AForge.Imaging (in AForge.Imaging.dll) Version: (


public class OrderedColorDithering


The class implements ordered color dithering as described on Wikipedia. The algorithm achieves dithering by applying a threshold map on the pixels displayed, causing some of the pixels to be rendered at a different color, depending on how far in between the color is of available color entries.

The image processing routine accepts 24/32 bpp color images for processing. As a result this routine produces 4 bpp or 8 bpp indexed image, which depends on size of the specified color table - 4 bpp result for color tables with 16 colors or less; 8 bpp result for larger color tables.

Sample usage:

// create color image quantization routine
ColorImageQuantizer ciq = new ColorImageQuantizer( new MedianCutQuantizer( ) );
// create 256 colors table
Color[] colorTable = ciq.CalculatePalette( image, 256 );
// create dithering routine
OrderedColorDithering dithering = new OrderedColorDithering( );
dithering.ColorTable = colorTable;
// apply the dithering routine
Bitmap newImage = dithering.Apply( image );

Initial image:

Result image:

Inheritance Hierarchy


See Also