Additional data in the image (PPM / PAM / PNM)

Is it possible to store additional data in pixels of a binary PNM file so that it can be read as an image (I hope, by any decoder, but specifically using ffmpeg)?

I have a simulation that saves its data as PPM at the moment, and I would like to write more than three values ​​per pixel in the file and still be able to use it as an image (obviously, only the first three / four values ​​will actually affect per image).

In particles, I think that TUPLTYPE PAM should allow me to do this, but I don’t know how to do something that is also a readable image.

+4
source share
2 answers

There are two tricks that together can get up to 5 extra bytes per pixel in a PAM file.

The first trick:

You can try to save an extra byte of information in the alpha channel, and then choose to ignore this information in the decoder. Turning on the alpha channel in PAM is done by adding an argument _APLHAto TUPLTYPE, so instead TUPLTYPE RGByou have TUPLTYPE RGB_ALPHA.

The second trick:

MAXVAL PAM ( PPM ) 65535 255, , 16- 8- . 16- 8 , , .

+ :

3 x 8 = 24 RGB- 16 -. : 5 .

+1

PNM , .bmp.

, . 0 1 (00000000 00000001), 254 255 (1111110 11111111). 8 (6 , ). . , , .

, /, , 50, 123, 32... 0-255 ( 256 , ) ( 32 ), .

+1

Source: https://habr.com/ru/post/1540241/


All Articles