C# Class AForge.Imaging.ColorReduction.ColorErrorDiffusionToAdjacentNeighbors

Base class for error diffusion color dithering, where error is diffused to adjacent neighbor pixels.

The class does error diffusion to adjacent neighbor pixels using specified set of coefficients. These coefficients are represented by 2 dimensional jugged array, where first array of coefficients is for right-standing pixels, but the rest of arrays are for bottom-standing pixels. All arrays except the first one should have odd number of coefficients.

Suppose that error diffusion coefficients are represented by the next jugged array:

int[][] coefficients = new int[2][] { new int[1] { 7 }, new int[3] { 3, 5, 1 } };

The above coefficients are used to diffuse error over the next neighbor pixels (* marks current pixel, coefficients are placed to corresponding neighbor pixels):

| * | 7 | | 3 | 5 | 1 | / 16

The image processing routine accepts 24/32 bpp color images for processing.

Sample usage:

// create dithering routine ColorErrorDiffusionToAdjacentNeighbors dithering = new ColorErrorDiffusionToAdjacentNeighbors( new int[3][] { new int[2] { 5, 3 }, new int[5] { 2, 4, 5, 4, 2 }, new int[3] { 2, 3, 2 } } ); // apply the dithering routine Bitmap newImage = dithering.Apply( image );
Inheritance: ErrorDiffusionColorDithering
Exibir arquivo Open project: holisticware-admin/MonoVersal.AForgeNET

Public Methods

Method Description
ColorErrorDiffusionToAdjacentNeighbors ( int coefficients ) : System

Initializes a new instance of the ColorErrorDiffusionToAdjacentNeighbors class.

Protected Methods

Method Description
Diffuse ( int rError, int gError, int bError, byte ptr ) : void

Do error diffusion.

All parameters of the image and current processing pixel's coordinates are initialized by base class.

Private Methods

Method Description
CalculateCoefficientsSum ( ) : void

Method Details

ColorErrorDiffusionToAdjacentNeighbors() public method

Initializes a new instance of the ColorErrorDiffusionToAdjacentNeighbors class.
public ColorErrorDiffusionToAdjacentNeighbors ( int coefficients ) : System
coefficients int Diffusion coefficients (see /// for more information).
return System

Diffuse() protected method

Do error diffusion.
All parameters of the image and current processing pixel's coordinates are initialized by base class.
protected Diffuse ( int rError, int gError, int bError, byte ptr ) : void
rError int Error value of red component.
gError int Error value of green component.
bError int Error value of blue component.
ptr byte Pointer to current processing pixel.
return void