Frage

Maybe it's a weird question but I'm little confused why PPM6 is smaller than PPM3. According to wiki, in PPM3, each pixel is represented as 3 bytes

P3
# The P3 means colors are in ASCII, then 3 columns and 2 rows,
# then 255 for max color, then RGB triplets
3 2
255
255   0   0     0 255   0     0   0 255
255 255   0   255 255 255     0   0   0

further they say that P6 binary format of the same image represents each color component of each pixel with one byte (thus THREE bytes per pixel). The file is smaller but the color information is not readable by humans.

I don't understand why P6 is smaller if in both cases each pixel is represented with 3 bytes?

War es hilfreich?

Lösung

Don't confuse your source data with what actually gets written to a file.

PPM3 is not represented by 3 bytes per pixel. Well, not in the stored form. You store them as text files. 3 digits (255 for example) stored as text is 3 bytes (a byte per character). Not 1. And I'm not even regarding the white space there.

PPM6 is stored as binary with indeed 3 bytes per pixel. It will therefore always be smaller.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top