ArduinoTest.Components.ColorManagment.Service.ColorHelper.ComputeProminentColor C# (CSharp) Метод

ComputeProminentColor() публичный Метод

Computes the color that shows up the most often
public ComputeProminentColor ( IEnumerable colors ) : Color
colors IEnumerable /// The total collection of sampled colors ///
Результат Color
        public Color ComputeProminentColor(IEnumerable<Color> colors)
        {
            var colorCount = new Dictionary<Color, int?>();

            foreach(var color in colors)
            {
                if(!colorCount.ContainsKey(color))
                {
                    colorCount[color] = 0;
                }
                colorCount[color]++;
            }

            return colorCount.OrderByDescending(p => p.Value).First().Key;
        }