1
2mkbitmap(1) General Commands Manual mkbitmap(1)
3
4
5
7 mkbitmap - transform images into bitmaps with scaling and filtering
8
10 mkbitmap [options] [filename...]
11
13 mkbitmap reads an image, and applies one or more of the following oper‐
14 ations to it, in this order: inversion, highpass filtering, scaling,
15 and thresholding. Each operation can be individually controlled and
16 turned on or off.
17
18 The principal use of mkbitmap is to convert color or greyscale images
19 into a format suitable as input for other programs, particularly the
20 tracing program potrace(1). It is particularly useful for converting
21 scanned line art, such as cartoons, handwritten text, etc., to high-
22 resolution bilevel images.
23
24 Highpass filtering can be used to ensure that foreground features such
25 as lines and text are preserved, while at the same time compensating
26 for uneven background. Optional blurring can be applied to smooth out
27 the image and remove visual noise. Scaling is important because a
28 scanned greyscale image contains more visual detail than a bilevel
29 image at the same resolution. By scaling the image to a higher resolu‐
30 tion (using interpolation) before thresholding it, some of this detail
31 is preserved. Thresholding means converting a greyscale image to a
32 bilevel image using only black and white pixels. Pixels that are darker
33 than a certain threshold value are converted to black. Optional inver‐
34 sion is useful if the input image shows bright features on dark back‐
35 ground, such as a picture of chalk drawings on a blackboard.
36
37 Supported input formats are PNM (PBM, PGM, PPM) and BMP. The output
38 formats are PBM for bitmaps, and PGM for greymaps.
39
41 General options:
42 -h, --help print help message and exit.
43
44 -v, --version print version info and exit.
45
46 -l, --license print license info and exit.
47
48 Input/output options:
49 filename If filename arguments are given, then mkbitmap will by
50 default create one output file for each input filename
51 given. The name of the output file is obtained from the
52 input filename by changing its suffix to ".pbm" or
53 ".pgm". If the name of the input file and output file
54 would be identical, then an additional suffix "-out" is
55 appended to the output filename. If no filename argu‐
56 ments are given, then mkbitmap acts as a filter, reading
57 from standard input and writing to standard output. A
58 filename of "-" may be given to specify reading from
59 standard input; the output for this argument will then
60 be written to standard output. Each input file may con‐
61 tain one or more images.
62
63 -o filename, --output filename
64 write output to this file. All output is concatenated
65 and directed to the specified file. This overrides the
66 default behavior of creating one output file for each
67 input file. A filename of "-" may be given to specify
68 writing to standard output.
69
70 Image processing options:
71 -x, --nodefaults
72 Turn off default options. Normally, the following
73 options are preselected by default: -f 4 -s 2 -3 -t
74 0.45. The -x option disables these defaults; thus,
75 mkbitmap -x does nothing but copy a greyscale image from
76 the input to the output. Other processing options can
77 then be added one by one; e.g., mkbitmap -xf10 does only
78 highpass filtering, mkbitmap -xt0.5 does only threshold‐
79 ing, etc.
80
81 -i, --invert Invert the input image. If this option is chosen, it is
82 applied to the image before any other operation. It is
83 used to deal with white-on-black images, such as photo‐
84 graphs of chalk drawings on a blackboard. Note that the
85 behavior of this option is not in general the same as
86 inverting the output bitmap, unless the thresholding
87 value is also inverted.
88
89 -f n, --filter n
90 Apply a highpass filter to the image. This filter is
91 approximately Gaussian and non-directional. The effect
92 is to preserve small detail while compensating for back‐
93 ground gradients. The parameter n is a radius (in pix‐
94 els) which corresponds approximately to the size of
95 details which should be preserved. More precisely, the
96 filter is implemented by subtracting a blurred version
97 of the image from the original image. The parameter n is
98 equal to the standard deviation of the blur. The output
99 of the filtering step is a normalized image whose aver‐
100 age brightness is exactly 0.5. The default filter radius
101 is 4.
102
103 -n, --nofilter Turn off highpass filtering.
104
105 -b n, --blur n Blur the image. The effect is to smooth out fine details
106 and to reduce visual noise in the image. The parameter n
107 is the blurring radius, and should be chosen small (1 is
108 a good value to start with). This is implemented as an
109 approximately Gaussian, non-directional blur with stan‐
110 dard deviation proportional to n. Blurring is applied
111 after the highpass filter, but before scaling and
112 thresholding. If this option is not given, the default
113 is not to apply any blurring.
114
115 -s n, --scale n
116 Scale the image by an integer factor n>0. Scaling is
117 done after highpass filtering, but before the threshold‐
118 ing step. A scaling factor of 1 indicates that no scal‐
119 ing is to be done. Otherwise, interpolation is used to
120 fill in the in-between pixels. If the output of mkbitmap
121 is to be used as input to a tracing program such as
122 potrace, a scaling factor of 2 is recommended. This pre‐
123 served the right amount of detail for the tracing algo‐
124 rithm to work well. If a scaling factor of 1 is used,
125 too much detail is lost. If a scaling factor of 3 or
126 higher is used, the interpolation tends to "invent"
127 detail which was not present in the original image, thus
128 preventing potrace from doing a good job.
129
130 -1, --linear Use linear interpolation when scaling to a higher reso‐
131 lution. This is slightly faster, but less nice, than the
132 default cubic interpolation.
133
134 -3, --cubic Use cubic interpolation when scaling to a higher resolu‐
135 tion. This is the default. It is slower than linear
136 interpolation, but leads to better results.
137
138 -t n, --threshold n
139 Set the threshold grey value for bilevel conversion. The
140 parameter n is a brightness value between 0 for black
141 and 1 for white. Any pixels below this brightness will
142 be converted to black (thus, smaller values of n will
143 lead to whiter output).
144
145 -g, --grey Disable bilevel conversion. If this option is given,
146 processing stops after the scaling step and a greymap is
147 output.
148
150 The exit status is 0 on successful completion, 1 if the command line
151 was invalid, and 2 on any other error.
152
154 1.10
155
157 Peter Selinger <selinger at users.sourceforge.net>
158
160 mkbitmap is distributed as part of the potrace package, and the latest
161 version is available from http://potrace.sourceforge.net/. This site
162 also contains documentation and information on how to obtain support.
163
165 potrace(1)
166
168 Copyright (C) 2001-2011 Peter Selinger
169
170 This program is free software; you can redistribute it and/or modify it
171 under the terms of the GNU General Public License as published by the
172 Free Software Foundation; either version 2 of the License, or (at your
173 option) any later version.
174
175 This program is distributed in the hope that it will be useful, but
176 WITHOUT ANY WARRANTY; without even the implied warranty of MER‐
177 CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
178 Public License for more details.
179
180 You should have received a copy of the GNU General Public License along
181 with this program; if not, write to the Free Software Foundation, Inc.,
182 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. See also
183 http://www.gnu.org/.
184
185
186
187Version 1.10 August 2011 mkbitmap(1)