Python: 如何自动填充colormath光谱颜色class?
Python: how to automatically fill colormath spectral color class?
还有SpectralColor Class in colormath。
我不想手动提供光谱数据,而是想用列表中的数据轻松自动填充 class,但我真的不知道这是如何工作的。
例如
from colormath.color_objects import LabColor, XYZColor, SpectralColor, AdobeRGBColor
from colormath.color_conversions import convert_color
test=[0.0864521948302278, 0.060647147441089, 0.0726747188946782, 0.0939848211034762, 0.117476972460373, 0.120470421815122, 0.135515000803907, 0.147192947184837, 0.158235428114852, 0.167354983153096, 0.176595115477727, 0.184356798767392, 0.191455139493337, 0.202102699343208, 0.214077113676754, 0.225593591186178, 0.239495675347855, 0.252998713390957, 0.268988453847135, 0.286663797550772, 0.304930930121131, 0.324055045587196, 0.340413611744997, 0.35813823359423, 0.372255852167114, 0.38710860985204, 0.400396731744843, 0.411356232148721, 0.422039413253371, 0.433510097645216, 0.445295564481938, 0.455445976037395, 0.465897317024798, 0.47640303941666, 0.485959434493102, 0.49540575001133, 0.504048573672828, 0.511424852548411, 0.518111900409216]
print (test)
test2=', '.join(str(x) for x in test)
spc2=SpectralColor(test2)
xyz = convert_color(spc2, XYZColor)
print ('xyz:', xyz)
谢谢!
...如果有人遇到相同或相似的问题。您以不同方式调用该函数:
spc2=SpectralColor(*test)
发现于 here
还有SpectralColor Class in colormath。
我不想手动提供光谱数据,而是想用列表中的数据轻松自动填充 class,但我真的不知道这是如何工作的。
例如
from colormath.color_objects import LabColor, XYZColor, SpectralColor, AdobeRGBColor
from colormath.color_conversions import convert_color
test=[0.0864521948302278, 0.060647147441089, 0.0726747188946782, 0.0939848211034762, 0.117476972460373, 0.120470421815122, 0.135515000803907, 0.147192947184837, 0.158235428114852, 0.167354983153096, 0.176595115477727, 0.184356798767392, 0.191455139493337, 0.202102699343208, 0.214077113676754, 0.225593591186178, 0.239495675347855, 0.252998713390957, 0.268988453847135, 0.286663797550772, 0.304930930121131, 0.324055045587196, 0.340413611744997, 0.35813823359423, 0.372255852167114, 0.38710860985204, 0.400396731744843, 0.411356232148721, 0.422039413253371, 0.433510097645216, 0.445295564481938, 0.455445976037395, 0.465897317024798, 0.47640303941666, 0.485959434493102, 0.49540575001133, 0.504048573672828, 0.511424852548411, 0.518111900409216]
print (test)
test2=', '.join(str(x) for x in test)
spc2=SpectralColor(test2)
xyz = convert_color(spc2, XYZColor)
print ('xyz:', xyz)
谢谢!
...如果有人遇到相同或相似的问题。您以不同方式调用该函数:
spc2=SpectralColor(*test)
发现于 here