Skip to main content

Indexed image pixel colours

Short answer

Look up the index at each pixel in the image, then its RGB in the colour table. (0,2) index 0 → green; (1,1) index 2 → blue; (1,3) index 5 → grey; (2,1) index 6 → magenta; (2,2) index 4 → yellow; (3,0) index 2 → blue.

The table on the left below represents an indexed image (rows and columns numbered 0 to 3). The table on the right is the colour index table. What is the colour of the following pixels: (0,2), (1,1), (1,3), (2,1), (2,2), (3,0).

Indexed image:

0123
02303
17215
25644
32750

Colour index table:

IndexRGB
002550
125500
200255
3000
42552550
5127127127
62550255
7255255255

An indexed image stores, for each pixel, only an index number. The actual colour (R, G, B) is found by looking up that index in the colour index table (palette).

Convention used: a pixel (r, c) means row r, column c, both counted from 0, as the question labels rows and columns.

Step 1: find the index at each pixel

Pixel (row, col)Index in image
(0,2)0
(1,1)2
(1,3)5
(2,1)6
(2,2)4
(3,0)2

Step 2: look up each index in the colour table

PixelIndex(R, G, B)Colour
(0,2)0(0, 255, 0)Green
(1,1)2(0, 0, 255)Blue
(1,3)5(127, 127, 127)Grey
(2,1)6(255, 0, 255)Magenta
(2,2)4(255, 255, 0)Yellow
(3,0)2(0, 0, 255)Blue

Answer: (0,2) green, (1,1) blue, (1,3) grey, (2,1) magenta, (2,2) yellow, (3,0) blue.

Storage note: with 8 colours, each pixel needs only 3 bits, instead of 24 bits for direct RGB. This is why indexed images are small.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Multimedia System chapter 3 questions →