Note: line breaks (\ n) are represented by character 10 of the ASCII code (0x0A)Ĭonsole.WriteLine("Enter name of file PGM") įileStream filePGM = File. The name of the file to be analyzed must be read from the command line, not prompted by the user or pre-set.
Right-click on the PGM file and go through 'Open with' > 'Choose default program'. You must create a program capable of reading a file in binary PGM format (header P5), without comments, with 255 shades of gray (but with a width and height that can vary). a) Select a program to open PGM files on Windows. In binary (P5) format, they are contiguous bytes, from 0 (black) to 255 (white). In ASCII format (P2) they are numbers from 0 to 255 separated by spaces and perhaps newlines. The second line contains the width and height, separated by a space.Ī third line contains the intensity value that corresponds to the target (typically 255, although it could also be 15 or another value).įrom there the colors (shades of gray) of the points that make up the image begin. Its header begins with a line containing P2 (if the image data is in ASCII) or P5 (if it is in binary). Specifically, it is the variant capable of handling images in shades of gray. The PGM format is one of the versions of NetPBM image formats.