1. CIE Color Functions
The CIE tristimulus values, X,Y,Z and chromaticity values, x,y, are defined as data types in the the ImagerColor interface. This package provides a way to convert these value to other CIE defined systems.
The CIE lightness function, L* = F[Y], is a fairly close match for the Munsel Value function for luminance > 1%. There is a formula for luminance < 1%, but its use is somewhat controversial. Note that such colors are quite dark. The lightness is not an absolute function, but is defined relative to a standard white.
LStarFromLuminance:
PROC [Y:
REAL, whiteY:
REAL]
RETURNS[lStar:
REAL];
L* = 116(Y/Yn)1/3 - 16 Y/Yn > 0.008856
L* = 903.29(Y/Yn) Y/Yn <= 0.008856
LuminanceFromLStar: PROC [lStar: REAL, whiteY: REAL] RETURNS[Y: REAL];
The CIE chromaticity diagram is not perceptually very uniform. That is, distances in the diagram do not corespond to perceptual difference. For example, a two blue colors that look similar will be closer together on the diagram than two green colors that look similar by the same amount. The Metric Chromaticity diagram is a transformation of the chromaticity diagram that is supposed to be more uniform. The metric chromaticity can be computed from either the tristimulus values or the chromaticity values.
MetricChrFromChr:
PROC[xy: CIEChromaticity]
RETURNS[uv: MetricChromaticity];
u' = 4x/(-2x+12y+3) v' = 9y/(-2x+12y+3)
ChrFromMetricChr:
PROC[uv: MetricChromaticity]
RETURNS[xy: CIEChromaticity];
x = 27u'/(18u'-48v'+36) y = 12v'/(18u'-48v'+36)
MetricChrFromXYZ:
PROC[xyz:
CIE]
RETURNS[uv: MetricChromaticity];
u' = 4X/(X+15Y+3Z) v' = 9Y/(X+15Y+3Z)
In 1976, the CIE standardized two systems for measuring color difference. Both were based on existing systems, both were judged to work equally well, and neither are perfect. The CIELAB system was derived from the ANLAB system, which was in common use for colorants in paints, plastic and textiles. CIELUV is related to the metric chromaticity diagram (and I'm not sure what else).
CIELABFromXYZ: PROC [xyz: CIE, white: CIE] RETURNS[lab: CIELAB];
XYZFromCIELAB:
PROC [lab:
CIELAB, white:
CIE]
RETURNS[xyz:
CIE];
The equations for CIELAB are:
a* = 500[(X/Xn)1/3 - (Y/Yn)1/3]
b* = 200[(Z/Zn)1/3 - (Y/Yn)1/3]
where Xn, Yn, Zn are the tristimulus values of the reference white. For values of X/Xn, Y/Yn, or Z/Zn less than 0.008856 use ??
CIELUVFromXYZ: PROC [xyz: CIE, white: CIE] RETURNS[luv: CIELUV];
XYZFromCIELUV:
PROC [luv:
CIELUV, white:
CIE]
RETURNS[xyz:
CIE];
The equations for CIELUV are:
u* = 13L*(u'-un')
v* = 13L*(v'-vn')
where u' and un' are the Metric Chromaticiy coordinates of the value and the reference white
In CIELAB or CIELUV, the perceptual difference between two colors is approximately the euclidian distance between the two points in the color space. One unit equals a "noticeable" color difference. Both use the same function for lightness, L*, defined above, with the same caveat for very dark colors. Both are defined relative to a "reference white". These formulas are intended for colors that are close to one another. Don't get too hung up on the numbers here—some sources claim that only one digit is significan.
DifferenceCIELAB: PROC [color1, color2: CIELAB] RETURNS [difference: REAL];
DifferenceCIELUV: PROC [color1, color2: CIELUV] RETURNS [difference: REAL];