def web_to_ucs(RGB, conds): """Converts from the web colorspace to CAM02-UCS.""" XYZ = web_to_XYZ(RGB) XYZ_w = web_to_XYZ([1, 1, 1]) Y_w, L_A, Y_b, surround = conds cam02 = colour.XYZ_to_CIECAM02(XYZ * Y_w, XYZ_w * Y_w, L_A, Y_b, surround) JMh = tstack([cam02.J, cam02.M, cam02.h]) return colour.models.JMh_CIECAM02_to_CAM02UCS(JMh)
""" import colour from colour.utilities.verbose import message_box message_box('"CIECAM02" Colour Appearance Model Computations') XYZ = (19.01, 20.00, 21.78) XYZ_w = (95.05, 100.00, 108.88) L_A = 318.31 Y_b = 20.0 surround = colour.CIECAM02_VIEWING_CONDITIONS['Average'] message_box(('Converting to "CIECAM02" colour appearance model specification ' 'using given parameters:\n' '\n\tXYZ: {0}\n\tXYZ_w: {1}\n\tL_A: {2}\n\tY_b: {3}' '\n\tSurround: {4}').format(XYZ, XYZ_w, L_A, Y_b, surround)) specification = colour.XYZ_to_CIECAM02(XYZ, XYZ_w, L_A, Y_b, surround) print(specification) print('\n') J = 41.73109113 C = 0.10470776 h = 219.04843266 specification = colour.CIECAM02_Specification(J, C, h) message_box(('Converting to "CIE XYZ" tristimulus values using given ' 'parameters:\n' '\n\tJ: {0}\n\tC: {1}\n\th: {2}\n\tXYZ_w: {3}\n\tL_A: {4}' '\n\tY_b: {5}').format(J, C, h, XYZ_w, L_A, Y_b)) print(colour.CIECAM02_to_XYZ(specification, XYZ_w, L_A, Y_b))
XYZ_w = np.array([Xw,Yw,Zw]) XYZ_d_ = np.array(XYZ_d) N_A = Light[:,0]/np.max(Light[:,0])*198.261 t1 = np.arange(400, 710, 10) plt.plot(t1,N_A, color='red', marker="", linestyle='dashdot') plt.plot(t1,Light[:,1], marker="", linestyle='dashdot') plt.plot(t1,Light[:,2], marker="", linestyle='dashdot') plt.xlabel('Wavelength') plt.ylabel('Relative power') plt.legend(['A', 'D50', 'D65'], loc='upper left') plt.show() #/ Generate input data with CIECAM02 model La = Yw/5 Yb = 20 Jab_ = [] viewing_condition = ['Average', 'Dim', 'Dark'] for j in viewing_condition: surround = colour.CIECAM02_VIEWING_CONDITIONS[j] ans = colour.XYZ_to_CIECAM02(XYZ_d_, XYZ_w.T, La, Yb, surround) J = ans[0].T a = ans[1].T*np.cos(ans[2].T/(180/math.pi)) b = ans[1].T*np.sin(ans[2].T/(180/math.pi)) Jab = np.c_[J,a,b] Jab_.append(Jab) Jab_o = np.concatenate((Jab_[0],Jab_[1],Jab_[2]),axis=0)