Пример #1
0
        public static Image2 Quantize(this Image2 source, IQuantizer quantizer, int maxColors)
        {
            QuantizedImage quantizedImage = quantizer.Quantize(source, maxColors);

            source.SetPixels(source.Width, source.Height, quantizedImage.ToImage().Pixels);
            return(source);
        }
Пример #2
0
        /// <summary>
        /// Applies quantization to the image.
        /// </summary>
        /// <typeparam name="T">The pixel format.</typeparam>
        /// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam>
        /// <param name="source">The image this method extends.</param>
        /// <param name="quantizer">The quantizer to apply to perform the operation.</param>
        /// <param name="maxColors">The maximum number of colors to return.</param>
        /// <returns>The <see cref="Image{T,TP}"/>.</returns>
        public static Image <T, TP> Quantize <T, TP>(this Image <T, TP> source, IQuantizer <T, TP> quantizer, int maxColors)
            where T : IPackedVector <TP>
            where TP : struct
        {
            QuantizedImage <T, TP> quantizedImage = quantizer.Quantize(source, maxColors);

            source.SetPixels(source.Width, source.Height, quantizedImage.ToImage().Pixels);
            return(source);
        }
Пример #3
0
        /// <summary>
        /// Applies quantization to the image.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
        /// <param name="source">The image this method extends.</param>
        /// <param name="quantizer">The quantizer to apply to perform the operation.</param>
        /// <param name="maxColors">The maximum number of colors to return.</param>
        /// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
        public static Image <TColor, TPacked> Quantize <TColor, TPacked>(this Image <TColor, TPacked> source, IQuantizer <TColor, TPacked> quantizer, int maxColors)
            where TColor : struct, IPackedPixel <TPacked>
            where TPacked : struct, IEquatable <TPacked>
        {
            QuantizedImage <TColor, TPacked> quantizedImage = quantizer.Quantize(source, maxColors);

            source.SetPixels(source.Width, source.Height, quantizedImage.ToImage().Pixels);
            return(source);
        }