A comprehensive guide to chromaticity coordinates - the two-dimensional representation of color that separates chromaticity (hue and saturation) from luminance, enabling precise color specification and visualization in the CIE chromaticity diagram for color science applications.
Chromaticity coordinates are a fundamental concept in color science that provide a two-dimensional representation of color independent of luminance. By normalizing the tristimulus values X, Y, and Z, chromaticity coordinates (x, y) create a standardized way to specify and visualize colors on the CIE chromaticity diagram. This separation of chromaticity from brightness is essential for color matching, gamut visualization, and understanding color relationships in digital imaging and color management systems.
Chromaticity coordinates are derived from CIE XYZ tristimulus values through normalization, creating a device-independent color specification that focuses purely on the color quality rather than its intensity.
// Chromaticity Coordinate System
class ChromaticityCoordinates {
constructor() {
// CIE chromaticity coordinate system
this.system = {
name: 'CIE xy Chromaticity Coordinates',
year_established: 1931,
basis: 'CIE XYZ tristimulus values',
dimensions: 2,
coordinate_names: ['x', 'y'],
coordinate_ranges: {
x: { min: 0, max: 1 },
y: { min: 0, max: 1 }
},
constraint: 'x + y + z = 1 (where z is implicit)',
gamut_boundary: 'Spectral locus and purple line',
white_point_location: 'Interior of gamut triangle'
};
// Standard illuminant chromaticity coordinates
this.standardIlluminants = {
'A': { x: 0.44757, y: 0.40745, description: 'Incandescent tungsten' },
'B': { x: 0.34842, y: 0.35161, description: 'Obsolete daylight' },
'C': { x: 0.31006, y: 0.31616, description: 'Obsolete daylight' },
'D50': { x: 0.34567, y: 0.35850, description: 'Horizon daylight' },
'D55': { x: 0.33242, y: 0.34743, description: 'Mid-morning daylight' },
'D65': { x: 0.31271, y: 0.32902, description: 'Noon daylight' },
'D75': { x: 0.29902, y: 0.31485, description: 'North sky daylight' },
'E': { x: 0.33333, y: 0.33333, description: 'Equal energy' },
'F2': { x: 0.37208, y: 0.37529, description: 'Cool white fluorescent' },
'F7': { x: 0.31292, y: 0.32933, description: 'Broad-band daylight fluorescent' },
'F11': { x: 0.38052, y: 0.37713, description: 'Narrow-band white fluorescent' }
};
// Color gamut boundaries in chromaticity coordinates
this.gamutBoundaries = {
'sRGB': {
red: { x: 0.6400, y: 0.3300 },
green: { x: 0.3000, y: 0.6000 },
blue: { x: 0.1500, y: 0.0600 },
white_point: { x: 0.3127, y: 0.3290 }, // D65
area: 0.0954, // Approximate area in xy space
coverage: 'Standard web and HDTV gamut'
},
'Adobe_RGB': {
red: { x: 0.6400, y: 0.3300 },
green: { x: 0.2100, y: 0.7100 },
blue: { x: 0.1500, y: 0.0600 },
white_point: { x: 0.3127, y: 0.3290 }, // D65
area: 0.1204, // Approximate area in xy space
coverage: 'Professional photography and print'
},
'DCI_P3': {
red: { x: 0.6800, y: 0.3200 },
green: { x: 0.2650, y: 0.6900 },
blue: { x: 0.1500, y: 0.0600 },
white_point: { x: 0.3140, y: 0.3510 }, // DCI white
area: 0.1178, // Approximate area in xy space
coverage: 'Digital cinema and wide gamut displays'
},
'Rec2020': {
red: { x: 0.7080, y: 0.2920 },
green: { x: 0.1700, y: 0.7970 },
blue: { x: 0.1310, y: 0.0460 },
white_point: { x: 0.3127, y: 0.3290 }, // D65
area: 0.1688, // Approximate area in xy space
coverage: 'Ultra high definition television'
}
};
// Spectral locus data (monochromatic colors)
this.spectralLocus = this.generateSpectralLocus();
}
// Convert XYZ to chromaticity coordinates
xyzToChromaticity(X, Y, Z) {
const conversion = {
input_xyz: { X, Y, Z },
sum: X + Y + Z,
chromaticity: null,
luminance: Y,
validation: {
valid_input: true,
warnings: [],
errors: []
}
};
// Validate input
if (X < 0 || Y < 0 || Z < 0) {
conversion.validation.valid_input = false;
conversion.validation.errors.push('Negative tristimulus values not allowed');
}
if (conversion.sum === 0) {
conversion.validation.valid_input = false;
conversion.validation.errors.push('All tristimulus values are zero');
return conversion;
}
if (conversion.sum < 0.001) {
conversion.validation.warnings.push('Very low tristimulus values may cause precision issues');
}
// Calculate chromaticity coordinates
conversion.chromaticity = {
x: X / conversion.sum,
y: Y / conversion.sum,
z: Z / conversion.sum // z coordinate (implicit, x + y + z = 1)
};
// Additional properties
conversion.chromaticity.dominant_wavelength = this.calculateDominantWavelength(
conversion.chromaticity.x,
conversion.chromaticity.y
);
conversion.chromaticity.excitation_purity = this.calculateExcitationPurity(
conversion.chromaticity.x,
conversion.chromaticity.y
);
return conversion;
}
// Convert chromaticity coordinates back to XYZ (requires luminance)
chromaticityToXYZ(x, y, Y = 100) {
const conversion = {
input_chromaticity: { x, y },
input_luminance: Y,
xyz: null,
validation: {
valid_input: true,
warnings: [],
errors: []
}
};
// Validate chromaticity coordinates
if (x < 0 || x > 1 || y < 0 || y > 1) {
conversion.validation.errors.push('Chromaticity coordinates must be between 0 and 1');
}
if (x + y > 1) {
conversion.validation.errors.push('Sum of x and y coordinates cannot exceed 1');
}
if (Y < 0) {
conversion.validation.errors.push('Luminance (Y) cannot be negative');
}
if (conversion.validation.errors.length > 0) {
conversion.validation.valid_input = false;
return conversion;
}
// Check if coordinates are within visible gamut
if (!this.isWithinVisibleGamut(x, y)) {
conversion.validation.warnings.push('Coordinates may be outside visible gamut');
}
// Calculate XYZ values
if (y === 0) {
conversion.validation.errors.push('Cannot convert when y coordinate is zero');
conversion.validation.valid_input = false;
return conversion;
}
conversion.xyz = {
X: (x * Y) / y,
Y: Y,
Z: ((1 - x - y) * Y) / y
};
return conversion;
}
// Calculate dominant wavelength
calculateDominantWavelength(x, y, whitePoint = this.standardIlluminants.D65) {
const analysis = {
chromaticity: { x, y },
white_point: whitePoint,
dominant_wavelength: null,
excitation_purity: null,
color_type: null
};
// Vector from white point to color
const dx = x - whitePoint.x;
const dy = y - whitePoint.y;
if (Math.abs(dx) < 0.0001 && Math.abs(dy) < 0.0001) {
analysis.color_type = 'achromatic';
analysis.dominant_wavelength = null;
analysis.excitation_purity = 0;
return analysis;
}
// Find intersection with spectral locus or purple line
let minDistance = Infinity;
let closestWavelength = null;
let isPurpleLine = false;
// Check spectral locus
for (let wavelength = 380; wavelength <= 780; wavelength += 1) {
const spectralPoint = this.spectralLocus[wavelength];
if (!spectralPoint) continue;
// Check if this spectral point is on the line from white point through color
const spectralDx = spectralPoint.x - whitePoint.x;
const spectralDy = spectralPoint.y - whitePoint.y;
// Check if vectors are collinear and in same direction
const crossProduct = dx * spectralDy - dy * spectralDx;
const dotProduct = dx * spectralDx + dy * spectralDy;
if (Math.abs(crossProduct) < 0.001 && dotProduct > 0) {
const distance = Math.sqrt(spectralDx * spectralDx + spectralDy * spectralDy);
if (distance < minDistance) {
minDistance = distance;
closestWavelength = wavelength;
isPurpleLine = false;
}
}
}
// Check purple line if no spectral match found
if (closestWavelength === null) {
// Purple line connects 380nm and 780nm
const purple380 = this.spectralLocus[380];
const purple780 = this.spectralLocus[780];
// Find intersection with purple line
const purpleIntersection = this.findLineIntersection(
whitePoint.x, whitePoint.y, x, y,
purple380.x, purple380.y, purple780.x, purple780.y
);
if (purpleIntersection) {
analysis.color_type = 'purple';
analysis.complementary_wavelength = this.findComplementaryWavelength(
purpleIntersection.x, purpleIntersection.y, whitePoint
);
isPurpleLine = true;
}
}
if (closestWavelength !== null && !isPurpleLine) {
analysis.color_type = 'spectral';
analysis.dominant_wavelength = closestWavelength;
}
// Calculate excitation purity
const colorDistance = Math.sqrt(dx * dx + dy * dy);
analysis.excitation_purity = minDistance > 0 ? colorDistance / minDistance : 0;
return analysis;
}
// Calculate excitation purity
calculateExcitationPurity(x, y, whitePoint = this.standardIlluminants.D65) {
const colorDistance = Math.sqrt(
Math.pow(x - whitePoint.x, 2) + Math.pow(y - whitePoint.y, 2)
);
// Find distance to gamut boundary in same direction
const boundaryPoint = this.findGamutBoundaryIntersection(x, y, whitePoint);
const boundaryDistance = Math.sqrt(
Math.pow(boundaryPoint.x - whitePoint.x, 2) + Math.pow(boundaryPoint.y - whitePoint.y, 2)
);
return boundaryDistance > 0 ? colorDistance / boundaryDistance : 0;
}
// Analyze color gamut in chromaticity space
analyzeColorGamut(gamutName) {
const analysis = {
gamut_name: gamutName,
gamut_data: this.gamutBoundaries[gamutName],
analysis_results: {},
comparisons: {},
recommendations: []
};
if (!analysis.gamut_data) {
analysis.error = `Unknown gamut: ${gamutName}`;
return analysis;
}
const gamut = analysis.gamut_data;
// Calculate gamut properties
analysis.analysis_results = {
area: this.calculateGamutArea(gamut),
perimeter: this.calculateGamutPerimeter(gamut),
centroid: this.calculateGamutCentroid(gamut),
aspect_ratio: this.calculateGamutAspectRatio(gamut),
color_temperature_range: this.analyzeColorTemperatureRange(gamut),
spectral_coverage: this.analyzeSpectralCoverage(gamut)
};
// Compare with other gamuts
Object.keys(this.gamutBoundaries).forEach(otherGamut => {
if (otherGamut !== gamutName) {
analysis.comparisons[otherGamut] = this.compareGamuts(gamut, this.gamutBoundaries[otherGamut]);
}
});
// Generate recommendations
analysis.recommendations = this.generateGamutRecommendations(analysis);
return analysis;
}
// Convert between different chromaticity coordinate systems
convertChromaticitySystem(x, y, fromSystem, toSystem) {
const conversion = {
input: { x, y, system: fromSystem },
output: null,
conversion_matrix: null,
accuracy: null
};
// Currently only supporting CIE xy system
// Future implementations could include u'v', UV, etc.
if (fromSystem === 'CIE_xy' && toSystem === 'CIE_xy') {
conversion.output = { x, y, system: toSystem };
conversion.accuracy = 'exact';
} else if (fromSystem === 'CIE_xy' && toSystem === 'CIE_uv_1960') {
// Convert to CIE 1960 UCS
const u = (4 * x) / (-2 * x + 12 * y + 3);
const v = (6 * y) / (-2 * x + 12 * y + 3);
conversion.output = { u, v, system: toSystem };
conversion.accuracy = 'exact';
} else if (fromSystem === 'CIE_xy' && toSystem === 'CIE_upvp_1976') {
// Convert to CIE 1976 UCS (u', v')
const up = (4 * x) / (-2 * x + 12 * y + 3);
const vp = (9 * y) / (-2 * x + 12 * y + 3);
conversion.output = { up, vp, system: toSystem };
conversion.accuracy = 'exact';
} else {
conversion.error = `Conversion from ${fromSystem} to ${toSystem} not implemented`;
}
return conversion;
}
// Generate spectral locus data
generateSpectralLocus() {
const locus = {};
// Simplified spectral locus approximation
for (let wavelength = 380; wavelength <= 780; wavelength += 1) {
// These are simplified approximations - real data would come from CIE tables
let x, y;
if (wavelength <= 440) {
// Violet to blue
const t = (wavelength - 380) / (440 - 380);
x = 0.15 + 0.02 * t;
y = 0.02 + 0.04 * t;
} else if (wavelength <= 490) {
// Blue to cyan
const t = (wavelength - 440) / (490 - 440);
x = 0.17 - 0.02 * t;
y = 0.06 + 0.24 * t;
} else if (wavelength <= 520) {
// Cyan to green
const t = (wavelength - 490) / (520 - 490);
x = 0.15 + 0.15 * t;
y = 0.30 + 0.30 * t;
} else if (wavelength <= 580) {
// Green to yellow
const t = (wavelength - 520) / (580 - 520);
x = 0.30 + 0.14 * t;
y = 0.60 - 0.15 * t;
} else if (wavelength <= 650) {
// Yellow to red
const t = (wavelength - 580) / (650 - 580);
x = 0.44 + 0.20 * t;
y = 0.45 - 0.12 * t;
} else {
// Deep red
const t = (wavelength - 650) / (780 - 650);
x = 0.64 + 0.10 * t;
y = 0.33 - 0.00 * t;
}
locus[wavelength] = { x, y, wavelength };
}
return locus;
}
// Check if coordinates are within visible gamut
isWithinVisibleGamut(x, y) {
// Check if point is inside the spectral locus and purple line
// This is a simplified check - real implementation would use precise boundary
return x >= 0 && y >= 0 && x + y <= 1 && x <= 0.8 && y <= 0.9;
}
// Find intersection of two lines
findLineIntersection(x1, y1, x2, y2, x3, y3, x4, y4) {
const denom = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
if (Math.abs(denom) < 0.0001) {
return null; // Lines are parallel
}
const t = ((x1 - x3) * (y3 - y4) - (y1 - y3) * (x3 - x4)) / denom;
return {
x: x1 + t * (x2 - x1),
y: y1 + t * (y2 - y1)
};
}
// Calculate gamut area
calculateGamutArea(gamut) {
// Using shoelace formula for triangle area
const vertices = [gamut.red, gamut.green, gamut.blue];
let area = 0;
for (let i = 0; i < vertices.length; i++) {
const j = (i + 1) % vertices.length;
area += vertices[i].x * vertices[j].y;
area -= vertices[j].x * vertices[i].y;
}
return Math.abs(area) / 2;
}
// Calculate gamut perimeter
calculateGamutPerimeter(gamut) {
const vertices = [gamut.red, gamut.green, gamut.blue, gamut.red];
let perimeter = 0;
for (let i = 0; i < vertices.length - 1; i++) {
const dx = vertices[i + 1].x - vertices[i].x;
const dy = vertices[i + 1].y - vertices[i].y;
perimeter += Math.sqrt(dx * dx + dy * dy);
}
return perimeter;
}
// Calculate gamut centroid
calculateGamutCentroid(gamut) {
return {
x: (gamut.red.x + gamut.green.x + gamut.blue.x) / 3,
y: (gamut.red.y + gamut.green.y + gamut.blue.y) / 3
};
}
}The horseshoe-shaped boundary of the chromaticity diagram represents the spectral locus - the chromaticity coordinates of monochromatic light at each wavelength from approximately 380nm to 780nm. This boundary defines the limits of all possible colors in nature.
The straight line connecting the endpoints of the spectral locus (380nm and 780nm) is called the purple line. Colors along this line cannot be produced by monochromatic light but represent mixtures of deep red and violet light.
The white point represents the chromaticity of the reference white illuminant. Different illuminants (D65, D50, A, etc.) have different white points, affecting how colors appear under different lighting conditions.
Color reproduction devices have limited gamuts that can be visualized as triangles (for RGB devices) or other shapes within the chromaticity diagram. The vertices of these triangles represent the chromaticity coordinates of the device primaries.
By overlaying different gamut boundaries on the chromaticity diagram, you can compare the color reproduction capabilities of different devices and understand which colors can or cannot be reproduced.
Colors that fall outside a device's gamut triangle cannot be accurately reproduced and require gamut mapping strategies to find the best possible representation.
For any color point in the chromaticity diagram, the dominant wavelength is found by drawing a line from the white point through the color point to the spectral locus. This represents the hue of the color.
Excitation purity is the ratio of the distance from the white point to the color point versus the distance from the white point to the spectral locus along the same line. This represents the saturation of the color.
Colors that fall on the purple line have complementary wavelengths rather than dominant wavelengths, as they cannot be matched by any single wavelength of light.
Chromaticity coordinates enable precise color specification and matching across different devices and viewing conditions by providing a standardized reference system.
The chromaticity coordinates of light sources help characterize their color rendering properties and suitability for different applications.
While not perceptually uniform, chromaticity coordinates provide the foundation for more advanced color difference calculations in perceptually uniform color spaces.
Equal distances in the chromaticity diagram do not correspond to equal perceived color differences, particularly in the green region where the diagram is compressed.
Chromaticity coordinates ignore luminance information, which is crucial for complete color specification and appearance prediction.
Individual differences in color vision can affect the perceived relationships between colors, even when their chromaticity coordinates are identical.
Modern display technologies use chromaticity coordinates to specify color gamuts and ensure consistent color reproduction across different devices and manufacturers.
ICC profiles and color management systems rely on chromaticity coordinates to define device color spaces and perform accurate color conversions.
Industrial color quality control systems use chromaticity coordinates to establish color tolerances and monitor color consistency in manufacturing processes.
Explore these comprehensive pillar articles related to Chromaticity Coordinates
A comprehensive guide to color theory, its fundamental principles, and practical applications in digital design and web development.
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.
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.
Discover more about Chromaticity Coordinates 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 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.
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 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