A comprehensive guide to chromatic adaptation - the process of adjusting colors when viewing conditions change, essential for accurate color reproduction across different illuminants and critical for color management systems and display calibration.
Chromatic adaptation is the visual system's ability to adjust to changes in illumination in order to preserve the appearance of object colors. In color science and digital imaging, chromatic adaptation transforms refer to mathematical models that predict how colors appear under different illuminants, enabling accurate color reproduction across varying lighting conditions.
Human vision automatically adapts to different lighting conditions through several mechanisms including pupil adjustment, photoreceptor adaptation, and neural processing. This allows us to perceive a white sheet of paper as white whether viewed under daylight, tungsten light, or fluorescent illumination.
// Comprehensive chromatic adaptation implementation
class ChromaticAdaptation {
constructor() {
// Standard illuminants with XYZ white points
this.illuminants = {
'A': { X: 109.850, Y: 100.000, Z: 35.585, name: 'Tungsten 2856K' },
'B': { X: 99.072, Y: 100.000, Z: 85.223, name: 'Daylight 4874K' },
'C': { X: 98.074, Y: 100.000, Z: 118.232, name: 'Daylight 6774K' },
'D50': { X: 96.422, Y: 100.000, Z: 82.521, name: 'Daylight 5003K' },
'D55': { X: 95.682, Y: 100.000, Z: 92.149, name: 'Daylight 5503K' },
'D65': { X: 95.047, Y: 100.000, Z: 108.883, name: 'Daylight 6504K' },
'D75': { X: 94.972, Y: 100.000, Z: 122.638, name: 'Daylight 7504K' },
'E': { X: 100.000, Y: 100.000, Z: 100.000, name: 'Equal Energy' },
'F2': { X: 99.187, Y: 100.000, Z: 67.395, name: 'Fluorescent 4230K' },
'F7': { X: 95.044, Y: 100.000, Z: 108.755, name: 'Fluorescent 6500K' },
'F11': { X: 100.966, Y: 100.000, Z: 64.370, name: 'Fluorescent 4000K' }
};
// Bradford transformation matrix (most accurate)
this.bradfordMatrix = {
forward: [
[0.8951000, 0.2664000, -0.1614000],
[-0.7502000, 1.7135000, 0.0367000],
[0.0389000, -0.0685000, 1.0296000]
],
inverse: [
[0.9869929, -0.1470543, 0.1599627],
[0.4323053, 0.5183603, 0.0492912],
[-0.0085287, 0.0400428, 0.9684867]
]
};
// Von Kries transformation matrix
this.vonKriesMatrix = {
forward: [
[0.4002400, 0.7076000, -0.0808100],
[-0.2280800, 1.1500000, 0.0612400],
[0.0000000, 0.0000000, 0.9184000]
],
inverse: [
[1.8599364, -1.1293816, 0.2198974],
[0.3611914, 0.6388125, -0.0000064],
[0.0000000, 0.0000000, 1.0888251]
]
};
// CAT02 transformation matrix (CIECAM02)
this.cat02Matrix = {
forward: [
[0.7328000, 0.4296000, -0.1624000],
[-0.7036000, 1.6975000, 0.0061000],
[0.0030000, 0.0136000, 0.9834000]
],
inverse: [
[1.0961238, -0.2788690, 0.1827452],
[0.4543690, 0.4735332, 0.0720978],
[-0.0096276, -0.0056980, 1.0153256]
]
};
}
// Perform chromatic adaptation using specified method
adaptColor(xyz, sourceIlluminant, targetIlluminant, method = 'Bradford') {
const sourceWP = this.illuminants[sourceIlluminant];
const targetWP = this.illuminants[targetIlluminant];
if (!sourceWP || !targetWP) {
throw new Error('Unknown illuminant specified');
}
if (sourceIlluminant === targetIlluminant) {
return { ...xyz, adapted: false, method: 'none' };
}
switch (method.toLowerCase()) {
case 'bradford':
return this.bradfordAdaptation(xyz, sourceWP, targetWP);
case 'vonkries':
case 'von kries':
return this.vonKriesAdaptation(xyz, sourceWP, targetWP);
case 'cat02':
return this.cat02Adaptation(xyz, sourceWP, targetWP);
case 'xyzscaling':
case 'xyz scaling':
return this.xyzScalingAdaptation(xyz, sourceWP, targetWP);
default:
return this.bradfordAdaptation(xyz, sourceWP, targetWP);
}
}
// Bradford chromatic adaptation (recommended)
bradfordAdaptation(xyz, sourceWP, targetWP) {
// Convert white points to Bradford cone response domain
const sourceRGB = this.matrixMultiply(this.bradfordMatrix.forward, [sourceWP.X, sourceWP.Y, sourceWP.Z]);
const targetRGB = this.matrixMultiply(this.bradfordMatrix.forward, [targetWP.X, targetWP.Y, targetWP.Z]);
// Calculate adaptation gains
const adaptationMatrix = [
[targetRGB[0] / sourceRGB[0], 0, 0],
[0, targetRGB[1] / sourceRGB[1], 0],
[0, 0, targetRGB[2] / sourceRGB[2]]
];
// Transform color to Bradford space
const colorRGB = this.matrixMultiply(this.bradfordMatrix.forward, [xyz.X, xyz.Y, xyz.Z]);
// Apply adaptation
const adaptedRGB = this.matrixMultiply(adaptationMatrix, colorRGB);
// Transform back to XYZ
const adaptedXYZ = this.matrixMultiply(this.bradfordMatrix.inverse, adaptedRGB);
return {
X: Math.max(0, adaptedXYZ[0]),
Y: Math.max(0, adaptedXYZ[1]),
Z: Math.max(0, adaptedXYZ[2]),
adapted: true,
method: 'Bradford',
sourceIlluminant: sourceWP.name,
targetIlluminant: targetWP.name
};
}
// Von Kries chromatic adaptation
vonKriesAdaptation(xyz, sourceWP, targetWP) {
const sourceRGB = this.matrixMultiply(this.vonKriesMatrix.forward, [sourceWP.X, sourceWP.Y, sourceWP.Z]);
const targetRGB = this.matrixMultiply(this.vonKriesMatrix.forward, [targetWP.X, targetWP.Y, targetWP.Z]);
const adaptationMatrix = [
[targetRGB[0] / sourceRGB[0], 0, 0],
[0, targetRGB[1] / sourceRGB[1], 0],
[0, 0, targetRGB[2] / sourceRGB[2]]
];
const colorRGB = this.matrixMultiply(this.vonKriesMatrix.forward, [xyz.X, xyz.Y, xyz.Z]);
const adaptedRGB = this.matrixMultiply(adaptationMatrix, colorRGB);
const adaptedXYZ = this.matrixMultiply(this.vonKriesMatrix.inverse, adaptedRGB);
return {
X: Math.max(0, adaptedXYZ[0]),
Y: Math.max(0, adaptedXYZ[1]),
Z: Math.max(0, adaptedXYZ[2]),
adapted: true,
method: 'Von Kries'
};
}
// CAT02 chromatic adaptation (CIECAM02)
cat02Adaptation(xyz, sourceWP, targetWP) {
const sourceRGB = this.matrixMultiply(this.cat02Matrix.forward, [sourceWP.X, sourceWP.Y, sourceWP.Z]);
const targetRGB = this.matrixMultiply(this.cat02Matrix.forward, [targetWP.X, targetWP.Y, targetWP.Z]);
const adaptationMatrix = [
[targetRGB[0] / sourceRGB[0], 0, 0],
[0, targetRGB[1] / sourceRGB[1], 0],
[0, 0, targetRGB[2] / sourceRGB[2]]
];
const colorRGB = this.matrixMultiply(this.cat02Matrix.forward, [xyz.X, xyz.Y, xyz.Z]);
const adaptedRGB = this.matrixMultiply(adaptationMatrix, colorRGB);
const adaptedXYZ = this.matrixMultiply(this.cat02Matrix.inverse, adaptedRGB);
return {
X: Math.max(0, adaptedXYZ[0]),
Y: Math.max(0, adaptedXYZ[1]),
Z: Math.max(0, adaptedXYZ[2]),
adapted: true,
method: 'CAT02'
};
}
// Simple XYZ scaling adaptation (least accurate)
xyzScalingAdaptation(xyz, sourceWP, targetWP) {
return {
X: xyz.X * (targetWP.X / sourceWP.X),
Y: xyz.Y * (targetWP.Y / sourceWP.Y),
Z: xyz.Z * (targetWP.Z / sourceWP.Z),
adapted: true,
method: 'XYZ Scaling'
};
}
// Calculate degree of adaptation
calculateAdaptationDegree(viewingConditions) {
const {
luminance = 20, // cd/m²
surroundType = 'average', // dim, average, dark
backgroundLuminance = 20
} = viewingConditions;
// CIECAM02 adaptation degree calculation
let F = 1.0; // Surround factor
switch (surroundType.toLowerCase()) {
case 'dim':
F = 0.9;
break;
case 'dark':
F = 0.8;
break;
case 'average':
default:
F = 1.0;
break;
}
// Calculate adaptation factor based on luminance
const LA = luminance / 5; // Adapting luminance
const D = F * (1 - (1/3.6) * Math.exp((-LA - 42) / 92));
return {
degree: Math.max(0, Math.min(1, D)),
surround: surroundType,
luminance: luminance,
description: D > 0.9 ? 'Complete adaptation' :
D > 0.7 ? 'High adaptation' :
D > 0.5 ? 'Moderate adaptation' :
D > 0.3 ? 'Low adaptation' : 'Minimal adaptation'
};
}
// Partial chromatic adaptation
partialAdaptation(xyz, sourceIlluminant, targetIlluminant, degree = 1.0, method = 'Bradford') {
if (degree === 0) {
return { ...xyz, adapted: false };
}
if (degree === 1) {
return this.adaptColor(xyz, sourceIlluminant, targetIlluminant, method);
}
// Interpolate between original and fully adapted colors
const fullyAdapted = this.adaptColor(xyz, sourceIlluminant, targetIlluminant, method);
return {
X: xyz.X + degree * (fullyAdapted.X - xyz.X),
Y: xyz.Y + degree * (fullyAdapted.Y - xyz.Y),
Z: xyz.Z + degree * (fullyAdapted.Z - xyz.Z),
adapted: true,
degree: degree,
method: method + ' (partial)'
};
}
// Compare adaptation methods
compareAdaptationMethods(xyz, sourceIlluminant, targetIlluminant) {
const methods = ['Bradford', 'Von Kries', 'CAT02', 'XYZ Scaling'];
const results = {};
methods.forEach(method => {
try {
results[method] = this.adaptColor(xyz, sourceIlluminant, targetIlluminant, method);
} catch (error) {
results[method] = { error: error.message };
}
});
return {
original: xyz,
sourceIlluminant,
targetIlluminant,
adaptations: results,
recommendation: 'Bradford method is generally most accurate'
};
}
// Calculate color appearance under different illuminants
colorAppearanceAnalysis(xyz, illuminants = ['A', 'D50', 'D65', 'F2']) {
const baseIlluminant = 'D65';
const appearances = {};
illuminants.forEach(illuminant => {
if (illuminant === baseIlluminant) {
appearances[illuminant] = {
...xyz,
illuminant: this.illuminants[illuminant].name,
adapted: false
};
} else {
appearances[illuminant] = {
...this.adaptColor(xyz, baseIlluminant, illuminant),
illuminant: this.illuminants[illuminant].name
};
}
});
return {
baseColor: xyz,
baseIlluminant: this.illuminants[baseIlluminant].name,
appearances: appearances,
analysis: this.analyzeAppearanceChanges(appearances)
};
}
// Analyze appearance changes across illuminants
analyzeAppearanceChanges(appearances) {
const illuminantKeys = Object.keys(appearances);
const changes = [];
for (let i = 0; i < illuminantKeys.length; i++) {
for (let j = i + 1; j < illuminantKeys.length; j++) {
const illum1 = illuminantKeys[i];
const illum2 = illuminantKeys[j];
const color1 = appearances[illum1];
const color2 = appearances[illum2];
const deltaE = this.calculateDeltaE(color1, color2);
changes.push({
from: illum1,
to: illum2,
deltaE: deltaE,
significance: deltaE < 1 ? 'Imperceptible' :
deltaE < 2 ? 'Just noticeable' :
deltaE < 5 ? 'Noticeable' :
deltaE < 10 ? 'Significant' : 'Very significant'
});
}
}
return changes.sort((a, b) => b.deltaE - a.deltaE);
}
// Calculate Delta E between two XYZ colors
calculateDeltaE(xyz1, xyz2) {
// Convert to LAB for Delta E calculation
const lab1 = this.xyzToLab(xyz1.X, xyz1.Y, xyz1.Z);
const lab2 = this.xyzToLab(xyz2.X, xyz2.Y, xyz2.Z);
// CIE76 Delta E formula
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);
}
// Convert XYZ to LAB (simplified)
xyzToLab(X, Y, Z, illuminant = 'D65') {
const wp = this.illuminants[illuminant];
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)))
};
}
// LAB transformation function
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);
}
}
// Matrix multiplication utility
matrixMultiply(matrix, vector) {
const result = [];
for (let i = 0; i < matrix.length; i++) {
let sum = 0;
for (let j = 0; j < vector.length; j++) {
sum += matrix[i][j] * vector[j];
}
result.push(sum);
}
return result;
}
// Get illuminant information
getIlluminantInfo(illuminant) {
const info = this.illuminants[illuminant];
if (!info) {
throw new Error(`Unknown illuminant: ${illuminant}`);
}
return {
...info,
chromaticity: this.xyzToChromaticity(info.X, info.Y, info.Z),
category: this.categorizeIlluminant(illuminant)
};
}
// Convert XYZ to chromaticity coordinates
xyzToChromaticity(X, Y, Z) {
const sum = X + Y + Z;
if (sum === 0) return { x: 0, y: 0 };
return {
x: X / sum,
y: Y / sum
};
}
// Categorize illuminant type
categorizeIlluminant(illuminant) {
if (illuminant === 'A') return 'Tungsten incandescent';
if (illuminant.startsWith('D')) return 'Daylight';
if (illuminant.startsWith('F')) return 'Fluorescent';
if (illuminant === 'E') return 'Equal energy';
return 'Other';
}
}The Bradford chromatic adaptation transform is currently the most accurate method for predicting color appearance under different illuminants. It uses a transformation matrix that closely matches the spectral sensitivities of human cone cells.
The Von Kries adaptation model assumes that chromatic adaptation occurs independently in each type of cone cell. While simpler than Bradford, it's less accurate for large illuminant changes.
Part of the CIECAM02 color appearance model, CAT02 provides good accuracy and is used in advanced color management applications that require appearance modeling.
Successful chromatic adaptation requires consideration of viewing conditions including ambient lighting, surround brightness, and adaptation state of the observer.
Real-world adaptation is often incomplete. Partial adaptation models account for the fact that observers may not fully adapt to new illuminants, especially in mixed lighting conditions.
Chromatic adaptation transforms enable accurate color difference calculations by ensuring colors are evaluated under the same reference illuminant.
Explore these comprehensive pillar articles related to Chromatic Adaptation
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 Chromatic Adaptation 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