DIRECTORY ImagerColorDefs USING [Color, ColorOperator, ConstantColor, SampledColor], ImagerPixelArrayDefs USING [PixelArray], ImagerTransformation USING [Transformation], Rope USING [ROPE]; ImagerColor: CEDAR DEFINITIONS ~ BEGIN Color: TYPE ~ ImagerColorDefs.Color; ConstantColor: TYPE ~ ImagerColorDefs.ConstantColor; SampledColor: TYPE ~ ImagerColorDefs.SampledColor; ColorOperator: TYPE ~ ImagerColorDefs.ColorOperator; PixelArray: TYPE ~ ImagerPixelArrayDefs.PixelArray; Transformation: TYPE ~ ImagerTransformation.Transformation; ROPE: TYPE ~ Rope.ROPE; CIE: TYPE ~ RECORD [X, Y, Z: REAL]; CIEChromaticity: TYPE ~ RECORD [x, y: REAL]; illuminantC: CIEChromaticity ~ [x: 0.310, y: 0.317]; ChromaticityFromCIE: PROC [CIE] RETURNS [CIEChromaticity]; CIEFromChromaticity: PROC [c: CIEChromaticity, Y: REAL] RETURNS [CIE]; RGBCalibration: TYPE ~ REF RGBCalibrationRep; RGBCalibrationRep: TYPE ~ RECORD [ type: ATOM, -- identifying name red: CIEChromaticity, -- CIE chromaticity of red phosphor green: CIEChromaticity, -- CIE chromaticity of green phosphor blue: CIEChromaticity, -- CIE chromaticity of blue phosphor white: CIEChromaticity, -- CIE chromaticity of white (RGB[1, 1, 1]) YMax: REAL, -- maximum luminance, typically 100 impl: REF RGBCalibrationImplRep -- implementation data (matrices relating RGB and XYZ) ]; RGBCalibrationImplRep: TYPE; GetDefaultCalibration: PROC RETURNS [RGBCalibration]; CreateCalibration: PROC [type: ATOM, red, green, blue: CIEChromaticity, white: CIEChromaticity, YMax: REAL _ 100] RETURNS [RGBCalibration]; RGB: TYPE ~ RECORD [R, G, B: REAL]; CIEFromRGB: PROC [rgb: RGB, calibration: RGBCalibration _ NIL] RETURNS [CIE]; RGBFromCIE: PROC [cie: CIE, calibration: RGBCalibration _ NIL] RETURNS [RGB]; RGBMaxY: PROC [c: CIEChromaticity, calibration: RGBCalibration _ NIL] RETURNS [Y: REAL]; YIQ: TYPE ~ RECORD [Y, I, Q: REAL]; YIQFromRGB: PROC [RGB] RETURNS [YIQ]; RGBFromYIQ: PROC [YIQ] RETURNS [RGB]; HSV: TYPE ~ RECORD [H, S, V: REAL]; HSVFromRGB: PROC [RGB] RETURNS [HSV]; RGBFromHSV: PROC [HSV] RETURNS [RGB]; HSL: TYPE ~ RECORD [H, S, L: REAL]; HSLFromRGB: PROC [RGB] RETURNS [HSL]; RGBFromHSL: PROC [HSL] RETURNS [RGB]; Find: PROC [name: ROPE] RETURNS [ConstantColor]; ColorFromAtom: PROC [atom: ATOM] RETURNS [ConstantColor]; ColorFromGray: PROC [f: REAL] RETURNS [ConstantColor]; ColorFromRGB: PROC [rgb: RGB, calibration: RGBCalibration _ NIL] RETURNS [ConstantColor]; ColorFromCIE: PROC [cie: CIE] RETURNS [ConstantColor]; GrayFromColor: PROC [color: ConstantColor] RETURNS [REAL]; AtomFromColor: PROC [color: ConstantColor] RETURNS [ATOM]; MakeSampledBlack: PROC [pa: PixelArray, um: Transformation, clear: BOOL _ FALSE] RETURNS [SampledColor]; MakeSampledColor: PROC [pa: PixelArray, um: Transformation, colorOperator: ColorOperator] RETURNS [SampledColor]; END. <ImagerColor.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Doug Wyatt, May 12, 1985 3:55:28 pm PDT Color Models CIE tristimulus values; by convention, X, Y, and Z range from 0 to about 100. Corresponding chromaticity coordinates are x = X/(X+Y+Z) y = Y/(X+Y+Z) z = Z/(X+Y+Z) CIE chromaticity; x and y are IN[0..1]. On the CIE chromaticity diagram, all points that correspond to physically realizable colors lie within the horseshoe-shaped spectrum locus. Chromaticity of CIE standard illuminant C (daylight). Derives [x, y] from [X, Y, Z]. Derives [X, Y, Z] from [x, y, Y]. An RGBCalibration specifies the relationship between RGB and CIE for a given device. Returns a "reasonable" calibration for a typical color monitor. Creates a new RGB calibration. Red, green, and blue, as for a color monitor or scanner; R, G, and B range from 0 to 1. Converts RGB to CIE; if calibration=NIL, uses the default calibration. Converts CIE to RGB; if calibration=NIL, uses the default calibration. May return values outside [0..1] if the color is outside the device's gamut. For the given CIE chromaticity, returns the maximum Y attainable with RGB. [x, y, Y] is inside the device's gamut iff Y<=RGBMaxY[[x, y], calibration]. YIQ is the scheme used for color television; see Foley and van Dam, section 17.4.3. Y, I, and Q range from 0 to 1; Y is luminance, roughly corresponding to CIE.Y/100. Y = .30*R+.59*G+.11*B I = .60*R-.28*G-.32*B Q = .21*R-.52*G+.31*B Conversion between RGB and YIQ. Hue, Saturation, Value; H, S, and V range from 0 to 1. If V=0 (black), H and S are irrelevant. If S=0 (achromatic), H is irrelevant. The HSV space is a hexcone; see Foley and van Dam, section 17.4.4. Conversion between RGB and HSV. Hue, Saturation, Lightness; H, S, and L range from 0 to 1. If L=0 (black) or L=1 (white), H and S are irrelevant. If S=0 (achromatic), H is irrelevant. The HSL space is a double hexcone; see Foley and van Dam, section 17.4.5 (they call it HLS). Conversion between RGB and HSL. Constant Colors Finds the color with the given hierarchical name (for Interpress). Returns a well-known color identified by the atom; if atom is unknown, returns NIL. Among the currently recognized atoms are: $White $Gray $Black $Invert $Clear $Red $Green $Blue $Cyan $Magenta $Yellow $Pink $Orange $Brown $Olive $YellowGreen $Purple Constant gray; f is the fraction of absorptance, from 0 (background) to 1 (black). Imager.MakeGray is identical; see MAKEGRAY in the Interpress standard, section 4.7.1. Red, Green, Blue, in the range 0 to 1. If calibration=NIL, the color is uncalibrated. CIE tristimulus values, X, Y, Z, in the range 0 to approximately 100. Returns Interpress-style gray, a fraction of absorptance from 0 (background) to 1 (black). If color came from ColorFromAtom, returns the atom; otherwise returns NIL. Sampled Colors Κ ˜codešœ™Kšœ Οmœ1™