A comprehensive guide to chromaticity - the objective specification of the quality of a color regardless of its luminance, fundamental to color science and essential for accurate color conversions, color matching, and color reproduction across different devices and applications.
Chromaticity is the objective specification of the quality of a color regardless of its luminance (brightness). It represents the color information independent of intensity, making it fundamental to color science, color matching, and accurate color reproduction. Chromaticity coordinates provide a two-dimensional representation of color that enables precise color specification and comparison.
Chromaticity separates the color quality (hue and saturation) from the brightness information, allowing colors to be compared and specified independently of their luminance. This separation is crucial for color matching applications where the same color may appear at different brightness levels.
// Chromaticity calculator implementation
class ChromaticityCalculator {
constructor() {
// Standard illuminants with chromaticity coordinates
this.illuminants = {
'A': { x: 0.44757, y: 0.40745, name: 'Tungsten 2856K' },
'D50': { x: 0.34567, y: 0.35850, name: 'Daylight 5003K' },
'D65': { x: 0.31271, y: 0.32902, name: 'Daylight 6504K' },
'E': { x: 0.33333, y: 0.33333, name: 'Equal Energy' }
};
// RGB color space primaries
this.rgbPrimaries = {
'sRGB': {
red: { x: 0.6400, y: 0.3300 },
green: { x: 0.3000, y: 0.6000 },
blue: { x: 0.1500, y: 0.0600 },
white: { x: 0.3127, y: 0.3290 }
},
'Adobe RGB': {
red: { x: 0.6400, y: 0.3300 },
green: { x: 0.2100, y: 0.7100 },
blue: { x: 0.1500, y: 0.0600 },
white: { x: 0.3127, y: 0.3290 }
}
};
}
// Convert XYZ to chromaticity coordinates
xyzToChromaticity(X, Y, Z) {
const sum = X + Y + Z;
if (sum === 0 || sum < 1e-10) {
return { x: 0, y: 0, Y: 0, valid: false };
}
return {
x: X / sum,
y: Y / sum,
z: Z / sum,
Y: Y,
valid: true
};
}
// Convert chromaticity coordinates to XYZ
chromaticityToXYZ(x, y, Y = 100) {
if (y === 0) {
return { X: 0, Y: 0, Z: 0, valid: false };
}
return {
X: (x * Y) / y,
Y: Y,
Z: ((1 - x - y) * Y) / y,
valid: true
};
}
// Calculate dominant wavelength
calculateDominantWavelength(x, y, illuminant = 'D65') {
const whitePoint = this.illuminants[illuminant];
// Vector from white point to color point
const dx = x - whitePoint.x;
const dy = y - whitePoint.y;
// Simplified calculation - would need spectral locus data for accuracy
const angle = Math.atan2(dy, dx) * 180 / Math.PI;
const wavelength = 380 + ((angle + 180) / 360) * 400;
const distance = Math.sqrt(dx * dx + dy * dy);
const maxDistance = 0.4; // Approximate
const purity = Math.min(1, distance / maxDistance);
return {
dominantWavelength: Math.round(Math.max(380, Math.min(780, wavelength))),
purity: purity,
purityPercentage: Math.round(purity * 100)
};
}
// Calculate color temperature from chromaticity
calculateColorTemperature(x, y) {
// McCamy's approximation
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 {
cct: Math.max(1000, Math.min(25000, Math.round(cct))),
method: 'McCamy approximation'
};
}
// Check if chromaticity is within gamut
isWithinGamut(x, y, colorSpace = 'sRGB') {
const primaries = this.rgbPrimaries[colorSpace];
if (!primaries) return { withinGamut: false, error: 'Unknown color space' };
const { red, green, blue } = primaries;
// Barycentric coordinate test
const denom = (green.y - blue.y) * (red.x - blue.x) + (blue.x - green.x) * (red.y - blue.y);
const a = ((green.y - blue.y) * (x - blue.x) + (blue.x - green.x) * (y - blue.y)) / denom;
const b = ((blue.y - red.y) * (x - blue.x) + (red.x - blue.x) * (y - blue.y)) / denom;
const c = 1 - a - b;
return {
withinGamut: a >= 0 && b >= 0 && c >= 0,
barycentricCoordinates: { a, b, c },
colorSpace: colorSpace
};
}
// Calculate chromaticity difference
calculateChromaticityDifference(x1, y1, x2, y2) {
const deltaX = x1 - x2;
const deltaY = y1 - y2;
const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
return {
deltaX: deltaX,
deltaY: deltaY,
distance: distance,
significance: distance < 0.001 ? 'Imperceptible' :
distance < 0.003 ? 'Just noticeable' :
distance < 0.01 ? 'Noticeable' : 'Significant'
};
}
// Analyze chromaticity properties
analyzeChromaticity(x, y, illuminant = 'D65') {
const dominantWavelength = this.calculateDominantWavelength(x, y, illuminant);
const colorTemperature = this.calculateColorTemperature(x, y);
const gamutAnalysis = {};
Object.keys(this.rgbPrimaries).forEach(colorSpace => {
gamutAnalysis[colorSpace] = this.isWithinGamut(x, y, colorSpace);
});
return {
coordinates: { x, y },
dominantWavelength: dominantWavelength,
colorTemperature: colorTemperature,
gamutAnalysis: gamutAnalysis,
distanceFromCenter: Math.sqrt(Math.pow(x - 0.33333, 2) + Math.pow(y - 0.33333, 2))
};
}
}The most common chromaticity representation uses the CIE 1931 xy chromaticity coordinates, derived from XYZ tristimulus values. These coordinates define a two-dimensional color space where x and y represent the color quality independent of brightness.
Chromaticity coordinates are calculated from XYZ values using normalization: x = X/(X+Y+Z), y = Y/(X+Y+Z), z = Z/(X+Y+Z), where x + y + z = 1.
The CIE chromaticity diagram plots all visible colors in a horseshoe-shaped region, with the spectral locus forming the curved boundary and the purple line connecting the red and violet ends.
Each RGB color space is defined by the chromaticity coordinates of its red, green, and blue primaries, plus the white point chromaticity. These define the color gamut triangle on the chromaticity diagram.
The chromaticity coordinates of color space primaries form triangular boundaries that define which colors can be reproduced. Larger triangles indicate wider color gamuts.
The white point chromaticity coordinates specify the color that appears neutral white in a given color space, typically corresponding to a standard illuminant.
The dominant wavelength is found by drawing a line from the white point through the color point to the spectral locus, indicating the perceived hue of the color.
Color purity is the ratio of the distance from white point to color point versus the distance from white point to the spectral locus, indicating saturation level.
Correlated color temperature can be calculated from chromaticity coordinates using approximation formulas, providing a measure of the warmth or coolness of white and near-white colors.
Chromaticity coordinates are essential for creating ICC color profiles, defining the color characteristics of devices for accurate color management.
Accurate conversion between different color spaces requires precise chromaticity information to maintain color accuracy across different devices and applications.
Chromaticity diagrams enable visualization and analysis of color gamuts, helping optimize color reproduction strategies for specific applications.
Explore these comprehensive pillar articles related to Chromaticity
A comprehensive guide to color theory, its fundamental principles, and practical applications in digital design and web development.
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.
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.
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.
Discover more about Chromaticity and related color theory concepts
A comprehensive guide to color theory, its fundamental principles, and practical applications in digital design and web development.
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.
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.
Discover more color terminology and concepts in our comprehensive glossary.
Browse Full Glossary