aboutsummaryrefslogtreecommitdiffstats
path: root/color.txi
blob: 101bc7ba0c8be273fecea40b43cebcdd21eca7c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
@subsubheading Measurement-based Color Spaces

@noindent
@cindex tristimulus
The @dfn{tristimulus} color spaces are those whose component values
@cindex tristimulus
are proportional measurements of light intensity.  The CIEXYZ(1931)
system provides 3 sets of spectra to dot-product with a spectrum of
interest.  The result of those dot-products is coordinates in CIEXYZ
space.  All tristimuls color spaces are related to CIEXYZ by linear
transforms, namely matrix multiplication.  Of the color spaces listed
here, CIEXYZ and RGB709 are tristimulus spaces.

@deftp {Color Space} CIEXYZ
The CIEXYZ color space covers the full @dfn{gamut}.
@cindex gamut
It is the basis for color-space conversions.

CIEXYZ is a list of three inexact numbers between 0.0 and 1.1.
'(0. 0. 0.) is black; '(1. 1. 1.) is white.
@end deftp


@defun ciexyz->color xyz

@var{xyz} must be a list of 3 numbers.  If @var{xyz} is valid CIEXYZ coordinates,
then @code{ciexyz->color} returns the color specified by @var{xyz}; otherwise returns #f.
@end defun


@defun color:ciexyz x y z

Returns the CIEXYZ color composed of @var{x}, @var{y}, @var{z}.  If the
coordinates do not encode a valid CIEXYZ color, then an error is
signaled.
@end defun


@defun color->ciexyz color
Returns the list of 3 numbers encoding @var{color} in CIEXYZ.
@end defun

@deftp {Color Space} RGB709
BT.709-4 (03/00) @cite{Parameter values for the HDTV standards for
production and international programme exchange} specifies parameter
values for chromaticity, sampling, signal format, frame rates, etc., of
high definition television signals.

An RGB709 color is represented by a list of three inexact numbers
between 0.0 and 1.0.  '(0. 0. 0.) is black '(1. 1. 1.) is white.
@end deftp


@defun rgb709->color rgb

@var{rgb} must be a list of 3 numbers.  If @var{rgb} is valid RGB709 coordinates,
then @code{rgb709->color} returns the color specified by @var{rgb}; otherwise returns #f.
@end defun


@defun color:rgb709 r g b

Returns the RGB709 color composed of @var{r}, @var{g}, @var{b}.  If the
coordinates do not encode a valid RGB709 color, then an error is
signaled.
@end defun


@defun color->rgb709 color
Returns the list of 3 numbers encoding @var{color} in RGB709.
@end defun

@subsubheading Perceptual Uniformity

@noindent
Although properly encoding the chromaticity, tristimulus spaces do not
match the logarithmic response of human visual systems to intensity.
Minimum detectable differences between colors correspond to a smaller
range of distances (6:1) in the L*a*b* and L*u*v* spaces than in
tristimulus spaces (80:1).  For this reason, color distances are
computed in L*a*b* (or L*C*h).

@deftp {Color Space} L*a*b*
Is a CIE color space which better matches the human visual system's
perception of color.  It is a list of three numbers:

@itemize @bullet
@item
0 <= L* <= 100 (CIE @dfn{Lightness})
@cindex Lightness

@item
-500 <= a* <= 500
@item
-200 <= b* <= 200
@end itemize
@end deftp


@defun l*a*b*->color L*a*b* white-point

@var{L*a*b*} must be a list of 3 numbers.  If @var{L*a*b*} is valid L*a*b* coordinates,
then @code{l*a*b*->color} returns the color specified by @var{L*a*b*}; otherwise returns #f.
@end defun


@defun color:l*a*b* L* a* b* white-point

Returns the L*a*b* color composed of @var{L*}, @var{a*}, @var{b*} with @var{white-point}.

@defunx color:l*a*b* L* a* b*
Returns the L*a*b* color composed of @var{L*}, @var{a*}, @var{b*}.  If the coordinates
do not encode a valid L*a*b* color, then an error is signaled.
@end defun


@defun color->l*a*b* color white-point

Returns the list of 3 numbers encoding @var{color} in L*a*b* with @var{white-point}.

@defunx color->l*a*b* color
Returns the list of 3 numbers encoding @var{color} in L*a*b*.
@end defun

@deftp {Color Space} L*u*v*
Is another CIE encoding designed to better match the human visual
system's perception of color.
@end deftp


@defun l*u*v*->color L*u*v* white-point

@var{L*u*v*} must be a list of 3 numbers.  If @var{L*u*v*} is valid L*u*v* coordinates,
then @code{l*u*v*->color} returns the color specified by @var{L*u*v*}; otherwise returns #f.
@end defun


@defun color:l*u*v* L* u* v* white-point

Returns the L*u*v* color composed of @var{L*}, @var{u*}, @var{v*} with @var{white-point}.

@defunx color:l*u*v* L* u* v*
Returns the L*u*v* color composed of @var{L*}, @var{u*}, @var{v*}.  If the coordinates
do not encode a valid L*u*v* color, then an error is signaled.
@end defun


@defun color->l*u*v* color white-point

Returns the list of 3 numbers encoding @var{color} in L*u*v* with @var{white-point}.

@defunx color->l*u*v* color
Returns the list of 3 numbers encoding @var{color} in L*u*v*.
@end defun

@subsubheading Cylindrical Coordinates

@noindent
HSL (Hue Saturation Lightness), HSV (Hue Saturation Value), HSI (Hue
Saturation Intensity) and HCI (Hue Chroma Intensity) are cylindrical
color spaces (with angle hue).  But these spaces are all defined in
terms device-dependent RGB spaces.

