C# Class AForge.Imaging.Filters.ErrorDiffusionToAdjacentNeighbors

Base class for error diffusion 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 filter accepts 8 bpp grayscale images for processing.

Sample usage:

// create filter ErrorDiffusionToAdjacentNeighbors filter = new ErrorDiffusionToAdjacentNeighbors( new int[3][] { new int[2] { 5, 3 }, new int[5] { 2, 4, 5, 4, 2 }, new int[3] { 2, 3, 2 } } ); // apply the filter filter.ApplyInPlace( image );
Inheritance: ErrorDiffusionDithering
Show file Open project: holisticware-admin/MonoVersal.AForgeNET

Public Methods

Method Description
ErrorDiffusionToAdjacentNeighbors ( int coefficients ) : System

Initializes a new instance of the ErrorDiffusionToAdjacentNeighbors class.

Protected Methods

Method Description
Diffuse ( int error, 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

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 error, byte ptr ) : void
error int Current error value.
ptr byte Pointer to current processing pixel.
return void

ErrorDiffusionToAdjacentNeighbors() public method

Initializes a new instance of the ErrorDiffusionToAdjacentNeighbors class.
public ErrorDiffusionToAdjacentNeighbors ( int coefficients ) : System
coefficients int Diffusion coefficients.
return System