NETPBM EXTENSIONS ================= PPMLABEL -- Draw Text in a PPM CIE Colour Chart Generator Histogram Equalisation for Anymaps ASCII Text Rendering for PPMDRAW by John Walker http://www.fourmilab.ch/ This directory contains additions to the 1 March 1994 Netpbm distribution which implement three separate features. They are supplied in two separate archives, available by anonymous FTP from: ftp://ftp.fourmilab.ch/pub/web/netpbm ppm.shar.gz - PPM directory additions: Makefile, README, cietoppm.1, cietoppm.c, libppm6.c, ppmdraw.h, ppmlabel.1, ppmlabel.c, ppmdtexttest.c pnm.shar.gz - PNM directory additions: Makefile, pnmhisteq.c, pnmhisteq.1 These are Unix "shar" archives, compressed with GZIP. PPM DIRECTORY ============= Text Rendering for ppmdraw Files: ppmdraw.h libppm6.c -------------------------- -------------------------- I find the ppmdraw functions extremely handy for image generation, but have long wanted the ability to include ASCII text annotations. When I developed cietoppm.c (see below), this capability was essential, so I added it. I added the following two new function definitions to ppmdraw.h: void ppmd_text(pixel** pixels, int cols, int rows, pixval maxval, int x, int y, int height, int angle, char *s, void (*drawprocP)(pixel**, int, int, pixval, int, int, char*), char* clientdata); Draws the null-terminated string s left justified at the point (x, y). The text will be height pixels high and aligned on a baseline inclined angle degrees to the X axis. The supplied drawproc and clientdata are passed to ppmd_line() which performs the actual drawing. void ppmd_text_box(int height, int angle, char *s, int *left, int *top, int *right, int *bottom); Calculates the extents box for text drawn by ppm_text with the given string, size, and orientation. Most extent box calculations should use an angle specification of zero to calculate the unrotated box enclosing the text. If you need the extents of rotated text, however, you can call ppmd_text_box with a nonzero angle. These functions are implemented in the new library module libppm6.c. I made this a separate file instead of adding the functions to libppm5.c for two reasons: first, to avoid pulling in the relatively large amount of static data (the font definition) unless the user calls the text functions and, second, to reduce integration hassles. ppmd_text draws text using a built-in stroke font derived from the public domain Hershey plotter font set. The single-stroke Roman font is used, which looks good over a relatively large magnification range but is reasonably compact in definition. Since the font is scaled and rotated in the vector domain then rendered with calls to ppmd_line, the ugliness of transformed bitmap fonts is avoided. In order to avoid programs which call ppmd_text being forced into MATHBINARIES, ppmd_text calculates the sine and cosine needed to rotate the text by table lookup. It does all its calculation using scaled integers and, in fact, doesn't use any floating point at all. Draw text in portable pixmap Files: ppmlabel.c ppmlabel.1 ---------------------------- ---------------------------- This program uses ppmd_text to draw text in a portable pixmap. The position, size, angle, and text and optional background colour of one or more text strings are given by command line arguments. Text can be specified on the command line or read from files. Text Rendering test program File: ppmdtexttest.c --------------------------- -------------------- This is not an addition to PBMPLUS; it's just a sample program that exercises ppmd_text and ppmd_text_box and illustrates text at various sizes, rotations, and justifications. CIE Colour chart to PPM Files: cietoppm.c cietoppm.1 ----------------------- ---------------------------- This program, which uses ppmd_text to generate the labels for the chart, creates a portable pixmap containing a CIE colour chart ("tongue diagram"), showing the colour gamut renderable with a variety of standard primary illuminants (NTSC, SMPTE, PAL/SECAM, HDTV, etc.) or a custom colour system specified on the command line in terms of the CIE X and Y coordinates of the illuminants and white point. See the man page cietoppm.1 for more details. The source code contains several handy routines and tables for folks interested in colour theory and transformations, including a table of the CIE spectral colour matching functions in 5 nanometre increments across the visual range, the spectral chromaticity coordinates for pure hues in the same range, a CIE XYZ to RGB converter, and functions to test whether a given hue is inside the gamut defined by three primaries and, if not, to constrain it to the closest renderable hue. There's also a black body chromaticity calculation directly from Planck's equation. Makefile File: Makefile -------- -------------- Just to avoid ambiguity, I've included a Makefile with the new programs added. cietoppm.c and ppmlabel.c are MATHBINARIES programs, but the others are not. PNM DIRECTORY ============= Histogram Equalisation Files: pnmhisteq.c pnmhisteq.1 ---------------------- ------------------------------ This filter implements contrast enhancement through the technique of histogram equalisation. A luminosity histogram is prepared from the input image, then pixel luminosities are adjusted to optimise the use of the available intensity range. You can save the calculated luminosity map as a PGM file, then subsequently use it to process other images; this allows using a consistent map when, for example, processing frames of an animation. Makefile File: Makefile -------- -------------- To avoid ambiguity, I've included a Makefile with pnmhisteq added.