1Pamditherbw User Manual(0) Pamditherbw User Manual(0)
2
3
4
6 pamditherbw - dither grayscale image to black and white
7
8
10 pamditherbw
11
12 [-floyd | -fs | -atkinson | -threshold | -hilbert | -dither8 | -d8 |
13 -cluster3 | -c3 | -cluster4 | -c4 | -cluster8 | -c8]
14
15 [-value val]
16
17 [-clump size]
18
19 [pamfile]
20
21
23 This program is part of Netpbm(1).
24
25 pamditherbw dithers a grayscale image. Dithering means turning each
26 shade of gray into a pattern of black and white pixels that, from a
27 distance, look the same as the gray.
28
29 The input should be a PGM image or a PAM image of tuple type GRAYSCALE.
30 However, pamditherbw doesn't check, so if you feed it e.g. a PPM image,
31 it will produce arbitrary results (actually, it just takes the first
32 channel of whatever you give it and treats it as if it represented gray
33 levels).
34
35 The output is a PAM with tuple type BLACKANDWHITE. You can turn this
36 into a PBM (if you need to use it with an older program doesn't under‐
37 stand PAM) with pamtopnm.
38
39 To do the opposite of dithering, you can usually just scale the image
40 down and then back up again with pamscale, possibly smoothing or blur‐
41 ring the result with pnmsmooth or pnmconvol. Or use the special case
42 program pbmtopgm.
43
44 To dither a color image (to reduce the number of pixel colors), use
45 ppmdither.
46
47 Another way to convert a grayscale image to a black and white image is
48 thresholding. Thresholding is simply replacing each grayscale pixel
49 with a black or white pixel depending on wether its brightness is above
50 or below a threshold. That threshold might vary. Simple thresholding
51 is a degenerate case of dithering, so pamditherbw does very simple
52 thresholding with its -threshold option. But pamthreshold does more
53 sophisticated thresholding.
54
55
56
58 The default quantization method is boustrophedonic Floyd-Steinberg
59 error diffusion (-floyd or -fs).
60
61 Also available are simple thresholding (-threshold); Bayer's ordered
62 dither (-dither8) with a 16x16 matrix;
63 Atkinson
64 ⟨http://www.tinrocket.com/projects/programming/graphics/00158/⟩ ; and
65 three different sizes of 45-degree clustered-dot dither (-cluster3,
66 -cluster4, -cluster8).
67
68 A space filling curve halftoning method using the Hilbert curve is also
69 available (-hilbert).
70
71 Floyd-Steinberg or Atkinson will almost always give the best looking
72 results; however, looking good is not always what you want. For
73 instance, thresholding can be used in a pipeline with the pnmconvol
74 tool, for tasks like edge and peak detection. And clustered-dot
75 dithering gives a newspaper-ish look, a useful special effect.
76
77 Floyd-Steinberg is by for the more traditional, but
78 some claim
79 ⟨http://www.tinrocket.com/projects/programming/graphics/00158/⟩ Atkin‐
80 son works better.
81
82 The -value option alters the thresholding value for Floyd-Steinberg and
83 simple thresholding. It should be a real number between 0 and 1.
84 Above 0.5 means darker images; below 0.5 means lighter.
85
86 The Hilbert curve method is useful for processing images before display
87 on devices that do not render individual pixels distinctly (like laser
88 printers). This dithering method can give better results than the
89 dithering usually done by the laser printers themselves. The -clump
90 option alters the number of pixels in a clump. This is usually an
91 integer between 2 and 100 (default 5). Smaller clump sizes smear the
92 image less and are less grainy, but seem to lose some grey scale lin‐
93 earity. Typically a PGM image will have to be scaled to fit on a laser
94 printer page (2400 x 3000 pixels for an A4 300 dpi page), and then
95 dithered to a PBM image before being converted to a postscript file. A
96 printing pipeline might look something like:
97
98 pamscale -xysize 2400 3000 image.pgm | pamditherbw -hilbert | pamtopnm | pnmtops -scale 0.25 > image.ps
99
100 All options can be abbreviated to their shortest unique prefix.
101
102
104 The only reference you need for this stuff is 'Digital Halftoning' by
105 Robert Ulichney, MIT Press, ISBN 0-262-21009-6.
106
107 The Hilbert curve space filling method is taken from 'Digital Halfton‐
108 ing with Space Filling Curves' by Luiz Velho, Computer Graphics Volume
109 25, Number 4, proceedings of SIGRAPH '91, page 81. ISBN 0-89791-436-8
110
111
113 pamtopnm(1), pgmtopgm(1), pbmtopgm(1), pamthreshold(1), pbmreduce(1),
114 pnmconvol(1), pamscale(1), pam(1), pnm(1),
115
116
118 pamditherbw was new in Netpbm 10.23 (July 2004), but is essentially the
119 same program as pgmtopbm that has existed practically since the begin‐
120 ning. pamditherbw differs from its predecessor in that it properly
121 adds brightnesses (using gamma transformations; pgmtopbm just adds them
122 linearly) and that it accepts PAM input in addition to PGM and PBM and
123 produces PAM output.
124
125 pamditherbw obsoletes pgmtopbm.
126
127 -atkinson was new in Netpbm 10.38 (March 2007).
128
129
131 Copyright (C) 1989 by Jef Poskanzer.
132
133
134
135netpbm documentation 03 March 2007 Pamditherbw User Manual(0)