Subject: Re: .pgm file (WhatIsIt?)

From: [email-masked] (Ferdinand Che)
Date: Sat, 18 Jun 94 10:25:28 GMT

In article <[email-masked]> [email-masked] writes:
>
>	I am trying to implement the Canny code and need to know the specs of the .pgm file format. Binary? unsigned characters? header? etc..  I'll be converting some of our files so I need to know the exact contents of the header (byte by byte)
>	Thanks in advance.
>							Cale Brownstead
>							Applied Research Lab
>							Penn State University
>						        IA: [email-masked]

Check the "man page" for pgm (if you are using a unix machine), and
you are more than likely to find the above information. Otherwise, the
following is an edited version of it: 

pgm(5)                    FILE FORMATS                     pgm(5)

NAME
     pgm - portable graymap file format

DESCRIPTION
     The portable graymap format is a lowest  common  denominator
     grayscale file format.  The definition is as follows:

     - A "magic number" for identifying the  file  type.   A  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 whi-
       tespace, 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.

			....end....

You will find that the first two characters "P2" of the header are for
pgm raw files. For pgm ascii decimal files these two charcters become
"P3". 

Hope that helps you.

Ferdinand

--
	****  Electronics Laboratory, University of Kent at Canterbury	****
	****  Kent CT2 7NX, Tel: 0227 - 764000 (days)			****
	****	or 0227 - 763902 (evenings) ext 3718 / 3192 		****
	****			Fax: 0227-456084			****