Struct WeightedColor
A color and the share of an image's pixels it stands for, from DominantColors(int, DominantColorOptions?).
public readonly record struct WeightedColor : IEquatable<WeightedColor>
- Implements
- Inherited Members
Examples
// The main colors and how much of the picture each covers, e.g. to pick brand colors from a logo or a placeholder color.
IReadOnlyList<WeightedColor> colors = logo.DominantColors(5);
foreach ((Rgba8 color, double weight) in colors)
{
Console.WriteLine($"#{color.R:X2}{color.G:X2}{color.B:X2} covers {weight:P0}");
}
Constructors
WeightedColor(Rgba8, double)
A color and the share of an image's pixels it stands for, from DominantColors(int, DominantColorOptions?).
public WeightedColor(Rgba8 Color, double Weight)
Parameters
ColorRgba8The color.
WeightdoubleThe share of the counted pixels nearest this color, from 0 to 1.
Examples
// The main colors and how much of the picture each covers, e.g. to pick brand colors from a logo or a placeholder color.
IReadOnlyList<WeightedColor> colors = logo.DominantColors(5);
foreach ((Rgba8 color, double weight) in colors)
{
Console.WriteLine($"#{color.R:X2}{color.G:X2}{color.B:X2} covers {weight:P0}");
}
Properties
Color
The color.
public Rgba8 Color { get; init; }
Property Value
Weight
The share of the counted pixels nearest this color, from 0 to 1.
public double Weight { get; init; }