Beispiel #1
0
        public static BitmapSource QuantizeInRgb(BitmapSource bitmap, object parameter)
        {
            var quantizationVector = parameter as Vector <byte>;
            var colors             = bitmap.GetColors().Select(c => Quantization.QuantizeVector(c, quantizationVector)).ToArray();

            return(bitmap.Create(colors));
        }
Beispiel #2
0
        public static BitmapSource QuantizeInYCbCr(BitmapSource bitmap, object parameter)
        {
            var quantizationVector = parameter as Vector <byte>;
            var colors             = Transformation.YCbCrToRGB(
                Transformation.RGBToYCbCr(bitmap.GetColors())
                .Select(c => Quantization.QuantizeVector(c, quantizationVector)).ToArray()
                );

            return(bitmap.Create(colors));
        }
        private static HashSet <Vector <byte> > CreateQuantizedSet(Vector <byte>[] colors, byte i)
        {
            var quantizationVector = QuantizationVectorFunc(i);
            var result             = new HashSet <Vector <byte> >();

            foreach (var color in colors)
            {
                result.Add(Quantization.QuantizeVector(color, quantizationVector));
            }
            return(result);
        }