Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function xyz_from_wavelength (ColorTemp, lw, currentCIE) {
var nmMin = 380;
var nmMax = 780;
var degrees = 5;
var XYZ = {x: 0,
y: 0,
z: 0};
//currentCIE pode ser "1931" ou "1965"
var nmMinIndex = nmMin - beta[currentCIE][0][0];
var nmMaxIndex = beta[currentCIE].length - 1 -
(beta[currentCIE][beta[currentCIE].length - 1][0] - nmMax);
var XSum = 0,
YSum = 0,
ZSum = 0;
var wSum = 0,
mac = 0;
for (nm = nmMinIndex; nm <= nmMaxIndex; nm += degrees) {
// calculate X
XSum += beta[currentCIE][nm][1] * lw[illuminant][nm][1] * ColorTemp[mac];
// calculate Y
YSum += beta[currentCIE][nm][2] * lw[illuminant][nm][1] * ColorTemp[mac];
// calculate Z
ZSum += beta[currentCIE][nm][3] * lw[illuminant][nm][1] * ColorTemp[mac];
wSum += beta[currentCIE][nm][2] * lw[illuminant][nm][1];
mac++;
}
return cXYZ(XSum/wSum, YSum/wSum, ZSum/wSum);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.