A comprehensive guide to colorimetry - the science of measuring and quantifying color, providing the mathematical and scientific foundation for color reproduction, color management, and accurate color conversions in digital imaging and display technologies.
Colorimetry is the science of measuring and quantifying color based on the physical properties of light and the physiological response of the human visual system. It provides the mathematical and scientific foundation for color reproduction, color management, and accurate color conversions across different devices and media. Colorimetry enables consistent and predictable color communication in digital imaging, printing, and display technologies.
Colorimetry combines physics (light measurement), biology (human vision), and mathematics (color calculations) to create standardized methods for describing and reproducing colors accurately.
// Colorimetry system implementation
class ColorimetrySystem {
constructor() {
// CIE standard observers
this.standardObservers = {
'2deg': { name: 'CIE 1931 2° Standard Observer', fieldOfView: 2 },
'10deg': { name: 'CIE 1964 10° Standard Observer', fieldOfView: 10 }
};
// Standard illuminants
this.standardIlluminants = {
'A': { cct: 2856, type: 'incandescent' },
'D50': { cct: 5003, type: 'daylight' },
'D65': { cct: 6504, type: 'daylight' },
'E': { cct: 5454, type: 'equal-energy' }
};
}
// Calculate tristimulus values from spectral data
calculateTristimulus(spectralData, illuminant = 'D65', observer = '2deg') {
const { wavelengths, reflectance } = spectralData;
let X = 0, Y = 0, Z = 0;
let normalizationFactor = 0;
for (let i = 0; i < wavelengths.length; i++) {
const wl = wavelengths[i];
const rho = reflectance[i];
const S = this.getIlluminantPower(illuminant, wl);
const xBar = this.getColorMatchingValue('x', wl, observer);
const yBar = this.getColorMatchingValue('y', wl, observer);
const zBar = this.getColorMatchingValue('z', wl, observer);
const deltaWl = i < wavelengths.length - 1 ? wavelengths[i + 1] - wl : 5;
X += rho * S * xBar * deltaWl;
Y += rho * S * yBar * deltaWl;
Z += rho * S * zBar * deltaWl;
normalizationFactor += S * yBar * deltaWl;
}
const k = 100 / normalizationFactor;
return {
X: X * k,
Y: Y * k,
Z: Z * k,
illuminant,
observer
};
}
// Calculate correlated color temperature
calculateCCT(x, y, method = 'mccamy') {
if (method === 'mccamy') {
const n = (x - 0.3320) / (0.1858 - y);
const cct = 449 * Math.pow(n, 3) + 3525 * Math.pow(n, 2) + 6823.3 * n + 5520.33;
return Math.max(1000, Math.min(25000, cct));
}
return 6500; // Default
}
// Color difference calculations
calculateColorDifference(color1, color2, formula = 'CIE2000') {
const lab1 = this.ensureLAB(color1);
const lab2 = this.ensureLAB(color2);
let deltaE;
switch (formula) {
case 'CIE76':
deltaE = this.deltaE76(lab1, lab2);
break;
case 'CIE94':
deltaE = this.deltaE94(lab1, lab2);
break;
case 'CIE2000':
deltaE = this.deltaE2000(lab1, lab2);
break;
default:
deltaE = this.deltaE2000(lab1, lab2);
}
return {
deltaE,
formula,
interpretation: this.interpretDeltaE(deltaE)
};
}
deltaE76(lab1, lab2) {
const deltaL = lab1.L - lab2.L;
const deltaA = lab1.a - lab2.a;
const deltaB = lab1.b - lab2.b;
return Math.sqrt(deltaL * deltaL + deltaA * deltaA + deltaB * deltaB);
}
deltaE94(lab1, lab2, textiles = false) {
const kL = textiles ? 2 : 1;
const k1 = textiles ? 0.048 : 0.045;
const k2 = textiles ? 0.014 : 0.015;
const deltaL = lab1.L - lab2.L;
const deltaA = lab1.a - lab2.a;
const deltaB = lab1.b - lab2.b;
const c1 = Math.sqrt(lab1.a * lab1.a + lab1.b * lab1.b);
const deltaC = c1 - Math.sqrt(lab2.a * lab2.a + lab2.b * lab2.b);
const deltaH = Math.sqrt(deltaA * deltaA + deltaB * deltaB - deltaC * deltaC);
const sL = 1;
const sC = 1 + k1 * c1;
const sH = 1 + k2 * c1;
return Math.sqrt(
Math.pow(deltaL / (kL * sL), 2) +
Math.pow(deltaC / sC, 2) +
Math.pow(deltaH / sH, 2)
);
}
deltaE2000(lab1, lab2) {
// Simplified CIE Delta E 2000
const deltaL = lab2.L - lab1.L;
const c1 = Math.sqrt(lab1.a * lab1.a + lab1.b * lab1.b);
const c2 = Math.sqrt(lab2.a * lab2.a + lab2.b * lab2.b);
const avgC = (c1 + c2) / 2;
const g = 0.5 * (1 - Math.sqrt(Math.pow(avgC, 7) / (Math.pow(avgC, 7) + Math.pow(25, 7))));
const a1Prime = (1 + g) * lab1.a;
const a2Prime = (1 + g) * lab2.a;
const c1Prime = Math.sqrt(a1Prime * a1Prime + lab1.b * lab1.b);
const c2Prime = Math.sqrt(a2Prime * a2Prime + lab2.b * lab2.b);
const deltaC = c2Prime - c1Prime;
return Math.sqrt(deltaL * deltaL + deltaC * deltaC + Math.pow(lab1.b - lab2.b, 2));
}
interpretDeltaE(deltaE) {
if (deltaE < 1) return 'Not perceptible';
if (deltaE < 2) return 'Perceptible through close observation';
if (deltaE < 3.5) return 'Perceptible at a glance';
if (deltaE < 5) return 'Clear difference';
return 'Very clear difference';
}
ensureLAB(color) {
if (color.L !== undefined) return color;
if (color.X !== undefined) return this.xyzToLab(color.X, color.Y, color.Z);
if (color.r !== undefined) {
const xyz = this.rgbToXyz(color.r, color.g, color.b);
return this.xyzToLab(xyz.X, xyz.Y, xyz.Z);
}
throw new Error('Unsupported color format');
}
// Metamerism analysis
analyzeMetamerism(sample1, sample2, illuminants = ['D65', 'A']) {
const analysis = { isMetameric: false, metamericIndex: 0 };
const colors1 = illuminants.map(ill => this.calculateTristimulus(sample1, ill));
const colors2 = illuminants.map(ill => this.calculateTristimulus(sample2, ill));
const differences = colors1.map((c1, i) =>
this.calculateColorDifference(c1, colors2[i]).deltaE
);
const maxDiff = Math.max(...differences);
const minDiff = Math.min(...differences);
analysis.metamericIndex = maxDiff - minDiff;
analysis.isMetameric = analysis.metamericIndex > 1;
return analysis;
}
// Helper methods
getIlluminantPower(illuminant, wavelength) {
// Simplified - return normalized power
return 1.0;
}
getColorMatchingValue(component, wavelength, observer) {
// Simplified - return approximated values
if (component === 'y' && wavelength >= 500 && wavelength <= 600) {
return 1.0; // Peak sensitivity
}
return 0.1;
}
rgbToXyz(r, g, b) {
// sRGB to XYZ conversion
const rLin = this.srgbToLinear(r / 255);
const gLin = this.srgbToLinear(g / 255);
const bLin = this.srgbToLinear(b / 255);
return {
X: (rLin * 0.4124564 + gLin * 0.3575761 + bLin * 0.1804375) * 100,
Y: (rLin * 0.2126729 + gLin * 0.7151522 + bLin * 0.0721750) * 100,
Z: (rLin * 0.0193339 + gLin * 0.1191920 + bLin * 0.9503041) * 100
};
}
xyzToLab(X, Y, Z, illuminant = 'D65') {
const wp = { X: 95.047, Y: 100.000, Z: 108.883 }; // D65 white point
const xn = X / wp.X;
const yn = Y / wp.Y;
const zn = Z / wp.Z;
const fx = this.labFunction(xn);
const fy = this.labFunction(yn);
const fz = this.labFunction(zn);
return {
L: Math.max(0, Math.min(100, 116 * fy - 16)),
a: Math.max(-128, Math.min(127, 500 * (fx - fy))),
b: Math.max(-128, Math.min(127, 200 * (fy - fz)))
};
}
labFunction(t) {
const delta = 6 / 29;
const deltaCubed = delta * delta * delta;
if (t > deltaCubed) {
return Math.pow(t, 1/3);
} else {
return (t / (3 * delta * delta)) + (4 / 29);
}
}
srgbToLinear(value) {
if (value <= 0.04045) {
return value / 12.92;
} else {
return Math.pow((value + 0.055) / 1.055, 2.4);
}
}
}Colorimetry is based on the tristimulus theory of human color vision, which states that any color can be matched by combining three primary stimuli in appropriate proportions. This forms the basis of the CIE XYZ color space.
Measures the complete spectral reflectance or transmittance of a sample, providing the most accurate and complete color information. Essential for color matching and quality control.
Direct measurement of tristimulus values using filtered photodiodes that simulate the human eye's response. Faster but less accurate than spectrophotometry.
Human visual evaluation under controlled lighting conditions. Still important for final quality assessment despite instrumental methods.
The original CIE color difference formula based on Euclidean distance in LAB space. Simple but not perceptually uniform across all colors.
Improved formula that accounts for perceptual non-uniformities in LAB space. Better correlation with visual assessment than ΔE*76.
Most advanced CIE color difference formula with excellent correlation to visual perception. Accounts for various perceptual phenomena.
Explore these comprehensive pillar articles related to Colorimetry
A comprehensive guide to color theory, its fundamental principles, and practical applications in digital design and web development.
Comprehensive guide to complementary colors - opposing hues on the color wheel that create maximum visual contrast, dynamic tension, and powerful design impact through scientific color relationships and perceptual phenomena.
Comprehensive guide to analogous color schemes - adjacent hues on the color wheel that create natural harmony, visual cohesion, and sophisticated design solutions through subtle color relationships and graduated transitions.
Comprehensive guide to triadic color schemes - three colors evenly spaced around the color wheel that create balanced, vibrant, and dynamic visual compositions with mathematical precision and artistic appeal.
Discover more about Colorimetry and related color theory concepts
A comprehensive guide to color theory, its fundamental principles, and practical applications in digital design and web development.
Comprehensive guide to analogous color schemes - adjacent hues on the color wheel that create natural harmony, visual cohesion, and sophisticated design solutions through subtle color relationships and graduated transitions.
Comprehensive guide to complementary colors - opposing hues on the color wheel that create maximum visual contrast, dynamic tension, and powerful design impact through scientific color relationships and perceptual phenomena.
A comprehensive guide to monochromatic color schemes - sophisticated single-hue harmonies that create unified visual experiences through systematic variations in saturation, lightness, and tonal relationships, essential for elegant design compositions, brand consistency, and advanced color theory applications requiring cohesive aesthetic unity.
A comprehensive guide to split-complementary color schemes - sophisticated three-color harmonies that combine a base color with two colors adjacent to its complement, creating balanced visual contrast with reduced tension compared to direct complementary pairs, essential for refined design compositions, brand identity systems, and advanced color theory applications.
A comprehensive guide to tetradic color schemes - sophisticated four-color harmonies that use two complementary pairs arranged in rectangular or square formations on the color wheel, providing maximum color variety while maintaining structured relationships essential for dynamic design compositions, brand systems, and advanced color theory applications.
Discover more color terminology and concepts in our comprehensive glossary.
Browse Full Glossary