summaryrefslogtreecommitdiffstats
path: root/upstream/fedora-rawhide/man1/pamditherbw.1
blob: c60ace76e12bda3d5150ce6546c43ed0d98ca574 (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
\
.\" This man page was generated by the Netpbm tool 'makeman' from HTML source.
.\" Do not hand-hack it!  If you have bug fixes or improvements, please find
.\" the corresponding HTML page on the Netpbm website, generate a patch
.\" against that, and send it to the Netpbm maintainer.
.TH "Pamditherbw User Manual" 0 "10 May 2010" "netpbm documentation"

.SH NAME

pamditherbw - dither grayscale image to black and white

.UN synopsis
.SH SYNOPSIS

\fBpamditherbw\fP

[\fB-floyd\fP | \fB-fs\fP
| \fB-atkinson\fP
| \fB-threshold\fP
| \fB-hilbert\fP
| \fB-dither8\fP | \fB-d8\fP | \fB-cluster3\fP
| \fB-c3\fP | \fB-cluster4\fP | \fB-c4\fP
| \fB-cluster8\fP | \fB-c8\fP]

[\fB-value\fP \fIval\fP]

[\fB-clump\fP \fIsize\fP]

[\fB-randomseed=\fP\fIinteger\fP]

[\fIpamfile\fP]
.PP
All options can be abbreviated to their shortest unique prefix.

.UN description
.SH DESCRIPTION
.PP
This program is part of
.BR "Netpbm" (1)\c
\&.
.PP
\fBpamditherbw\fP dithers a grayscale image.  Dithering means turning
each shade of gray into a pattern of black and white pixels that, from
a distance, look the same as the gray.
.PP
The input should be a PGM image or a PAM image of tuple type
GRAYSCALE.  However, \fBpamditherbw\fP doesn't check, so if you feed
it e.g. a PPM image, it will produce arbitrary results (actually, it
just takes the first channel of whatever you give it and treats it as
if it represented gray levels).
.PP
The output is a PAM with tuple type BLACKANDWHITE.  You can turn
this into a PBM (if you need to use it with an older program that doesn't
understand PAM) with \fBpamtopnm\fP.
.PP
To do the opposite of dithering, you can usually just scale the image
down and then back up again with \fBpamscale\fP, possibly smoothing or
blurring the result with \fBpnmsmooth\fP or \fBpnmconvol\fP.  Or use
the special case program \fBpbmtopgm\fP.
.PP
To dither a color image (to reduce the number of pixel colors),
use \fBppmdither\fP.
.PP
Another way to convert a grayscale image to a black and white image
is thresholding.  Thresholding is simply replacing each grayscale pixel
with a black or white pixel depending on whether its brightness is above or
below a threshold.  That threshold might vary.  Simple thresholding is a
degenerate case of dithering, so \fBpamditherbw\fP does very simple
thresholding with its \fB-threshold\fP option.  But \fBpamthreshold\fP
does more sophisticated thresholding.
.PP
If all you want is to change a PGM image with maxval 1 to a PBM image,
\fBpamtopnm\fP will do that.


.UN options
.SH OPTIONS
.PP
In addition to the options common to all programs based on libnetpbm
(most notably \fB-quiet\fP, see 
.UR index.html#commonoptions
 Common Options
.UE
\&), \fBpamditherbw\fP recognizes the following
command line options:

.UN quantmethod
.SS Quantization Method
.PP
The default quantization method is boustrophedonic Floyd-Steinberg
error diffusion (\fB-floyd\fP or \fB-fs\fP).
.PP
Also available are simple thresholding (\fB-threshold\fP); Bayer's
ordered dither (\fB-dither8\fP) with a 16x16 matrix;
.UR http://www.tinrocket.com/projects/programming/graphics/00158/
 Atkinson
.UE
\&; and three different sizes of 45-degree clustered-dot
dither (\fB-cluster3\fP, \fB-cluster4\fP, \fB-cluster8\fP).
.PP
A space filling curve halftoning method using the Hilbert curve is
also available (\fB-hilbert\fP).
.PP
Floyd-Steinberg or Atkinson will almost always give the best
looking results; however, looking good is not always what you want.
For instance, you can use thresholding in a pipeline with the
\fBpnmconvol\fP, for tasks such as edge and peak detection.  And
clustered-dot dithering gives a newspaper-ish look, a useful special
effect.
.PP
Floyd-Steinberg is by far the more traditional, but
.UR http://www.tinrocket.com/projects/programming/graphics/00158/
 some claim
.UE
\& Atkinson works better.
.PP
The Hilbert curve method is useful for processing images before
display on devices that do not render individual pixels distinctly
(like laser printers).  This dithering method can give better results
than the dithering usually done by the laser printers themselves.  The
\fB-clump\fP option alters the number of pixels in a clump.  Typically a PGM
image will have to be scaled to fit on a laser printer page (2400 x 3000
pixels for an A4 300 dpi page), and then dithered to a PBM image before being
converted to a postscript file.  A printing pipeline might look something
like:

.nf
    pamscale -xysize 2400 3000 image.pgm | pamditherbw -hilbert |  \e
      pamtopnm | pnmtops -scale 0.25 > image.ps 

.fi

.UN otheropts
.SS Other Options



.TP
\fB-value\fP
This option alters the thresholding value for Floyd-Steinberg,
Atkinson, and simple thresholding.  It should be a real number between
0 and 1.  Above 0.5 means darker images; below 0.5 means lighter.

.TP
\fB-clump\fP
This option alters the number of pixels in a clump when the
Hilbert curve method is used.  This is usually an integer between 2
and 100 (default 5).  Smaller clump sizes smear the image less and are
less grainy, but seem to lose some grey scale linearity.

.TP
\fB-randomseed=\fP\fIinteger\fP
The Floyd-Steiberg and Atkinson methods use random numbers to
diffuse the error.  This is the seed for the random number generator.
The other methods do not employ random numbers and ignore this option.
.sp
Use this to ensure you get the same image on separate invocations.
.sp
By default, \fBpamditherbw\fP uses a seed derived from the time of day
and process ID, which gives you fairly uncorrelated results in multiple
invocations.
.sp
This option was new in Netpbm 10.45 (December 2008).




.UN references
.SH REFERENCES
.PP
The only reference you need for this stuff is "Digital
Halftoning" by Robert Ulichney, MIT Press, ISBN 0-262-21009-6.
.PP
The Hilbert curve space filling method is taken from "Digital
Halftoning with Space Filling Curves" by Luiz Velho, Computer
Graphics Volume 25, Number 4, proceedings of SIGRAPH '91, page
81. ISBN 0-89791-436-8

.UN seealso
.SH SEE ALSO
.BR "pamtopnm" (1)\c
\&,
.BR "pgmtopgm" (1)\c
\&,
.BR "pbmtopgm" (1)\c
\&,
.BR "pamthreshold" (1)\c
\&,
.BR "pbmreduce" (1)\c
\&,
.BR "pnmconvol" (1)\c
\&,
.BR "pamscale" (1)\c
\&,
.BR "pam" (1)\c
\&,
.BR "pnm" (1)\c
\&,

.UN history
.SH HISTORY
.PP
\fBpamditherbw\fP was new in Netpbm 10.23 (July 2004), but is
essentially the same program as \fBpgmtopbm\fP that has existed
practically since the beginning.  \fBpamditherbw\fP differs from its
predecessor in that it properly adds brightnesses (using gamma
transformations; \fBpgmtopbm\fP just adds them linearly) and that it
accepts PAM input in addition to PGM and PBM and produces PAM output.
.PP
\fBpamditherbw\fP obsoletes \fBpgmtopbm\fP.
.PP
\fB-atkinson\fP was new in Netpbm 10.38 (March 2007).

.UN author
.SH AUTHOR

Copyright (C) 1989 by Jef Poskanzer.
.SH DOCUMENT SOURCE
This manual page was generated by the Netpbm tool 'makeman' from HTML
source.  The master documentation is at
.IP
.B http://netpbm.sourceforge.net/doc/pamditherbw.html
.PP