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
Licensing:
The computer code and data files described and made available on this web page
are distributed under
the GNU LGPL license.
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:
-
baboon.ascii.pgm, a 512 by 512 image of
a baboon.
-
baboon.png, a PNG image.
-
balloons.ascii.pgm, a 640x480 image of
a couple, with balloons.
-
balloons.png, a PNG image.
-
barbara.ascii.pgm, a 512x512 image
-
barbara.png, a PNG image.
-
body1.ascii.pgm
-
body1.png, a PNG image.
-
body2.ascii.pgm
-
body2.png, a PNG image.
-
body3.ascii.pgm
-
body3.png, a PNG image.
-
brain_398.ascii.pgm
-
brain_398.png, a PNG image.
-
brain_492.ascii.pgm
-
brain_492.png, a PNG image.
-
brain_508.ascii.pgm
-
brain_508.png, a PNG image.
-
brain_604.ascii.pgm
-
brain_604.png, a PNG image.
-
columns.ascii.pgm, a 640x480 image of
a person standing by some columns;
-
columns.png, a PNG image.
-
f14.ascii.pgm
-
f14.png, a PNG image.
-
feep.ascii.pgm, a simple 7 by 24 example that
displays "FEEP" in block letters.
-
feep.png, a PNG image.
-
foliage.ascii.pgm
-
foliage.png, a PNG image.
-
-
, a PNG image.
-
-
, a PNG image.
-
hands.ascii.pgm
-
hands.png, a PNG image.
-
handsmat.ascii.pgm
-
handsmat.png, a PNG image.
-
lena.ascii.pgm a 512x512 image.
-
lena.png, a PNG image.
-
marcie.ascii.pgm
-
marcie.png, a PNG image.
-
mountain.ascii.pgm
-
mountain.png, a PNG image.
-
pbmlib.ascii.pgm, a 600x200 image
created by PBMLIB.
-
pbmlib.png, a PNG image.
-
saturn.ascii.pgm
-
saturn.png, a PNG image.
-
screws.ascii.pgm
-
screws.png, a PNG image.
-
surf.ascii.pgm
-
surf.png, a PNG image.
-
totem.ascii.pgm
-
totem.png, a PNG image.
-
tracks.ascii.pgm, a 300x200 image
that looks like tracks.
-
tracks.png, a PNG image.
-
venus1.ascii.pgm
-
venus1.png, a PNG image.
-
venus2.ascii.pgm
-
venus2.png, a PNG image.
-
x31_f18.ascii.pgm
-
x31_f18.png, a PNG image.
You can go up one level to
the DATA page.
Last revised on 22 September 2009.