PPM file

Introduction

PPM (Portable Pixmap Format) is a simple image format that only contains information and image data such as format, image width and height, and number of bits.

If you open the .ppm file with txt, the content of the file will be as follows:

Insert picture description here

File classification and expansion

In addition to PPM, there are two related formats, PBM and PGM

P B M is a bitmap ( B itmap)
P G M is a grayscale ( G rayscale)
P P M is an image displayed through three colors of RGB ( P ixmaps)

They are distinguished by the header of the file

At the beginning of each image file, a magic number is used to indicate the type of file format (PBM, PGM, PPM), and the encoding method (ASCII or Binary)

Magic Number Type Encoding
P1 Bitmap ASCII
P2 Grayscale ASCII
P3 Pixmaps ASCII
P4 Bitmap Binary
P5 Grayscale Binary
P6 Pixmaps Binary

Encoding method: ASCII can be opened with a text editor to read the data of the corresponding image (such as RGB value in PPM format). Binary format is suitable for machine reading. The image information is stored sequentially in binary form, without space separation, so the image processing is more efficient and takes up less space (due to the lack of spaces).

For example

The content we entered is as follows. The
Insert picture description here
picture can be opened by the .ppm tool
Insert picture description here

Reference blog: https://blog.csdn.net/kinghzkingkkk/article/details/70226214

Guess you like

Origin blog.csdn.net/qq_43477024/article/details/111871570