Solution
To read a PGM file in LabVIEW, you need to use the Read Binary File.vi.
The header format is as described below:
P5
<width> <height>
<maximum grey value>
For an 8-bit image of size 320x240 the header would look like the following:
P5
320 240
255 This header is followed by an array of pixel values corresponding to the image. If the maximum gray value is less than 256 then each pixel is represented by 1-byte. Otherwise, it uses 2-bytes.
Attached below is an image on how to use the Read from Binary File.vi to read the image information as a 2D array of integer values. Alternatively, this 2D array of integers could be converted to an image data-type using the IMAQ ArrayToImage.vi.