showcase/pbm2glyph/

A vectorization utility, converts black and white raster images to PostScript. Needed for the preparation of music fonts for the roemer engine.

This is an example input for pbm2glyph, designed in gimp for this showcase. But you can obtain similar raster images from a black and white scanner. A higher resolution is generally advisable, 600 DPI should be fine.

The first processing step is to read the bitmap and convert it to straight lines. This step is completely lossless, all information in the image is preserved. This is exactly what you get if you call pbm2glyph with the --pixels option.

In the second step, all short lines (shorter than 2.5 pixels) are collapsed to their midpoints. The result is already quite an improvement. If this is good enough for you, give the option --straight to pbm2glyph. The output then uses the PostScript command lineto for straight lines.

In default mode, pbm2glyph proceeds to make some cubic bezier curves with a try and error algorithm. It repeatedly tries to join neighbouring lines to curves with as small an error as possible. The output uses the PostScript command curveto.

With the option --debug, pbm2glyph produces line graphics with red dots for the end points of segments, like above.

In the end, the EPS output from pbm2glyph looks somewhat like below. Because it is standard PostScript, you can use ghostview to look at it, or you can send it directly to your laser printer. If you're curious how the PostScript can be turned back into raster graphics most easily, have a look at glyph2pgm.

%!PS-Adobe-2.0 EPSF-2.0
%%Name: minim
%%BoundingBox: -66 -50 66 50
%%EndComments
-34.62 -34.62 moveto
1 -33.98 36.66 -3.17 34.62 34.62 curveto
-1 33.98 -36.66 3.17 -34.62 -34.62 curveto
-42.3 -38.46 moveto
-69.91 -21.26 -67.22 21.04 -42.3 38.46 curveto
-15.98 49.96 15.89 49.47 42.3 38.46 curveto
67.22 21.04 69.91 -21.26 42.3 -38.46 curveto
15.98 -49.96 -15.89 -49.47 -42.3 -38.46 curveto
fill
showpage