- 2072 Asoj · 6 marks
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:
| 0 | 1 | 2 | 3 | |
|---|---|---|---|---|
| 0 | 2 | 3 | 0 | 3 |
| 1 | 7 | 2 | 1 | 5 |
| 2 | 5 | 6 | 4 | 4 |
| 3 | 2 | 7 | 5 | 0 |
Colour index table:
| Index | R | G | B |
|---|---|---|---|
| 0 | 0 | 255 | 0 |
| 1 | 255 | 0 | 0 |
| 2 | 0 | 0 | 255 |
| 3 | 0 | 0 | 0 |
| 4 | 255 | 255 | 0 |
| 5 | 127 | 127 | 127 |
| 6 | 255 | 0 | 255 |
| 7 | 255 | 255 | 255 |
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
| Pixel | Index | (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)
Related questions
- Fleming's right and left hand rules · Electrical Machine, chapter 1
- Left and right focal point ratios · Theory of Structures II, chapter 4
- Pixel access rate of raster system · Computer Graphics, chapter 1
- Resize image keeping aspect ratio · Computer Graphics, chapter 1