What is PGM?
PGM is the greyscale member of the Netpbm family: a three-line header, then one brightness value per pixel with no compression. It is what image-processing courses, OCR pipelines and computer-vision tools pass around when they want a format with no decoder in the way.
What is BMP?
BMP is the Windows bitmap: pixel values written out with essentially no compression, which makes the files enormous and the format trivial to read. It survives in Windows tooling, embedded systems and anywhere a program wants image data without a decoder in front of it. Rows are stored bottom-up.