Пример #1
0
        /// <summary>
        /// Private method to calculate the average color of a given
        /// Color[] array using the HSL color model to boost the
        /// Saturation and the Luminosity of the color.
        /// </summary>
        /// <param name="pixels">The <see cref="Color"/> array of pixels to average.</param>
        /// <returns>Returns a single <see cref="Color"/> object.</returns>
        private Color AverageAmbuino(Color[] pixels)
        {
            // Calculate average RGB and convert to HSL
            var hsl = new HSLColor(AverageRGB(pixels));

            // Bump up the Saturation
            // -(x-1)^2 + 1
            hsl.Saturation = -Math.Pow(hsl.Saturation - 1, 2.0) + 1;

            // Bump up the Luminosity (force to 0.5)
            // 4 * (x-0.5)^3 + 0.5
            hsl.Luminosity = 4.0 * Math.Pow(hsl.Luminosity - 0.5, 3.0) + 0.5;

            return (Color)hsl;
        }
Пример #2
0
 private static double GetTemp2(HSLColor hslColor)
 {
     double temp2;
     if (hslColor.luminosity < 0.5)  //<=??
         temp2 = hslColor.luminosity * (1.0 + hslColor.saturation);
     else
         temp2 = hslColor.luminosity + hslColor.saturation - (hslColor.luminosity * hslColor.saturation);
     return temp2;
 }