@noindent
One might wonder if there is some fundamental reason why intuitive
specification of color must be device-dependent.  But take heart!  A
cylindrical system can be based on L*a*b* and is used for predicting how
close colors seem to observers.

@deftp {Color Space} L*C*h
Expresses the *a and b* of L*a*b* in polar coordinates.  It is a list of
three numbers:

@itemize @bullet
@item
0 <= L* <= 100 (CIE @dfn{Lightness})
@cindex Lightness

@item
C* (CIE @dfn{Chroma}) is the distance from the neutral (gray) axis.
@cindex Chroma
@item
0 <= h <= 360 (CIE @dfn{Hue}) is the angle.
@cindex Hue
@end itemize

The colors by quadrant of h are:

@multitable @columnfractions .20 .60 .20
@item 0 @tab red, orange, yellow @tab 90
@item 90 @tab yellow, yellow-green, green @tab 180
@item 180 @tab green, cyan (blue-green), blue @tab 270
@item 270 @tab blue, purple, magenta @tab 360
@end multitable

@end deftp


@defun l*c*h->color L*C*h white-point

@var{L*C*h} must be a list of 3 numbers.  If @var{L*C*h} is valid L*C*h coordinates,
then @code{l*c*h->color} returns the color specified by @var{L*C*h}; otherwise returns #f.
@end defun


@defun color:l*c*h L* C* h white-point

Returns the L*C*h color composed of @var{L*}, @var{C*}, @var{h} with @var{white-point}.

@defunx color:l*c*h L* C* h
Returns the L*C*h color composed of @var{L*}, @var{C*}, @var{h}.  If the coordinates
do not encode a valid L*C*h color, then an error is signaled.
@end defun


@defun color->l*c*h color white-point

Returns the list of 3 numbers encoding @var{color} in L*C*h with @var{white-point}.

@defunx color->l*c*h color
Returns the list of 3 numbers encoding @var{color} in L*C*h.
@end defun

@subsubheading Digital Color Spaces

@noindent
The color spaces discussed so far are impractical for image data because
of numerical precision and computational requirements.  In 1998 the IEC
adopted @cite{A Standard Default Color Space for the Internet - sRGB}
(@url{http://www.w3.org/Graphics/Color/sRGB}).  sRGB was cleverly
designed to employ the 24-bit (256x256x256) color encoding already in
widespread use; and the 2.2 gamma intrinsic to CRT monitors.

@noindent
Conversion from CIEXYZ to digital (sRGB) color spaces is accomplished by
conversion first to a RGB709 tristimulus space with D65 white-point;
then each coordinate is individually subjected to the same non-linear
mapping.  Inverse operations in the reverse order create the inverse
transform.

@deftp {Color Space} sRGB
Is "A Standard Default Color Space for the Internet".  Most display
monitors will work fairly well with sRGB directly.  Systems using ICC
profiles
@ftindex ICC Profile
@footnote{
@noindent
A comprehensive encoding of transforms between CIEXYZ and device color
spaces is the International Color Consortium profile format,
ICC.1:1998-09:

@quotation
The intent of this format is to provide a cross-platform device profile
format.  Such device profiles can be used to translate color data
created on one device into another device's native color space.
@end quotation
}
should work very well with sRGB.

@end deftp


@defun srgb->color rgb

@var{rgb} must be a list of 3 numbers.  If @var{rgb} is valid sRGB coordinates,
then @code{srgb->color} returns the color specified by @var{rgb}; otherwise returns #f.
@end defun


@defun color:srgb r g b

Returns the sRGB color composed of @var{r}, @var{g}, @var{b}.  If the
coordinates do not encode a valid sRGB color, then an error is
signaled.
@end defun

@deftp {Color Space} xRGB
Represents the equivalent sRGB color with a single 24-bit integer.  The
most significant 8 bits encode red, the middle 8 bits blue, and the
least significant 8 bits green.
@end deftp


@defun color->srgb color

Returns the list of 3 integers encoding @var{color} in sRGB.
@end defun


@defun color->xrgb color
Returns the 24-bit integer encoding @var{color} in sRGB.
@end defun


@defun xrgb->color k

Returns the sRGB color composed of the 24-bit integer @var{k}.
@end defun

@deftp {Color Space} e-sRGB
Is "Photography - Electronic still picture imaging - Extended sRGB color
encoding" (PIMA 7667:2001).  It extends the gamut of sRGB; and its
higher precision numbers provide a larger dynamic range.

A triplet of integers represent e-sRGB colors.  Three precisions are
supported:

@table @r
@item e-sRGB10
0 to 1023
@item e-sRGB12
0 to 4095
@item e-sRGB16
0 to 65535
@end table
@end deftp


@defun e-srgb->color precision rgb
@var{precision} must be the integer 10, 12, or 16.  @var{rgb} must be a list of 3
numbers.  If @var{rgb} is valid e-sRGB coordinates, then @code{e-srgb->color} returns the color
specified by @var{rgb}; otherwise returns #f.
@end defun


@defun color:e-srgb 10 r g b

Returns the e-sRGB10 color composed of integers @var{r}, @var{g}, @var{b}.

@defunx color:e-srgb 12 r g b
Returns the e-sRGB12 color composed of integers @var{r}, @var{g}, @var{b}.

@defunx color:e-srgb 16 r g b
Returns the e-sRGB16 color composed of integers @var{r}, @var{g}, @var{b}.
If the coordinates do not encode a valid e-sRGB color, then an error
is signaled.
@end defun


@defun color->e-srgb precision color
@var{precision} must be the integer 10, 12, or 16.  @code{color->e-srgb} returns the list of 3
integers encoding @var{color} in sRGB10, sRGB12, or sRGB16.
@end defun