Class DominantColorOptions
Options for DominantColors(int, DominantColorOptions?).
public sealed record DominantColorOptions : IEquatable<DominantColorOptions>
- Inheritance
-
DominantColorOptions
- 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}");
}
Properties
AlphaThreshold
Gets the alpha below which a pixel is left out, as background. Defaults to 128.
public byte AlphaThreshold { get; init; }
Property Value
Default
Gets the default options.
public static DominantColorOptions Default { get; }
Property Value
Iterations
Gets the most k-means passes, 0 to 100; clustering stops sooner once nothing moves. Defaults to 16.
public int Iterations { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is out of range.
MaxSamples
Gets the most pixels clustered, 256 to 16,777,216: larger images are averaged down in square blocks first. Defaults to 65,536.
public int MaxSamples { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is out of range.
MergeDistance
Gets how close two clusters must be in Oklab to count as one color, 0 to 1. Defaults to 0.04, about the smallest difference people name as a different color.
public float MergeDistance { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is out of range.