Debian Codegraph @

doc/developer/dither.xml

raw symbols SCIP
1 <chapter>
2 <title>Dithering</title>
3 <para>
4 The dithering code in
5 <filename>src/main/print-dither.c</filename> attempts to
6 reproduce various shades of gray (or all colors) from only a few
7 different inks (black, cyan, magenta, yellow, and sometimes
8 light cyan and light magenta). The dots can't vary in darkness
9 or size (except for certain special printers), and so we need to
10 lay down a certain fraction of dots to represent each distinct
11 level.
12 </para>
13 <para>
14 This sounds straightforward; in practice, it isn't. Completely
15 random distribution of dots (simple probabilistic dithering)
16 would create grainy clumps and light spots. The smoothest
17 pattern results from an equidistant spacing of dots.
18 Approximating this requires sophisticated algorithms. We have
19 two dithering algorithms, an ordered dither algorithm that uses
20 a grid (matrix) to decide whether to print, and a modified
21 Floyd-Steinberg error diffusion algorithm that uses a grid in a
22 slightly different way.
23 </para>
24 <para>
25 We currently have three dithering functions:
26 </para>
27 <variablelist>
28 <varlistentry>
29 <term><literal>dither_fastblack</literal></term>
30 <listitem>
31 <para>
32 This produces pure black or white from a pre-dithered
33 input. This is used for two purposes: for printing pure
34 black and white very quickly (e.g. text), and for printing
35 pre-screened monochrome output that was rasterized
36 externally.
37 </para>
38 </listitem>
39 </varlistentry>
40 <varlistentry>
41 <term><literal>dither_black</literal></term>
42 <listitem>
43 <para>
44 This produces black from grayscale input. The new
45 dither_black can produce either a single or multiple
46 levels of black, for printers supporting variable dot
47 size.
48 </para>
49 </listitem>
50 </varlistentry>
51 <varlistentry>
52 <term><literal>dither_cmyk</literal></term>
53 <listitem>
54 <para>
55 This produces 3, 4, 5, 6, or 7 color output (CMY, CMYK,
56 CcMmYK, CcMmYy, CcMmYyK, or any variants). The new
57 routine can handle single or multiple levels of each
58 color.
59 </para>
60 </listitem>
61 </varlistentry>
62 </variablelist>
63 <para>
64 There is a choice of dithering algorithms. Four of them are
65 based on a basic error diffusion, with a few tweaks of my own.
66 The other one is &lsquo;ordered&rsquo;. However, they all share
67 the basic operation in common. First, the algorithm picks what
68 kind of dot (if there are multiple dot sizes and/or tones that
69 may be picked) is the candidate to be printed. This decision is
70 made based on the darkness at the point being dithered. Then,
71 it decides whether the dot will be printed at all. What this is
72 based on depends upon which algorithm family we use. This is
73 all described in more detail below.
74 </para>
75 <para>
76 Ordered dithering works by comparing the value at a given point
77 with the value of a tiled matrix. If the value at the point is
78 greater than the value in the matrix, the dot is printed. The
79 matrix should consist of a set of evenly spaced points between 0
80 and the upper limit. The choice of matrix is very important for
81 print quality. A good dither matrix will emphasize high
82 frequency components, which distributes dots evenly with a
83 minimum of clumping. The matrices used here are all simple
84 matrices that are expanded recursively to create larger matrices
85 with the same kind of even point distribution. This is
86 described below.
87 </para>
88 <para>
89 Note that it is important to use different matrices for the two
90 sub-operations, because otherwise the choice about whether to
91 print and the choice of dot size will be correlated. The usual
92 result is that the print is either too dark or too light, but
93 there can be other problems.
94 </para>
95 <para>
96 Ordered dithering works quite well on single dot size, four
97 color printers. It has not been well tested on four color,
98 variable dot size printers. It should be avoided on six color
99 printers.
100 </para>
101 <para>
102 Error diffusion works by taking the output error at a given
103 pixel and &ldquo;diffusing&rdquo; it into surrounding pixels.
104 Output error is the difference between the amount of ink output
105 and the input level at each pixel. For simple printers, with
106 one or four ink colors and only one dot size, the amount of ink
107 output is either 65536 (i. e. full output) or 0 (no output).
108 The difference between this and the input level is the error.
109 Normal error diffusion adds part of this error to the adjoining
110 pixels in the next column and the next row (the algorithm simply
111 scans each row in turn, never backing up). The error adds up
112 until it reaches a threshold (half of the full output level, or
113 32768), at which point a dot is output, the output is subtracted
114 from the current value, and the (now negative) error is diffused
115 similarly.
116 </para>
117 <para>
118 Error diffusion works quite well in general, but it tends to
119 generate artifacts which usually appear as worm-like lines or
120 areas of anomalous density. I have devised some ways, as
121 described below, of ameliorating these artifacts.
122 </para>
123 <para>
124 There are two sub-classes of error diffusion that we use here,
125 &lsquo;random&rsquo; and &lsquo;hybrid&rsquo;. One of the
126 techniques that we use to ameliorate the artifacts is to use a
127 fuzzy threshold rather than the hard threshold of half of the
128 output level. Random error diffusion uses a pseudo-random
129 number to perturb the threshold, while hybrid error diffusion
130 uses a matrix. Hybrid error diffusion worked very poorly in
131 3.1.3, and I couldn't figure out why until I found a bug. It
132 now works very well.
133 </para>
134 <para>
135 There is one additional variant (on both sub-classes), called
136 &lsquo;adaptive hybrid&rsquo; and &lsquo;adaptive random&rsquo;.
137 The adaptive variant takes advantage of the fact that the
138 patterns that ordered dithering create are less visible at very
139 low densities, while the artifacts created by error diffusion
140 are more objectionable at low densities. At low densities,
141 therefore, it uses ordered dithering; at higher densities it
142 uses error diffusion.
143 </para>
144 <para>
145 Handling multiple output levels makes life a bit more
146 complicated. In principle, it shouldn't be much harder: simply
147 figure out what the ratio between the available output levels is
148 and have multiple thresholds. In practice, getting these right
149 involves a lot of trial and error. The other thing that's
150 important is to maximize the number of dots that have some ink.
151 This will reduce the amount of speckling. More on this later.
152 </para>
153 <para>
154 The next question: how do we handle black when printing in
155 color? Black ink is much darker than colored inks. It's
156 possible to produce black by adding some mixture of cyan,
157 magenta, and yellow&mdash;in principle. In practice, the black
158 really isn't very black, and different inks and different papers
159 will produce different color casts. However, by using CMY to
160 produce gray, we can output a lot more dots! This makes for a
161 much smoother image. What's more, one cyan, one magenta, and
162 one yellow dot produce less darkness than one black dot, so
163 we're outputting that many more dots. Better yet, with 6 or 7
164 color printers, we have to output even more light ink dots. So
165 Epson Stylus Photo printers can produce really smooth grays---if
166 we do everything right. The right idea is to use CMY at lower
167 black levels, and gradually mix in black as the overall amount
168 of ink increases, so the black dots don't really become visible
169 within the ink mass.
170 </para>
171 <para>
172 Variable dot sizes are handled by dividing the range between 0
173 and 65536 into segments. Each segment can either represent a
174 range in which all of one kind of ink (color and/or dot size) is
175 used, with varying amounts of ink, or a transition region
176 between inks, in which equal numbers of dots are printed but the
177 amount of each ink will be adjusted throughout the range. Each
178 range is represented by four numbers:
179 </para>
180 <itemizedlist>
181 <listitem>
182 <para>
183 Bottom of the range.
184 </para>
185 </listitem>
186 <listitem>
187 <para>
188 Top of the range.
189 </para>
190 </listitem>
191 <listitem>
192 <para>
193 Value of the lighter ink.
194 </para>
195 </listitem>
196 <listitem>
197 <para>Value of the darker ink.
198 </para>
199 </listitem>
200 </itemizedlist>
201 <para>
202 In addition, the bit patterns and which type of ink are also
203 represented, but they don't affect the actual algorithm.
204 </para>
205 <para>
206 As mentioned above, the basic algorithm is the same whether we
207 use ordered dither or error diffusion. We perform the following
208 steps on each color of each pixel:
209 </para>
210 <orderedlist>
211 <listitem>
212 <para>
213 Compute the value of the particular color we're printing.
214 This isn't usually the pure CMY value; it's adjusted to
215 improve saturation and to limit the use of black in light
216 toned regions (to avoid speckling).
217 </para>
218 </listitem>
219 <listitem>
220 <para>
221 Find the range containing this value.
222 </para>
223 </listitem>
224 <listitem>
225 <para>
226 Compute where this value lies within the range. We scale
227 the endpoints between 0 and 65536 for this purpose. So for
228 example, if the bottom of the range is 10,000 and the top of
229 the range is 20,000, and the value is 12,500, we're 1/4 of
230 the way between the bottom and the top of the range, so our
231 scale point is 16384.
232 </para>
233 </listitem>
234 <listitem>
235 <para>
236 Compute the &ldquo;virtual value&rdquo;. The virtual value
237 is the distance between the value of the lighter and the
238 value of the darker ink. So if the value of the light ink
239 is 32768 and the dark ink is 65536, we compute a virtual
240 value scaled appropriately between these two values, which
241 is 40960 in this case.
242 </para>
243 </listitem>
244 <listitem>
245 <para>
246 Using either error diffusion or ordered dither, the standard
247 threshold is 1/2 of the value (20480 in this case). Using
248 ordered dither, we want to compute a value between 0 and
249 40960 that we will compare the input value against to decide
250 whether to print. Using pure error diffusion, we would
251 compare the accumulated error against 20480 to decide
252 whether to print. In practice, we use the same matrix
253 method to decide whether to print. The correct amount of
254 ink will be printed this way, but we minimize the squiggly
255 lines characteristic of error diffusion by dithering the
256 threshold in this fashion. A future enhancement will allow
257 us to control the amount of dithering applied to the
258 threshold.
259 </para>
260 </listitem>
261 </orderedlist>
262 <para>
263 The matrices were generated by Thomas Tonino
264 <email>[email protected]</email> with an algorithm of his
265 devising. The algorithm is designed to maximize the spacing
266 between dots at any given density by searching the matrix for
267 holes and placing a dot in the largest available hole. It
268 requires careful selection of initial points to achieve good
269 results, and is very time consuming. For best results, a
270 different matrix must be used for modes with 2:1 aspect ratio
271 (e.g. 1440&times;720) than for 1:1 (e. g. 720&times;720). It is
272 essential with any of these matrices that every point be used.
273 Skipping points generates low-frequency noise.
274 </para>
275 <para>
276 It's essential to use different matrices for deciding whether to
277 print and for deciding what color (dark or light) to print.
278 This should be obvious; the decision about whether to print at
279 all should be as independent as possible from the decision about
280 what color to print, because any bias will result in excess
281 light or dark ink being printed, shifting the tonal balance. We
282 actually use the same matrices, but we shift them vertically and
283 horizontally. Assuming that the matrices are not
284 self-correlated, this will yield good results.
285 </para>
286 <para>
287 The ranges are computed from a list of ink values (between 0 and
288 1 for each possible combination of dot size and ink tone, where
289 the value represents the darkness of the ink) and the desired
290 maximum density of the ink. This is done in dither_set_ranges,
291 and needs more documentation.
292 </para>
293 <para>
294 I stated earlier that I've tweaked the basic error diffusion
295 algorithm. Here's what I've done to improve it:
296 </para>
297 <itemizedlist>
298 <listitem>
299 <para>
300 We use a variable threshold to decide when to print, as
301 discussed above. This does two things for us: it reduces
302 the slightly squiggly diagonal lines that are the mark of
303 error diffusion; and it allows us to lay down some ink even
304 in very light areas near the edge of the image. The
305 squiggly lines that error diffusion algorithms tend to
306 generate are caused by the gradual accumulation of error.
307 This error is partially added horizontally and partially
308 vertically. The horizontal accumulation results in a dot
309 eventually being printed. The vertical accumulation results
310 in a dot getting laid down in roughly the same horizontal
311 position in the next row. The diagonal squigglies result
312 from the error being added to pixels one forward and one
313 below the current pixel; these lines slope from the top
314 right to the bottom left of the image.
315 </para>
316 <para>
317 Error diffusion also results in pale areas being completely
318 white near the top left of the image (the origin of the
319 printing coordinates). This is because enough error has to
320 accumulate for anything at all to get printed. In very pale
321 areas it takes quite a long time to build up anything
322 printable at all; this results in the bare spots.
323 </para>
324 <para>
325 Randomizing the threshold somewhat breaks up the diagonals
326 to some degree by randomizing the exact location that the
327 accumulated output crosses the threshold. It reduces the
328 false white areas by allowing some dots to be printed even
329 when the accumulated output level is very low. It doesn't
330 result in excess ink because the full output level is still
331 subtracted and diffused.
332 </para>
333 <para>
334 Excessive randomization leads to blobs at high densities.
335 Therefore, as the density increases, the degree of
336 randomization decreases.
337 </para>
338 </listitem>
339 <listitem>
340 <para>
341 Alternating scan direction between rows (first row is
342 scanned left to right, second is scanned right to left, and
343 so on). This also helps break up white areas, and it also
344 seems to break up squigglies a bit. Furthermore, it
345 eliminates directional biases in the horizontal direction.
346 This isn't necessary for ordered dither, but it doesn't hurt
347 either.
348 </para>
349 </listitem>
350 <listitem>
351 <para>
352 Diffusing the error into more pixels. Instead of diffusing
353 the entire error into (X+1, Y) and (X, Y+1), we diffuse it
354 into (X+1, Y), (X+K, Y+1), (X, Y+1), (X-K, Y+1) where K
355 depends upon the output level (it never exceeds about 10
356 dots, and is greater at higher output levels). This really
357 reduces squigglies and graininess. The amount of this
358 spread can be controlled; for line art, it should be less
359 than for photographs (of course, line art doesn't usually
360 contain much light color, but the <emphasis>error</emphasis>
361 value can be small in places!) In addition to requiring
362 more computation, a wide ink spread results in patterning at
363 high dot densities (note that the dot density can be high
364 even in fairly pale regions if multiple dot sizes are in
365 use).
366 </para>
367 </listitem>
368 <listitem>
369 <para>
370 Don't lay down any colored ink if we're laying down black
371 ink. There's no point; the colored ink won't show. We
372 still pretend that we did for purposes of error diffusion
373 (otherwise excessive error will build up, and will take a
374 long time to clear, resulting in heavy bleeding of ink into
375 surrounding areas, which is very ugly indeed), but we don't
376 bother wasting the ink. How well this will do with variable
377 dot size remains to be seen.
378 </para>
379 </listitem>
380 <listitem>
381 <para>
382 Oversampling. This is how to print 1440&times;720 with Epson
383 Stylus printers. Printing full density at 1440&times;720 will
384 result in excess ink being laid down. The trick is to print
385 only every other dot. We still compute the error as though we
386 printed every dot. It turns out that randomizing which dots
387 are printed results in very speckled output. This can be
388 taken too far; oversampling at 1440&times;1440 or
389 1440&times;2880 virtual resolution results in other problems.
390 However, at present 1440&times;1440 (which is more accurately
391 called "1440&times;720 enhanced", as the Epson printers cannot
392 print 1440 rows per inch) does quite well, although it's slow.
393 </para>
394 </listitem>
395 </itemizedlist>
396 <para>
397 What about multiple output levels? For 6 and 7 color printers,
398 simply using different threshold levels has a problem: the pale
399 inks have trouble being seen when a lot of darker ink is being
400 printed. So rather than just using the output level of the
401 particular color to decide which ink to print, we look at the
402 total density (sum of all output levels). If the density's high
403 enough, we prefer to use the dark ink. Speckling is less
404 visible when there's a lot of ink, anyway. I haven't yet
405 figured out what to do for multiple levels of one color.
406 </para>
407 <para>
408 You'll note that I haven't quoted a single source on color or
409 printing theory. I simply did all of this empirically.
410 </para>
411 <para>
412 There are various other tricks to reduce speckling. One that
413 I've seen is to reduce the amount of ink printed in regions
414 where one color (particularly cyan, which is perceived as the
415 darkest) is very pale. This does reduce speckling all right,
416 but it also results in strange tonal curves and weird (to my
417 eye) colors.
418 </para>
419 <para>
420 Before any dither routine is used,
421 <function>init_dither</function> must be called. This takes
422 three arguments: the input width (number of pixels in the
423 input), the output width (number of pixels in the output), and a
424 <type>stp_vars_t</type> structure containing the parameters for
425 the print job.
426 </para>
427 <para>
428 <function>init_dither</function> returns a pointer to an opaque
429 object representing the dither. This object is passed as the first
430 argument to all of the dither-related routines.
431 </para>
432 <para>
433 After a page is fully dithered, <function>free_dither</function>
434 must be called to free the dither object and perform any
435 cleanup. In the future, this may do more (such as flush
436 output). This arrangement permits using these routines with
437 programs that create multiple output pages, such as the CUPS driver.
438 </para>
439 <para>
440 The dithering routines themselves have a number of control knobs
441 that control internal aspects of the dithering process. These
442 knobs are accessible via a number of functions that can be
443 called after <function>init_dither</function>.
444 </para>
445 <itemizedlist>
446 <listitem>
447 <para>
448 <function>dither_set_density</function> takes a double
449 between 0 and 1 representing the desired ink density for
450 printing solid colors. This is used in a number of places
451 in the dithering routine to make decisions.
452 </para>
453 </listitem>
454 <listitem>
455 <para>
456 <function>dither_set_black_density</function> takes a double
457 between 0 and 1 representing the desired ink density for
458 printing black ink in color printing. This is used to
459 balance black against color ink. By default, this is equal
460 to the density set by
461 <function>dither_set_density</function>. By setting it
462 higher, more black ink will be printed. For example, if the
463 base density is .4 and the black density is .8, twice as
464 much black ink will be printed as would otherwise be called
465 for.
466 </para>
467 <para>
468 This is not used when printing in monochrome. When printing
469 monochrome, the base density
470 (<function>dither_set_density</function>) should be adjusted
471 appropriately.
472 </para>
473 </listitem>
474 <listitem>
475 <para>
476 <function>dither_set_ink_budget</function> takes an unsigned
477 number representing the most ink that may be deposited at a
478 given point. This number is arbitrary; the limit is
479 computed by summing the size of each ink dot, which is
480 supplied as a parameter in
481 <function>dither_set_X_ranges</function>. By default, there
482 is no limit.
483 </para>
484 </listitem>
485 <listitem>
486 <para>
487 <function>dither_set_black_lower</function> takes a double
488 that should be between 0 and 1 that represents the lowest
489 density level at which black ink will start to mix in with
490 colored ink to generate grays. The lower this is, the less
491 density is required to use black ink. Setting this too low
492 will result in speckling from black dots, particularly on 6
493 and 7 color printers. Setting this too high will make it
494 hard to get satisfactory black or may result in sharp
495 transition between blended colors and black. Default:
496 0.0468.
497 </para>
498 <para>
499 It is important to note that since the density scale is
500 never linear (and since this value is adjusted via other
501 things happening during the dithering process) that this
502 does not mean that 95% gray will use any black ink. At this
503 setting, there will be no black ink used until about 50%
504 gray.
505 </para>
506 <para>
507 This only applies to color mode.
508 </para>
509 <para>
510 This value should be set lower for printers capable of
511 variable dot size, since more dots can be laid down close to
512 each other.
513 </para>
514 </listitem>
515 <listitem>
516 <para>
517 <function>dither_set_black_upper</function> takes a double
518 that should be between 0 and 1 that represents the highest
519 density level at which colored inks will be mixed to create
520 gray. Setting this too low will result in speckly dark
521 grays because there is not enough ink to fill all the holes,
522 or sharp transition between blended colors and black if it
523 is too close to the value of
524 <function>dither_set_black_upper</function> Setting this too
525 high will result in poor black and dark tone quality.
526 Default: 0.5. This results in 10% and darker grays being
527 printed with essentially all black.
528 </para>
529 <para>
530 This only applies to color mode.
531 </para>
532 </listitem>
533 <listitem>
534 <para>
535 <function>dither_set_black_levels</function> takes three
536 doubles that represent the amount of cyan, magenta, and
537 yellow respectively that are blended to create gray. The
538 defaults are 1.0 for each, which is probably too low for
539 most printers. These values are adjusted to create a good
540 gray balance. Setting these too low will result in pale
541 light and midtone grays, with a sharp transition to darker
542 tones as black mixes in. Setting them too high will result
543 in overly dark grays and use of too much ink, possibly
544 creating bleed-through.
545 </para>
546 <para>
547 This only applies to color mode.
548 </para>
549 </listitem>
550 <listitem>
551 <para>
552 <function>dither_set_randomizers</function> takes four
553 integer values representing the degree of randomness used
554 for cyan, magenta, yellow, and black. This is used to allow
555 some printing to take place in pale areas. Zero is the most
556 random; greater than 8 or so gives very little randomness at
557 all. Defaults are 0 for cyan, magenta, and yellow, and 4
558 for black. Setting the value for black too low will result
559 in black speckling in pale areas. Setting values too high
560 will result in pale areas getting no ink at all.
561 </para>
562 <para>
563 This currently only applies to single dot size in color and
564 black. It should be extended to operate in variable dot
565 size mode, although actually applying it correctly will be
566 tricky.
567 </para>
568 </listitem>
569 <listitem>
570 <para>
571 <function>dither_set_ink_darkness</function> takes three
572 doubles representing the contribution to perceived darkness
573 of cyan, magenta, and yellow. This is used to help decide
574 when to switch between light and dark inks in 6 and 7 color
575 printers (with light cyan, light magenta, and possibly light
576 yellow). Setting these too low will result in too much
577 light ink being laid down, creating flat spots in the
578 darkness curves and bleed-through. Setting them too high
579 will result in dark ink being used in pale areas, creating
580 speckle. The defaults are .4 for cyan, .3 for magenta, and
581 .2 for yellow. Dark cyan will show against yellow much more
582 than dark magenta will show against cyan, since the cyan
583 appears much darker than the yellow.
584 </para>
585 </listitem>
586 <listitem>
587 <para>
588 <function>dither_set_light_inks</function> takes three
589 doubles between 0 and 1 representing the ratio in darkness
590 between the light and dark versions of the inks. Setting
591 these too low will result in too much dark ink being used in
592 pale areas, creating speckling, while setting them too high
593 will result in very smooth texture but too much use of light
594 ink, resulting in flat spots in the density curves and ink
595 bleed-through. There are no defaults. Any light ink
596 specified as zero indicates that there is no light ink for
597 that color.
598 </para>
599 <para>
600 This only applies to 6 and 7 color printers in single dot
601 size color mode, and only to those inks which have light
602 versions (usually cyan and magenta).
603 </para>
604 </listitem>
605 <listitem>
606 <para>
607 <function>dither_set_ink_spread</function> takes a small
608 integer representing the amount of ink spread in the dither.
609 Larger numbers mean less spread. Larger values are
610 appropriate for line art and solid tones; they will yield
611 sharper transitions but more dither artifacts. Smaller
612 values are more appropriate for photos. They will reduce
613 resolution and sharpness but reduce dither artifacts up to a
614 point. A value of 16 or higher implies minimum ink spread
615 at any resolution no matter what the overdensity. A value
616 of 14 is typical for photos on single dot size, 6 color
617 printers. For 4 color printers, subtract 1 (more spread;
618 the dots are farther apart). For variable dot size
619 printers, add 1 (more small dots are printed; less spread is
620 desirable).
621 </para>
622 </listitem>
623 <listitem>
624 <para>
625 <function>dither_set_adaptive_divisor</function> takes a
626 float representing the transition point between error
627 diffusion and ordered dither if adaptive dithering is used.
628 The float is a fraction of the printing density. For
629 example, if you wish the transition to be at 1/4 of the
630 maximum density (which works well on simple 4-color
631 printers), you would pass .25 here. With six colors and/or
632 with multiple dot sizes, the values should be set lower.
633 </para>
634 </listitem>
635 <listitem>
636 <para>
637 <function>dither_set_transition</function> takes a float
638 representing the exponent of the transition curve between
639 light and dark inks/dot sizes. A value less than 1 (typical
640 when using error diffusion) mixes in less dark ink/small
641 dots at lower ends of the range, to reduce speckling. When
642 using ordered dithering, this must be set to 1.
643 </para>
644 </listitem>
645 <listitem>
646 <para>
647 <function>dither_set_X_ranges_simple</function>
648 (<literal>X</literal> = <literal>c</literal>,
649 <literal>m</literal>, <literal>y</literal> or
650 <literal>k</literal>) describes the ink choices available
651 for each color. This is useful in typical cases where a
652 four color printer with variable dot sizes is in use. It is
653 passed an array of doubles between (0, 1] representing the
654 relative darkness of each dot size. The dot sizes are
655 assigned bit patterns (and ink quantities, see
656 <function>dither_set_ink_budget</function> above) from 1 to
657 the number of levels. This also requires a density, which
658 is the desired density for this color. This density need
659 not equal the density specified in
660 <function>dither_set_density</function>. Setting it lower
661 will tend to print more dark ink (because the curves are
662 calculated for this color assuming a lower density than is
663 actually supplied).
664 </para>
665 </listitem>
666 <listitem>
667 <para>
668 <function>dither_set_X_ranges</function>
669 (<literal>X</literal> = <literal>c</literal>,
670 <literal>m</literal>, <literal>y</literal> or
671 <literal>k</literal>) describes in a more general way the
672 ink choices available for each color. For each possible ink
673 choice, a bit pattern, dot size, value (i. e. relative
674 darkness), and whether the ink is the dark or light variant
675 ink is specified.
676 </para>
677 </listitem>
678 </itemizedlist>
679 </chapter>