CAM16-UCS (Uniform Color Space) - a perceptually uniform version of CIECAM16.
CAM16-UCS provides better perceptual uniformity for color difference calculations
and is recommended for applications requiring accurate color distance metrics.
The UCS (Uniform Color Space) transformation makes Euclidean distances in the space
correspond more closely to perceived color differences.
- Source:
- See:
-
- https://doi.org/10.1002/col.22131 - Original CAM16-UCS paper
- https://observablehq.com/@jrus/cam16 - Interactive CAM16 explanation
Methods
(static) calculateCam16UcsDifference(srgb1, srgb2, viewingConditionsopt) → {number}
Calculate color difference between two sRGB colors using CAM16-UCS
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
srgb1 |
SrgbColor | First sRGB color | |
srgb2 |
SrgbColor | Second sRGB color | |
viewingConditions |
Ciecam16ViewingConditions |
<optional> |
Viewing conditions |
- Source:
Returns:
Perceptual color difference
- Type
- number
(static) cam16ToUcs(cam16) → {Cam16UcsColor}
Convert CIECAM16 appearance correlates to CAM16-UCS coordinates
Parameters:
Name | Type | Description |
---|---|---|
cam16 |
Ciecam16Appearance | CIECAM16 appearance values |
- Source:
Returns:
CAM16-UCS rectangular coordinates
- Type
- Cam16UcsColor
(static) cam16UcsColorDifference(color1, color2) → {number}
Calculate the color difference between two colors in CAM16-UCS space
This provides a perceptually uniform color difference metric
Parameters:
Name | Type | Description |
---|---|---|
color1 |
Cam16UcsColor | First color in CAM16-UCS |
color2 |
Cam16UcsColor | Second color in CAM16-UCS |
- Source:
Returns:
Euclidean distance in CAM16-UCS space
- Type
- number
(static) cam16UcsToSrgb(ucsColor, viewingConditionsopt) → {SrgbColor|null}
Convert CAM16-UCS to sRGB
Note: This requires reverse engineering through CIECAM16 which is complex
and may not always have an exact solution
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
ucsColor |
Cam16UcsColor | CAM16-UCS coordinates | |
viewingConditions |
Ciecam16ViewingConditions |
<optional> |
Viewing conditions |
- Source:
Returns:
sRGB color or null if conversion fails
- Type
- SrgbColor | null
(static) findComplementaryCam16Ucs(color) → {Cam16UcsColor}
Find complementary color in CAM16-UCS space
Parameters:
Name | Type | Description |
---|---|---|
color |
Cam16UcsColor | Input color |
- Source:
Returns:
Complementary color
- Type
- Cam16UcsColor
(static) generateAnalogousCam16Ucs(color, angleopt, countopt) → {Array.<Cam16UcsColor>}
Generate analogous colors in CAM16-UCS space
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
color |
Cam16UcsColor | Base color | ||
angle |
number |
<optional> |
30 | Angle between colors |
count |
number |
<optional> |
2 | Number of analogous colors per side |
- Source:
Returns:
Array of analogous colors
- Type
- Array.<Cam16UcsColor>
(static) generateCam16UcsGradient(startColor, endColor, steps, viewingConditionsopt) → {Array.<SrgbColor>}
Generate a perceptually uniform gradient in CAM16-UCS space
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
startColor |
SrgbColor | Start color | |
endColor |
SrgbColor | End color | |
steps |
number | Number of steps | |
viewingConditions |
Ciecam16ViewingConditions |
<optional> |
Viewing conditions |
- Source:
Returns:
Array of gradient colors
- Type
- Array.<SrgbColor>
(static) generateTriadicCam16Ucs(color) → {Array.<Cam16UcsColor>}
Generate triadic colors in CAM16-UCS space
Parameters:
Name | Type | Description |
---|---|---|
color |
Cam16UcsColor | Base color |
- Source:
Returns:
Array of triadic colors
- Type
- Array.<Cam16UcsColor>
(static) interpolateCam16Ucs(color1, color2, t) → {Cam16UcsColor}
Interpolate between two colors in CAM16-UCS space
Parameters:
Name | Type | Description |
---|---|---|
color1 |
Cam16UcsColor | Start color |
color2 |
Cam16UcsColor | End color |
t |
number | Interpolation factor (0-1) |
- Source:
Returns:
Interpolated color
- Type
- Cam16UcsColor
(static) interpolateCam16UcsPolar(color1, color2, t) → {Cam16UcsPolarColor}
Interpolate in polar coordinates (better for hue preservation)
Parameters:
Name | Type | Description |
---|---|---|
color1 |
Cam16UcsPolarColor | Start color (polar) |
color2 |
Cam16UcsPolarColor | End color (polar) |
t |
number | Interpolation factor (0-1) |
- Source:
Returns:
Interpolated color (polar)
- Type
- Cam16UcsPolarColor
(static) polarToUcs(polar) → {Cam16UcsColor}
Convert CAM16-UCS polar to rectangular coordinates
Parameters:
Name | Type | Description |
---|---|---|
polar |
Cam16UcsPolarColor | CAM16-UCS polar coordinates |
- Source:
Returns:
CAM16-UCS rectangular coordinates
- Type
- Cam16UcsColor
(static) srgbToCam16Ucs(srgbColor, viewingConditionsopt) → {Cam16UcsColor}
Convert sRGB to CAM16-UCS
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
srgbColor |
SrgbColor | sRGB color | |
viewingConditions |
Ciecam16ViewingConditions |
<optional> |
Viewing conditions |
- Source:
Returns:
CAM16-UCS coordinates
- Type
- Cam16UcsColor
Example
const ucs = srgbToCam16Ucs({ r: 0.5, g: 0.7, b: 0.3 });
// Returns: { J: 67.2, a: -15.3, b: 28.1 }
(static) ucsToCam16(ucs) → {Ciecam16Appearance}
Convert CAM16-UCS coordinates back to CIECAM16 appearance
Parameters:
Name | Type | Description |
---|---|---|
ucs |
Cam16UcsColor | CAM16-UCS coordinates |
- Source:
Returns:
CIECAM16 appearance values
- Type
- Ciecam16Appearance
(static) ucsToPolar(ucs) → {Cam16UcsPolarColor}
Convert CAM16-UCS rectangular to polar coordinates
Parameters:
Name | Type | Description |
---|---|---|
ucs |
Cam16UcsColor | CAM16-UCS rectangular coordinates |
- Source:
Returns:
CAM16-UCS polar coordinates
- Type
- Cam16UcsPolarColor
Type Definitions
Cam16UcsColor
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
J |
number | Lightness (0-100) |
a |
number | Red-green component |
b |
number | Yellow-blue component |
- Source:
Cam16UcsPolarColor
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
J |
number | Lightness (0-100) |
C |
number | Chroma |
h |
number | Hue angle in degrees |
- Source: