private static void Solve(float x1, float x2, float x3, ColorRGB rgb1, ColorRGB rgb2, ColorRGB rgb3, out float m1, out float m2, out float m3) { // Cramer's rule ColorTransformMatrix A = new ColorTransformMatrix ( rgb1.R, rgb1.G, rgb1.B, rgb2.R, rgb2.G, rgb2.B, rgb3.R, rgb3.G, rgb3.B ); ColorTransformMatrix A1 = new ColorTransformMatrix ( x1, rgb1.G, rgb1.B, x2, rgb2.G, rgb2.B, x3, rgb3.G, rgb3.B ); ColorTransformMatrix A2 = new ColorTransformMatrix ( rgb1.R, x1, rgb1.B, rgb2.R, x2, rgb2.B, rgb3.R, x3, rgb3.B ); ColorTransformMatrix A3 = new ColorTransformMatrix ( rgb1.R, rgb1.G, x1, rgb2.R, rgb2.G, x2, rgb3.R, rgb3.G, x3 ); float det = A.Determinant; m1 = A1.Determinant / det; m2 = A2.Determinant / det; m3 = A3.Determinant / det; }
public static Color1931XYZ ToXYZ(this ColorHSV HSV, ColorTransformMatrix RGBtoXYZ) { ColorRGB RGB = ToRGB(HSV); return(ToXYZ(HSV, RGBtoXYZ)); }
public static Chromaticity1976uv Touv(this ColorRGB RGB, ColorTransformMatrix RGBtoXYZ) { Color1931XYZ XYZ = ToXYZ(RGB, RGBtoXYZ); return(Touv(XYZ)); }
public static Chromaticity1931xy Toxy(this ColorHSV HSV, ColorTransformMatrix RGBtoXYZ) { ColorRGB RGB = ToRGB(HSV); return(Toxy(RGB, RGBtoXYZ)); }
public static Color1976Lab ToLab(this ColorRGB RGB, ColorTransformMatrix RGBtoXYZ, Color1931XYZ whiteLab) { Color1931XYZ XYZ = ToXYZ(RGB, RGBtoXYZ); return(ToLab(XYZ, whiteLab)); }
public static Color1931xyY ToxyY(this ColorRGB RGB, ColorTransformMatrix RGBtoXYZ) { Color1931XYZ XYZ = ToXYZ(RGB, RGBtoXYZ); return(ToxyY(XYZ)); }
public static ColorTransformMatrix GetXYZtoRGB(Color1931XYZ xyz1, Color1931XYZ xyz2, Color1931XYZ xyz3, ColorRGB rgb1, ColorRGB rgb2, ColorRGB rgb3) { return(GetRGBtoXYZ(xyz1, xyz2, xyz3, rgb1, rgb2, rgb3).Invert()); }
public static ColorTransformMatrix GetRGBtoXYZ(Color1931XYZ xyz1, Color1931XYZ xyz2, Color1931XYZ xyz3, ColorRGB rgb1, ColorRGB rgb2, ColorRGB rgb3) { float a, b, c; float d, e, f; float g, h, i; Solve(xyz1.X, xyz2.X, xyz3.X, rgb1, rgb2, rgb3, out a, out b, out c); Solve(xyz1.Y, xyz2.Y, xyz3.Y, rgb1, rgb2, rgb3, out d, out e, out f); Solve(xyz1.Z, xyz2.Z, xyz3.Z, rgb1, rgb2, rgb3, out g, out h, out i); return(new ColorTransformMatrix(a, b, c, d, e, f, g, h, i)); }