The READ_PPM procedure reads the contents of a PGM (gray scale) or PPM (portable pixmap for color) format image file and returns the image in the form of a 2-D byte array (for grayscale images) or a (3, n, m) byte array (for TrueColor images).
Files to be read should adhere to the PGM/PPM standard. The following file types are supported: P2 (graymap ASCII), P5 (graymap RAWBITS), P3 (TrueColor ASCII pixmaps), and P6 (TrueColor RAWBITS pixmaps). Maximum pixel values are limited to 255. Images are always stored with the top row first.
PPM/PGM format is supported by the PBMPLUS toolkit for converting various image formats to and from portable formats, and by the Netpbm package.
This routine is written in the IDL language. Its source code can be found in the file read_ppm.pro in the lib subdirectory of the IDL distribution.
Note: To find information about a potential PPM file before trying to read its data, use the QUERY_PPM function.
To open and read the PGM image file named “foo.pgm” in the current directory and store the image in the variable IMAGE1:
READ_PPM, 'foo.pgm', IMAGE1
READ_PPM, Filename, Image [, MAXVAL=variable]
A scalar string specifying the full path name of the PGM or PPM file to read.
A named variable that will contain the image. For grayscale images, Image is a 2-D byte array. For TrueColor images, Image is a (3, n, m) byte array.
A named variable that will contain the maximum pixel value.
IOPEN, WRITE_PPM, QUERY_PPM