public void RgbToXyz(int[] rgb, double[] xyz) { var rgbColor = Color.FromArgb(rgb[0], rgb[1], rgb[2]); Assert.Equal( new XyzColor(xyz[0], xyz[1], xyz[2]), XyzColor.FromRgb(rgbColor) ); }
public IEnumerable <Color> PickColors(Bitmap bitmap, int count) { var(thumb, width, height) = Resize(bitmap, 72); using (thumb) { var colors = GetColors(thumb, width, height); var xyzColors = colors.Select(x => XyzColor.FromRgb(x)); var labColors = xyzColors.Select(x => CieLabColor.FromXyz(x)); var labSpace = new CieLabSpace(); var selections = KmeansPlusPlus(labColors.ToArray(), labSpace, count, _seed); return(selections.Select(x => labSpace.GetCentroid(x)).Select(x => x.ToXyzColor().ToRgbColor())); } }