def to_xyz100(self, lab): L_R, a_R, b_R = lab y_ref_s = L_R / 100 x_ref_s = a_R / 430 + y_ref_s z_ref_s = y_ref_s - b_R / 170 xyz_ref = np.array([x_ref_s, y_ref_s, z_ref_s]) ** (1.0 / self.sigma) return npx.solve(self.M, (npx.solve(self.R, xyz_ref).T / self.a_lms).T)
def to_rec2100(self, ictcp): lms_ = npx.solve(self.M2, ictcp) t = lms_**(1 / self.m2) - self.c1 # This next line is part of the model, but really it shouldn't occur for sane # input data. # t[t < 0] = 0.0 lms = (t / (self.c2 - self.c3 * lms_**(1 / self.m2)))**(1 / self.m1) rgb = npx.solve(self.M1, lms) return rgb
def to_xyz100(self, jzazbz): jz, az, bz = jzazbz iz = (jz + self.d0) / (1 + self.d - self.d * (jz + self.d0)) lms_ = npx.solve(self.M2, np.array([iz, az, bz])) if np.any(lms_ < 0.0): raise ColorioError("Illegal LMS value.") lms = 10000 * ((self.c1 - lms_**(1 / self.p)) / (self.c3 * lms_**(1 / self.p) - self.c2))**(1 / self.n) x_, y_, z_ = npx.solve(self.M1, lms) x = (x_ + (self.b - 1) * z_) / self.b y = (y_ + (self.g - 1) * x) / self.g # return (np.array([x, y, z_]).T * self.whitepoint).T return np.array([x, y, z_])
def from_xyz100(self, xyz100): # TODO NaN the values smaller than 0 and larger than 1 return npx.solve(self.invM, np.asarray(xyz100) / 100)
def to_xyz100(self, ipt): lms_ = npx.solve(self.M2, ipt) lms = np.sign(lms_) * np.abs(lms_)**(1 / 0.43) return npx.solve(self.M1, lms)
def from_xyz100(self, xyz): # https://en.wikipedia.org/wiki/SRGB#The_forward_transformation_(CIE_XYZ_to_sRGB) # http://www.color.org/srgb.pdf # TODO NaN the values smaller than 0 and larger than 1 return npx.solve(self.invM, xyz / 100)