ColorModels.mesa - Conversion routines between color models
Copyright © 1984 by Xerox Corporation. All rights reserved.
-- Last edited by Maureen Stone, February 10, 1984 4:18:42 pm PST
-- Last Edited by: Pier, January 18, 1984 12:54 pm
-- Last edited by Frank Crow, April 16, 1984 3:23:27 pm PST
ColorModels: CEDAR DEFINITIONS = {
The following four procedures convert between (hue, saturation, value) or (hue, saturation, lightness) and (red, green, blue).
All values should be in the range [0..1] except when undefined
undefined values:
RGB: None
HSV: If s=0 then h is undefined (color is a gray depending on v)
If v=0 then h and s are undefined (color is black)
HSL: If s=0 then h is undefined (color is a gray depending on l).
If l=1 then h is undefined and s=0 (color is white)
If l=0 then h is undefined and s=0 (color is black)
InvalidColor, Uninitialized: SIGNAL;
undefined: REAL = -1;
HSVToRGB: PROC[h, s, v: REAL] RETURNS[r, g, b: REAL];
RGBToHSV: PROC[r, g, b: REAL] RETURNS[h, s, v: REAL];
--HSV hexacone model.
HSLToRGB: PROC[h, s, l: REAL] RETURNS[r, g, b: REAL];
RGBToHSL: PROC[r, g, b: REAL] RETURNS[h, s, l: REAL];
HSL double hexacone model.
The following procedures convert between (red, green, blue) and (x,y) chromaticity coordinates.
Initialize the transform with x,y for red, green blue plus range for Y.
CIEToRGB and RGBToCIE will signal Uninitialized if InitCIE has not been called
These values are not guarenteed to stay in the range [0..1] unless the following is true:
whiteY is set to 1.0
For CIEToRGB, Y <= GetMaxY[x,y]
Real0: TYPE = REAL ← 0;
Matrix3: TYPE = ARRAY [0..3) OF Row3;
Row3: TYPE = ARRAY [0..3) OF Real0;
Column3: TYPE = ARRAY [0..3) OF Real0;
Calibration: TYPE = REF CalibrationRec;
CalibrationRec: TYPE=RECORD [
toCIE: Matrix3, --rgb to cie matrix
toRGB: Matrix3, --cie to rgb matrix
yScale: REAL
];
InitCIE: PROC[xr,yr,xg,yg,xb,yb: REAL, whiteY: REAL ← 1.0] RETURNS [calibration: Calibration];
whiteY is the maximum range for Y. Traditionally 100, 1.0 is more compatible with the rest of the models here. This model is suitable for cie coordinates from a monitor and is relative to the monitor's white point. We need to define the (x,y) value for white to get absolute cie. In other words, if the white point of the monitor matches the CIE standard illuminant, this is enough. Otherwise we need to compensate that.
PhosphorType: TYPE = ATOM;  -- $ConracLP, $HitachiLP, etc.
GetPhosphorCalibration: PROC[type: PhosphorType ← $DefaultLP] RETURNS [calibration: Calibration];
RegisterPhosphorCalibration: PROC[xr,yr,xg,yg,xb,yb: REAL, type: PhosphorType];
GetDefaultValues: PROC[type: PhosphorType] RETURNS[xr,yr,xg,yg,xb,yb: REAL];
SetDefaultValues: PROC[xr,yr,xg,yg,xb,yb: REAL, type: PhosphorType];
CIEToRGB: PROC[x,y, Y: REAL, calibration: Calibration] RETURNS[r, g, b: REAL];
may return a value outside of monitor's gamut
GetMaxY: PUBLIC PROC[x,y: REAL, calibration: Calibration] RETURNS[Y: REAL];
For CIEToRGB, if Y <= GetMaxY[x,y], then the color is inside the monitors gamut.
RGBToCIE: PROC[r, g, b: REAL, calibration: Calibration] RETURNS [x,y, Y: REAL];
}.