C# Class AForge.Imaging.ColorReduction.OrderedColorDithering

Color dithering with a thresold matrix (ordered dithering).

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:

Mostrar archivo Open project: holisticware-admin/MonoVersal.AForgeNET Class Usage Examples

Public Methods

Method Description
Apply ( Bitmap sourceImage ) : Bitmap

Perform color dithering for the specified image.

Apply ( UnmanagedImage sourceImage ) : Bitmap

Perform color dithering for the specified image.

OrderedColorDithering ( ) : System

Initializes a new instance of the OrderedColorDithering class.

OrderedColorDithering ( byte matrix ) : System

Initializes a new instance of the OrderedColorDithering class.

Private Methods

Method Description
GetClosestColor ( int red, int green, int blue, byte &colorIndex ) : Color

Method Details

Apply() public method

Perform color dithering for the specified image.
Unsupported pixel format of the source image. It must 24 or 32 bpp color image.
public Apply ( Bitmap sourceImage ) : Bitmap
sourceImage System.Drawing.Bitmap Source image to do color dithering for.
return System.Drawing.Bitmap

Apply() public method

Perform color dithering for the specified image.
Unsupported pixel format of the source image. It must 24 or 32 bpp color image.
public Apply ( UnmanagedImage sourceImage ) : Bitmap
sourceImage UnmanagedImage Source image to do color dithering for.
return System.Drawing.Bitmap

OrderedColorDithering() public method

Initializes a new instance of the OrderedColorDithering class.
public OrderedColorDithering ( ) : System
return System

OrderedColorDithering() public method

Initializes a new instance of the OrderedColorDithering class.
public OrderedColorDithering ( byte matrix ) : System
matrix byte Threshold matrix (see property).
return System