C# Class Accord.Imaging.ColorReduction.ErrorDiffusionColorDithering

Base class for error diffusion color dithering.

The class is the base class for color dithering algorithms based on error diffusion.

Color dithering with error diffusion is based on the idea that each pixel from the specified source image is substituted with a best matching color (or better say with color's index) from the specified color table. However, the error (difference between color value in the source image and the best matching color) is diffused to neighbor pixels of the source image, which affects the way those pixels are substituted by colors from the specified table.

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.

Mostrar archivo Open project: accord-net/framework

Protected Properties

Property Type Description
height int
pixelSize int
stride int
width int
x int
y int

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.

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 in protected members.

ErrorDiffusionColorDithering ( ) : System

Initializes a new instance of the ErrorDiffusionColorDithering 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

Diffuse() protected abstract method

Do error diffusion.
All parameters of the image and current processing pixel's coordinates are initialized in protected members.
protected abstract 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

ErrorDiffusionColorDithering() protected method

Initializes a new instance of the ErrorDiffusionColorDithering class.
protected ErrorDiffusionColorDithering ( ) : System
return System

Property Details

height protected_oe property

Processing image's height.
protected int height
return int

pixelSize protected_oe property

Processing image's pixel size in bytes.
protected int pixelSize
return int

stride protected_oe property

Processing image's stride (line size).
protected int stride
return int

width protected_oe property

Processing image's width.
protected int width
return int

x protected_oe property

Current processing X coordinate.
protected int x
return int

y protected_oe property

Current processing Y coordinate.
protected int y
return int