C# Class AForge.Imaging.ColorReduction.MedianCutQuantizer

Median cut color quantization algorithm.

The class implements median cut color quantization algorithm.

See also ColorImageQuantizer class, which may simplify processing of images.

Sample usage:

// create the color quantization algorithm IColorQuantizer quantizer = new MedianCutQuantizer( ); // process colors (taken from image for example) for ( int i = 0; i < pixelsToProcess; i++ ) { quantizer.AddColor( /* pixel coloer */ ); } // get palette reduced to 16 colors Color[] palette = quantizer.GetPalette( 16 );
Inheritance: IColorQuantizer
Show file Open project: noxryan/Claro-Shader Class Usage Examples

Public Methods

Method Description
AddColor ( Color color ) : void

Add color to the list of processed colors.

The method adds the specified color into internal list of processed colors. The list is used later by GetPalette method to build reduced color table of the specified size.

Clear ( ) : void

Clear internal state of the color quantization algorithm by clearing the list of colors so far processed.

GetPalette ( int colorCount ) : Color[]

Get paletter of the specified size.

The method must be called after continuously calling AddColor method and returns reduced color palette for colors accumulated/processed so far.

Private Methods

Method Description
SplitCubes ( List cubes, int count ) : void

Method Details

AddColor() public method

Add color to the list of processed colors.

The method adds the specified color into internal list of processed colors. The list is used later by GetPalette method to build reduced color table of the specified size.

public AddColor ( Color color ) : void
color Color Color to add to the internal list.
return void

Clear() public method

Clear internal state of the color quantization algorithm by clearing the list of colors so far processed.
public Clear ( ) : void
return void

GetPalette() public method

Get paletter of the specified size.

The method must be called after continuously calling AddColor method and returns reduced color palette for colors accumulated/processed so far.

public GetPalette ( int colorCount ) : Color[]
colorCount int Palette size to get.
return Color[]