Ejemplo n.º 1
0
        protected override Pixel QuantizatePixel(int x, int y)
        {
            // Get the color and add to the list
            Color color = image[y, x];

            int colorIndex;

            if (listColor.Count < this.MaxColors)
            {
                if (!listColor.Contains(color))
                {
                    listColor.Add(color);
                }
                colorIndex = listColor.IndexOf(color);
            }
            else
            {
                // Create the labpalette if so
                if (nearestNeighbour == null)
                {
                    LabColor[] labPalette = ColorConversion.ToLabPalette <Color>(listColor.ToArray());
                    nearestNeighbour = new ExhaustivePaletteSearch();
                    nearestNeighbour.Initialize(labPalette);
                }

                LabColor labNoTrans = ColorConversion.ToLabPalette <Color>(new Color[] { color })[0];
                colorIndex = nearestNeighbour.Search(labNoTrans);
            }

            return(new Pixel((uint)colorIndex, (uint)color.Alpha, true));
        }
 public FixedPaletteQuantization(Color[] fixedPalette)
 {
     this.nearestNeighbour = new ExhaustivePaletteSearch();
     this.Palette          = fixedPalette;
 }
Ejemplo n.º 3
0
 protected override void PreQuantization(EmguImage image)
 {
     this.listColor        = new List <Color>();
     this.nearestNeighbour = null;
     this.image            = image;
 }