def output_specification_from_data(self, data): """ Returns the LLAB(l:c) colour appearance model output specification from given data. Parameters ---------- data : list Fixture data. Returns ------- LLAB_Specification LLAB(l:c) colour appearance model specification. """ XYZ = tstack((data['X'], data['Y'], data['Z'])) XYZ_0 = tstack((data['X_0'], data['Y_0'], data['Z_0'])) specification = XYZ_to_LLAB(XYZ, XYZ_0, data['Y_b'], data['L'], LLAB_InductionFactors(1, data['F_S'], data['F_L'], data['F_C'])) return specification
def XYZ_to_LMS_ATD95(XYZ): """ Converts from *CIE XYZ* tristimulus values to *LMS* cone responses. Parameters ---------- XYZ : array_like *CIE XYZ* tristimulus values. Returns ------- ndarray *LMS* cone responses. Examples -------- >>> XYZ = np.array([19.01, 20.00, 21.78]) >>> XYZ_to_LMS_ATD95(XYZ) # doctest: +ELLIPSIS array([ 6.2283272..., 7.4780666..., 3.8859772...]) """ X, Y, Z = tsplit(XYZ) L = ((0.66 * (0.2435 * X + 0.8524 * Y - 0.0516 * Z))**0.7) + 0.024 M = ((-0.3954 * X + 1.1642 * Y + 0.0837 * Z)**0.7) + 0.036 S = ((0.43 * (0.04 * Y + 0.6225 * Z))**0.7) + 0.31 LMS = tstack((L, M, S)) return LMS
def XYZ_to_LMS_ATD95(XYZ): """ Converts from *CIE XYZ* tristimulus values to *LMS* cone responses. Parameters ---------- XYZ : array_like *CIE XYZ* tristimulus values. Returns ------- ndarray *LMS* cone responses. Examples -------- >>> XYZ = np.array([19.01, 20.00, 21.78]) >>> XYZ_to_LMS_ATD95(XYZ) # doctest: +ELLIPSIS array([ 6.2283272..., 7.4780666..., 3.8859772...]) """ X, Y, Z = tsplit(XYZ) L = ((0.66 * (0.2435 * X + 0.8524 * Y - 0.0516 * Z)) ** 0.7) + 0.024 M = ((-0.3954 * X + 1.1642 * Y + 0.0837 * Z) ** 0.7) + 0.036 S = ((0.43 * (0.04 * Y + 0.6225 * Z)) ** 0.7) + 0.31 LMS = tstack((L, M, S)) return LMS
def output_specification_from_data(self, data): """ Returns the *LLAB(l:c)* colour appearance model output specification from given data. Parameters ---------- data : list Fixture data. Returns ------- LLAB_Specification *LLAB(l:c)* colour appearance model specification. """ XYZ = tstack([data['X'], data['Y'], data['Z']]) XYZ_0 = tstack([data['X_0'], data['Y_0'], data['Z_0']]) specification = XYZ_to_LLAB( XYZ, XYZ_0, data['Y_b'], data['L'], LLAB_InductionFactors(1, data['F_S'], data['F_L'], data['F_C'])) return specification
def opponent_colour_dimensions(LMS_g): """ Returns opponent colour dimensions from given post adaptation cone signals. Parameters ---------- LMS_g : array_like Post adaptation cone signals. Returns ------- ndarray Opponent colour dimensions. Examples -------- >>> LMS_g = np.array([6.95457922, 7.08945043, 6.44069316]) >>> opponent_colour_dimensions(LMS_g) # doctest: +ELLIPSIS array([ 0.1787931..., 0.0286942..., 0.0107584..., 0.0192182..., 0.0205377..., 0.0107584...]) """ L_g, M_g, S_g = tsplit(LMS_g) A_1i = 3.57 * L_g + 2.64 * M_g T_1i = 7.18 * L_g - 6.21 * M_g D_1i = -0.7 * L_g + 0.085 * M_g + S_g A_2i = 0.09 * A_1i T_2i = 0.43 * T_1i + 0.76 * D_1i D_2i = D_1i A_1 = final_response(A_1i) T_1 = final_response(T_1i) D_1 = final_response(D_1i) A_2 = final_response(A_2i) T_2 = final_response(T_2i) D_2 = final_response(D_2i) return tstack((A_1, T_1, D_1, A_2, T_2, D_2))
def opponent_colour_dimensions(LMS_g): """ Returns opponent colour dimensions from given post adaptation cone signals. Parameters ---------- LMS_g : array_like Post adaptation cone signals. Returns ------- ndarray Opponent colour dimensions. Examples -------- >>> LMS_g = np.array([6.95457922, 7.08945043, 6.44069316]) >>> opponent_colour_dimensions(LMS_g) # doctest: +ELLIPSIS array([ 0.1787931..., 0.0286942..., 0.0107584..., 0.0192182..., ...]) """ L_g, M_g, S_g = tsplit(LMS_g) A_1i = 3.57 * L_g + 2.64 * M_g T_1i = 7.18 * L_g - 6.21 * M_g D_1i = -0.7 * L_g + 0.085 * M_g + S_g A_2i = 0.09 * A_1i T_2i = 0.43 * T_1i + 0.76 * D_1i D_2i = D_1i A_1 = final_response(A_1i) T_1 = final_response(T_1i) D_1 = final_response(D_1i) A_2 = final_response(A_2i) T_2 = final_response(T_2i) D_2 = final_response(D_2i) return tstack((A_1, T_1, D_1, A_2, T_2, D_2))