PGMA Files
Portable Gray Map (ASCII)
PGMA is the ASCII portable gray map format. It is a simple
grayscale image description. The definition is as follows:
-
the typical file extension is ".pgm", but an extension of
".pnm" is also occasionally used.
-
A "magic number" for identifying the file type. An
ASCII PGM file's magic
number is the two characters "P2".
-
Whitespace (blanks, TABs, CRs, LFs).
-
A width, formatted as ASCII characters in decimal.
-
Whitespace.
-
A height, again in ASCII decimal.
-
Whitespace.
-
The maximum gray value, again in ASCII decimal.
-
Whitespace.
-
Width * height gray values, each in ASCII decimal, between 0 and the
specified maximum value, separated by whitespace, starting at the
top-left corner of the graymap, proceeding in normal English
reading order.
A value of 0 means black, and the maximum value means white.
Characters from a "#" to the next end-of-line are ignored (comments).
No line should be longer than 70 characters.
Example PGMA file:
P2
# feep.pgma
24 7
15
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0
0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0
0 3 3 3 0 0 0 7 7 7 0 0 0 11 11 11 0 0 0 15 15 15 15 0
0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0
0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
PGMA File Characteristics:
-
ASCII
-
Gray
-
2D
-
No compression
-
1 image
Related Data and Programs:
PBMA
is a data directory which
describes ASCII Portable Bit Map files.
PGMB
is a data directory which
describes binary Portable Gray Map files.
PPMA
is a data directory which
describes ASCII Portable Pixel Map files.
Reference:
-
the NETPBM homepage.
Programs to create a PGMA file:
-
The gnuplot
command "set terminal pbm gray" will cause the graphics
information to be written to a PGM file.
Programs and routines to read a PGMA file:
-
MATLAB can read a PGMA
file with a command like A=imread('file','PGM').
-
pgma_io
a set of C++ routines;
-
pgma_io
a set of FORTRAN90 routines;
-
pgma_io,
a set of MATLAB functions.
-
The Visual Toolkit
routine vtkPNMReader can read an ASCII PGM file into VTK.
Programs and routines to write a PGMA file:
-
MATLAB can write a PGMA
file with a command like imwrite(a,'filename','PGM').
-
pgma_io
a set of C++ routines;
-
pgma_io
a set of FORTRAN90 routines;
-
pgma_io,
a set of MATLAB functions.
-
The Visual Toolkit
routine vtkPNMWriter can write a VTK
image to an ASCII PGM file.
Programs to view a PGMA file include:
Programs to convert a PGMA file to another format:
-
cjpeg can convert a
PGM file to JPEG format.
-
convert, a program that is part of
ImageMagick,
can convert a PGMA file to
BMP, CGM, EPS, FIG, FITS, GIF, JPG, PBM, PDF, PGM, PNG, PNM,
PPM, PS, RGB, TIF, XBM or XPM format.
-
GIMP,
the GNU Image Manipulation Program,
can read a PGMA file and write out a copy in a variety of formats.
-
PGMA_TO_PGMB
is a C++ program which can convert a PGMA file to
PGMB format.
-
The
NETPBM
program PGMTOFITS converts a PGMA file to FITS format.
-
xv can read a PGMA file
and write out a copy in BMP, FIT, GIF, JPG, PBM, PPM, RGB or TIF
format.
Programs to convert a file to PGMA format:
-
convert, a program supplied with
ImageMagick,
can convert a
BMP, CGM, EPS, FIG, FITS, GIF, JPG, PBM, PDF, PGM, PNG, PNM,
PPM, PS, RGB, TIF, XBM or XPM file to PGMA format.
However,
to force the ASCII format, you must include the switch
"-compress none".
-
djpeg
converts a JPEG file to PGMA format.
-
GIMP,
the GNU Image Manipulation Program, can read a file in a
variety of formats, and write it out as a PGMA file.
-
The
NETPBM
program FITSTOPGM converts a FITS file to PGMA format.
-
PGMB_TO_PGMA
is a C++ program which can convert a
PGMB file
to PGMA format.
-
xv can read a file in a
BMP, FIT, GIF, JPG, PBM, PPM, RGB or TIF format, and write it out
as a PGMA file.
Sample PGMA files:
You can go up one level to
the DATA page.
Last revised on 05 September 2006.