C# Класс Accord.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:

Показать файл Открыть проект

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
GetClosestColor ( int red, int green, int blue, byte &colorIndex ) : Color

Описание методов

Apply() публичный Метод

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.
Результат System.Drawing.Bitmap

Apply() публичный Метод

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.
Результат System.Drawing.Bitmap

OrderedColorDithering() публичный Метод

Initializes a new instance of the OrderedColorDithering class.
public OrderedColorDithering ( ) : System
Результат System

OrderedColorDithering() публичный Метод

Initializes a new instance of the OrderedColorDithering class.
public OrderedColorDithering ( byte matrix ) : System
matrix byte Threshold matrix (see property).
Результат System