public override System.Drawing.Image Quantize(System.Drawing.Image original) { int height = original.Height ; int width = original.Width ; Rectangle bounds = new Rectangle ( 0 , 0 , width , height ) ; Bitmap output = new Bitmap ( width , height , PixelFormat.Format32bppArgb ) ; Bitmap copy = new Bitmap ( width , height , PixelFormat.Format32bppArgb ) ; using ( Graphics g = Graphics.FromImage( copy ) ) { g.PageUnit = GraphicsUnit.Pixel ; g.DrawImage(original, bounds) ; } ClusterAlgorithm cluster = new ClusterAlgorithm(); CCFTree tree = cluster.BuildCCFTree(copy); Color[] colors = tree.ExportToPalette(); Console.WriteLine("Number of Colors after CCFTree: " + colors.Length); PaletteAlgorithm palettizer = new PaletteAlgorithm(); palettizer.Palette = colors; return palettizer.Quantize(copy); }
public override System.Drawing.Image Quantize(System.Drawing.Image original) { int height = original.Height ; int width = original.Width ; Rectangle bounds = new Rectangle ( 0 , 0 , width , height ) ; Bitmap output = new Bitmap ( width , height , PixelFormat.Format32bppArgb ) ; Bitmap copy = new Bitmap ( width , height , PixelFormat.Format32bppArgb ) ; using ( Graphics g = Graphics.FromImage( copy ) ) { g.PageUnit = GraphicsUnit.Pixel ; g.DrawImage(original, bounds) ; } ClusterAlgorithm cluster = new ClusterAlgorithm(); cluster.NumColors = NumColors; CCFTree tree = cluster.BuildCCFTree(copy); Hashtable histogram = GenerateHistogram(tree,copy); Console.WriteLine("Number of Colors after CCFTree: " + histogram.Count); PaletteAlgorithm palettizer = new PaletteAlgorithm(); palettizer.Palette = ReduceColors(histogram); return palettizer.Quantize(copy); }
public override System.Drawing.Image Quantize(System.Drawing.Image original) { int height = original.Height ; int width = original.Width ; Rectangle bounds = new Rectangle ( 0 , 0 , width , height ) ; Bitmap output = new Bitmap ( width , height , PixelFormat.Format32bppArgb ) ; Bitmap copy = new Bitmap ( width , height , PixelFormat.Format32bppArgb ) ; using ( Graphics g = Graphics.FromImage( copy ) ) { g.PageUnit = GraphicsUnit.Pixel ; g.DrawImage(original, bounds) ; } Hashtable histogram = GenerateHistogram(copy); PaletteAlgorithm palettizer = new PaletteAlgorithm(); palettizer.Palette = SelectHighestFrecuency(histogram); return palettizer.Quantize(copy); }
public override System.Drawing.Image Quantize(System.Drawing.Image original) { PaletteAlgorithm palettizer = new PaletteAlgorithm(); palettizer.Palette = GenerateUniformPalette(levelsR,levelsG,levelsB); return palettizer.Quantize(original); }