Color quantization tools.

The class contains methods aimed to simplify work with color quantization algorithms implementing IColorQuantizer interface. Using its methods it is possible to calculate reduced color palette for the specified image or reduce colors to the specified number.

Sample usage:

// instantiate the images' color quantization class ColorImageQuantizer ciq = new ColorImageQuantizer( new MedianCutQuantizer( ) ); // get 16 color palette for a given image Color[] colorTable = ciq.CalculatePalette( image, 16 ); // ... or just reduce color in the specified image Bitmap newImage = ciq.ReduceColors( image, 16 );

Initial image:

Result image:

コード例 #1
0
ファイル: ImageProcessor.cs プロジェクト: vzavadko/DA
        static ImageProcessor()
        {
            imageQuantizer = new ColorImageQuantizer(new MedianCutQuantizer());

            grayscale = Grayscale.CommonAlgorithms.BT709;

            edgeDetector = new CannyEdgeDetector();
        }
コード例 #2
0
        private Bitmap reducedColor(Bitmap image, int numColors)
        {
            // create color image quantization routine
            ColorImageQuantizer ciq = new ColorImageQuantizer(new MedianCutQuantizer());
            // create 16 colors table
            Color[] colorTable = ciq.CalculatePalette(image, numColors);
            // create dithering routine
            FloydSteinbergColorDithering dithering = new FloydSteinbergColorDithering();
            dithering.ColorTable = colorTable;
            // apply the dithering routine
            Bitmap newImage = dithering.Apply(image);

            return newImage;
        }
コード例 #3
0
 public static Bitmap OrderedColorDithering(Bitmap bmp, int value)
 {
     // create color image quantization routine
     ColorImageQuantizer ciq = new ColorImageQuantizer(new MedianCutQuantizer());
     // create 256 colors table
     Color[] colorTable = ciq.CalculatePalette(bmp, value);
     // create dithering routine
     OrderedColorDithering dithering = new OrderedColorDithering();
     dithering.ColorTable = colorTable;
     // apply the dithering routine
     Bitmap newImage = dithering.Apply(bmp);
     return newImage;
 }
コード例 #4
0
 public static Bitmap MedianCut(Bitmap bmp, int intensity)
 {
     ColorImageQuantizer ciq = new ColorImageQuantizer(new MedianCutQuantizer());
     IColorQuantizer quantizer = new MedianCutQuantizer();
     Bitmap newImage = ciq.ReduceColors(bmp, intensity);
     return newImage;
 }