Image file formats
Mini-course at ICERM
Arnaud Chéritat
Basic notions on image file formats on computers.
November 25th and 27th, 2019
Bitmap vs Vector
There are two main kinds of images:
Bitmap = usually a rectangular array of square pixels.
pixel = PICture ELement
On very rare occasions the pixels are rectangles.
Each pixel receives a color.
Show bird image and zoom on it.
On the vast majority of images, colors are coded by triples of bytes, one for each channel
- R: red
- G: green
- B: blue
- A: alpha
1 byte = 8 bits
Here each byte is interpreted an unsigned integer from 00000000b = 0 to 11111111b = 28−1 = 255
With this system a pixel can take 2563~16 million different colors.
Inspect with Gimp some pixels in the bird image.
Bit depth
28 = 256
The R,G, and B channels are usually encoded each on 8 bits.
212 = 4 096
Higher color definition devices go up to a bit depth of 12bpc (bits per channel).
Several formats (including BMP, PNG and JPEG 2000) allow for a bit depth > 8.
216 = 65 536
Image processing software often internally encode the channel on 16 bits to avoid quantization effects due to the poor grain of 8 bits (1/256th opposed to 1/65 536th). Or better: some use floats (example: recent feature of GIMP). This leads to…
High dynamic range images
Inspect with Gimp an HDR image.
Paletted images
Some image formats use palettes. For instance a non-animated GIF image has a palette of up to 256 colors. The palette is stored at the beginning of the file. Each color in the palette is encoded on 3 bytes, one for each channel R, G and B.
Each pixel is encoded on one byte, the index of its color in the palette.
Inspect a GIF with Gimp.
Note: PNG also have a palette option.