PGM Image Processing in c++ is very easy just you have to know some basics structure of PGM file format.
P2
7 12
150
100 100 150 0 0 0 0
100 100 100 0 0 0 0
100 0 0 0 0 0 0
100 0 0 0 0 0 0
100 100 100 0 0 0 0
100 100 100 0 0 0 0
100 0 0 0 0 0 0
100 0 0 0 0 0 0
100 0 0 0 0 0 0
100 0 0 0 0 0 0
100 0 0 0 0 0 0
100 0 0 0 0 0 0
Line 1:
P2 is the magic two characters which tells that you are using PGM format
Line 2:
First integer 7 indicates column and 12 indicates row.
Line 3:
150 is the highest value used in the pixel.
Line 4-15:
These values represent each pixel of the image where 0 is black and 255 which could be the highest pixel value.In this Image it contains 12 rows and 7 columns which can be easily stored in Arrays for Image Processing