public static CIELab ToCIELab( this CIEAXYZ axyz ) { CIELab lab = CIELab.Empty; double x = axyz.X; double y = axyz.Y; double z = axyz.Z; lab.Luminance = 116.0 * Fxyz(y / CIEAXYZ.D65.Y) - 16; lab.RedGreenDimension = 500.0 * (Fxyz(x / CIEAXYZ.D65.X) - Fxyz(y / CIEAXYZ.D65.Y)); lab.YellowBlueDimension = 200.0 * (Fxyz(y / CIEAXYZ.D65.Y) - Fxyz(z / CIEAXYZ.D65.Z)); lab.Alpha = axyz.Alpha; return(lab); }
public static CIEAXYZ ToCIEAXYZ( this CIELab lab ) { double l = lab.Luminance; double a = lab.RedGreenDimension; double b = lab.YellowBlueDimension; double delta = 6.0 / 29.0; double fy = (l + 16) / 116.0; double fx = fy + (a / 500.0); double fz = fy - (b / 200.0); return(new CIEAXYZ( lab.Alpha, (fx > delta) ? CIEAXYZ.D65.X * (fx * fx * fx) : (fx - 16.0 / 116.0) * 3 * (delta * delta) * CIEAXYZ.D65.X, (fy > delta) ? CIEAXYZ.D65.Y * (fy * fy * fy) : (fy - 16.0 / 116.0) * 3 * (delta * delta) * CIEAXYZ.D65.Y, (fz > delta) ? CIEAXYZ.D65.Z * (fz * fz * fz) : (fz - 16.0 / 116.0) * 3 * (delta * delta) * CIEAXYZ.D65.Z)); }
public static DoubleColor Double( this CIELab lab ) { return(lab.ToCIEAXYZ().Double()); }