public void DetectImageProperties() { Image image = LoadResourceImage("SchmidtBrinPage.jpg"); // Snippet: DetectImageProperties ImageAnnotatorClient client = ImageAnnotatorClient.Create(); ImageProperties properties = client.DetectImageProperties(image); ColorInfo dominantColor = properties.DominantColors.Colors.OrderByDescending(c => c.PixelFraction).First(); Console.WriteLine($"Dominant color in image: {dominantColor}"); // End snippet Assert.Equal(0.18, dominantColor.PixelFraction, 2); Assert.Equal(new Color { Red = 16, Green = 13, Blue = 8 }, dominantColor.Color); }
private List <MediaProperties> AnalyseColors(ImageAnnotatorClient client, Image image) { var colorList = new List <MediaProperties>(); var imageProperties = client.DetectImageProperties(image); if (imageProperties != null && imageProperties.DominantColors != null && imageProperties.DominantColors.Colors != null) { foreach (var color in imageProperties.DominantColors.Colors) { colorList.Add(new MediaProperties { Type = MediaPropertyType.Color, Value = color.Color.Red + "" + color.Color.Green + "" + color.Color.Blue, Score = color.Score, }); } } return(colorList); }