-->

Previous | Table of Contents | Next

Page 391

Edge Enhancement. (-0.1 > = alpha > = -0.9)

This is the opposite type of filter to the smoothing filter. It enhances edges. The alpha parameter controls the amount of edge enhancement, from subtle (-0.1) to blatant (-0.9). The radius parameter controls the effective radius as usual, but useful values are between 0.5 and 0.9. Try starting with values of alpha = 0.3, radius = 0.8.

COMBINATION USE

The various modes of pnmnlfilt can be used one after the other to get the desired result. For instance to turn a monochrome dithered image into a grayscale image, you could try one or two passes of the smoothing filter, followed by a pass of the optimal estimation filter, then some subtle edge enhancement. Note that using edge enhancement is only likely to be useful after one of the nonlinear filters (alpha-trimmed mean or optimal estimation filter), as edge enhancement is the direct opposite of smoothing.

For reducing color quantization noise in images (that is, turning GIF files back into 24-bit files), you could try a pass of the optimal estimation filter (alpha 1.2, radius 1.0), a pass of the median filter (alpha 0.5, radius 0.55), and possibly a pass of the edge enhancement filter. Several passes of the optimal estimation filter with declining alpha values are more effective than a single pass with a large alpha value. As usual, there is a tradeoff between filtering effectiveness and loosing detail. Experimentation is encouraged.

REFERENCES

The alpha-trimmed mean filter is based on the description in IEEE CG&A, May 1990, page 23, by Mark E. Lee and Richard A. Redner, and has been enhanced to allow continuous alpha adjustment.

The optimal estimation filter is taken from an article "Converting Dithered Images Back to Grayscale" by Allen Stenger, Dr. Dobb's Journal, November 1992, and this article references "Digital Image Enhancement and Noise Filtering by Use of Local Statistics" by Jong-Sen Lee, IEEE Transactions on Pattern Analysis and Machine Intelligence, March 1980.

The edge enhancement details are from pgmenhance(1), which is taken from Philip R. Thompson's xim program, which in turn took it from Section 6 of "Digital Halftones by Dot Diffusion" by D. E. Knuth, ACM Transaction on Graphics Vol. 6, No. 4, October 1987, which in turn got it from two 1976 papers by J. F. Jarvis et al.

SEE ALSO

pgmenhance(1), pnmconvol(1), pnm(5)

BUGS

Integers and tables may overflow if PPM_MAXMAXVAL is greater than 255.

AUTHOR

Graeme W. Gill (graeme@labtam.oz.au).

5 February 1993

pnmnoraw

pnmnoraw—Force a portable anymap into plain format

SYNOPSIS


pnmnoraw [pnmfile]

DESCRIPTION

pnmnoraw reads a portable anymap as input and writes it out in plain (nonraw) format. This is fairly useless if you haven't defined the PBMPLUS_RAWBITS compile-time option.

Page 392

SEE ALSO

pnm(5)

AUTHOR

Copyright " 1991 by Jef Poskanzer.

8 January 1991

pnmpad

pnmpad—Add borders to portable anymap

SYNOPSIS


pnmpad [-white|-black] [-l#] [-r#] [-t#] [-b#] [pnmfile]

DESCRIPTION

pnmpad reads a portable anymap as input and outputs a portable anymap with extra borders of the sizes specified. The color of the borders can be set to black or white (default black).

SEE ALSO

pbmmake(1), pnmpaste(1), pbm(5)

AUTHOR

Copyright " 1990 by Angus Duggan. Copyright " 1989 by Jef Poskanzer.

pnmpaste

pnmpaste—Paste a rectangle into a portable anymap

SYNOPSIS


pnmpaste [-replace|-or|-and |-xor] frompnmfile x y [intopnmfile]

DESCRIPTION

pnmpaste reads two portable anymaps as input, inserts the first anymap into the second at the specified location, and produces a portable anymap the same size as the second as output. If the second anymap is not specified, it is read from stdin. The x and y can be negative, in which case they are interpreted relative to the right and bottom of the anymap, respectively.

This tool is most useful in combination with pnmcut. For instance, if you want to edit a small segment of a large image, and your image editor cannot edit the large image, you can cut out the segment you are interested in, edit it, and then paste it back in.

Another useful companion tool is pbmmask.

The optional flag specifies the operation to use when doing the paste. The default is -replace. The other logical operations are only allowed if both input images are bitmaps. These operations act as if white is TRUE and black is FALSE.

All flags can be abbreviated to their shortest unique prefix.

SEE ALSO


pnmcut(1), pnminvert(1), pnmarith(1), pnm(5),

pbmmask(1)

Page 393

AUTHOR

Copyright " 1989, 1991 by Jef Poskanzer.

21 February 1991

pnmrotate

pnmrotate—Rotate a portable anymap by some angle

SYNOPSIS


pnmrotate [-noantialias] angle [pnmfile]

DESCRIPTION

pnmrotate reads a portable anymap as input, rotates it by the specified angle, and produces a portable anymap as output. If the input file is in color, the output will be, too; otherwise, it will be grayscale. The angle is in degrees (floating-point), measured counter-clockwise. It can be negative, but it should be between -90 and 90. Also, for rotations greater than 45 degrees you may get better results if you first use pnmflip to do a 90-degree rotation and then pnmrotate less than 45 degrees back the other direction.

The rotation algorithm is Alan Paeth's three-shear method. Each shear is implemented by looping over the source pixels and distributing fractions to each of the destination pixels. This has an antialiasing effect—it avoids jagged edges and similar artifacts. However, it also means that the original colors or gray levels in the image are modified. If you need to keep precisely the same set of colors, you can use the -noantialias flag. This does the shearing by moving pixels without changing their values. If you want antialiasing and don't care about the precise colors, but still need a limited *number* of colors, you can run the result through ppmquant.

All flags can be abbreviated to their shortest unique prefix.

REFERENCES

"A Fast Algorithm for General Raster Rotation" by Alan Paeth, Graphics Interface '86, pages 77_81.

SEE ALSO


pnmshear(1), pnmflip(1), pnm(5), ppmquant(1)

AUTHOR

Copyright " 1989, 1991 by Jef Poskanzer.

12 January 1991

pnmscale

pnmscale—Scale a portable anymap

SYNOPSIS


pnmscale s [pnmfile]

pnmscale -xsize|-width|-ysize| -height s [pnmfile]

pnmscale -xscale|-yscale s [pnmfile]

pnmscale -xscale|-xsize|-width s -yscale|-ysize|-height s [pnmfile]

pnmscale -xysize x y [pnmfile]

pnmscale _pixels n [pnmfile]

Previous | Table of Contents | Next