Chromatic adaptation transforms for converting colors between different illuminants.
Implements Bradford, CAT02, CAT16, and other chromatic adaptation transforms.
Chromatic adaptation is the human visual system's ability to adjust to changes in illumination
in order to preserve the appearance of object colors.
Members
(static, constant) ILLUMINANTS :Object.<string, WhitePoint>
Standard CIE illuminants (normalized to Y=100)
Type:
- Object.<string, WhitePoint>
- Source:
(inner, constant) ADAPTATION_MATRICES :Object
Supported chromatic adaptation methods
Type:
- Object
- Source:
Methods
(static) calculateCCT(whitePoint) → {number}
Calculate the correlated color temperature (CCT) of a white point
Uses McCamy's approximation
Parameters:
Name | Type | Description |
---|---|---|
whitePoint |
WhitePoint | White point in XYZ |
- Source:
Returns:
CCT in Kelvin
- Type
- number
(static) chromaticAdaptation(xyzColor, sourceWhite, destWhite, methodopt) → {XyzColor}
Apply chromatic adaptation transform to convert XYZ color from one illuminant to another
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
xyzColor |
XyzColor | Input XYZ color under source illuminant | ||
sourceWhite |
WhitePoint | string | Source illuminant (white point or name) | ||
destWhite |
WhitePoint | string | Destination illuminant (white point or name) | ||
method |
string |
<optional> |
'bradford' | Adaptation method ('bradford', 'cat02', 'cat16', 'vonKries') |
- Source:
Returns:
XYZ color adapted to destination illuminant
- Type
- XyzColor
Example
// Convert XYZ from D65 to D50
const xyzD50 = chromaticAdaptation(xyzD65, 'D65', 'D50');
(static) findClosestIlluminant(whitePoint) → {string}
Determine the closest standard illuminant to a white point
Parameters:
Name | Type | Description |
---|---|---|
whitePoint |
WhitePoint | White point to match |
- Source:
Returns:
Name of closest standard illuminant
- Type
- string
(static) getWhitePointFromTemperature(temperature) → {WhitePoint}
Get a white point for a given color temperature
Approximation using Planckian locus
Parameters:
Name | Type | Description |
---|---|---|
temperature |
number | Color temperature in Kelvin |
- Source:
Returns:
Approximate white point
- Type
- WhitePoint
(static) needsChromaticAdaptation(white1, white2, thresholdopt) → {boolean}
Check if chromatic adaptation is needed between two white points
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
white1 |
WhitePoint | string | First white point | ||
white2 |
WhitePoint | string | Second white point | ||
threshold |
number |
<optional> |
0.001 | Difference threshold |
- Source:
Returns:
True if adaptation is needed
- Type
- boolean
(static) xyzD50ToD65(xyzD50, methodopt) → {XyzColor}
Convert XYZ color from D50 to D65 illuminant
Common conversion for display work
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
xyzD50 |
XyzColor | XYZ color under D50 | ||
method |
string |
<optional> |
'bradford' | Adaptation method |
- Source:
Returns:
XYZ color under D65
- Type
- XyzColor
(static) xyzD65ToD50(xyzD65, methodopt) → {XyzColor}
Convert XYZ color from D65 to D50 illuminant
Common conversion for ICC profiles and print work
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
xyzD65 |
XyzColor | XYZ color under D65 | ||
method |
string |
<optional> |
'bradford' | Adaptation method |
- Source:
Returns:
XYZ color under D50
- Type
- XyzColor
Type Definitions
WhitePoint
Type:
- Object
- Source:
XyzColor
Type:
- Object
- Source: