Mapping RGB Triples Onto 16 Distinct Value
code | red | G | B |
0 | 0 | 0 | 0 |
1 | 0.5 | 0.5 | 0 |
2 | 0.5 | 0 | .5 |
3 | 1 | 0 | 0 |
4 | 0 | 0.5 | .5 |
5 | 0 | 1 | 0 |
6 | 0 | 0 | 1 |
7 | 0.33 | 0.33 | .33 |
8 | 0.66 | 0.66 | .66 |
9 | 1 | 1 | 0 |
10 | 1 | 0 | 1 |
11 | 1 | 0.5 | .5 |
12 | 0 | 1 | 1 |
13 | .5 | 1 | .5 |
14 | .5 | 0.5 | 1 |
15 | 1 | 1 | 1 |
from graphics gems II
struct rgb_color cc[] = { { 1 , 0 , 0 }, { 1 , 1 , 0 }, { 0 , 1 , 1 }, { 0 , 0 , 1 }, };
algorithm to fill in colormap
- subdivide
base pos | colormap pos | index |
0 | 0 | |
1 | 19.75 | |
2 | 39.5 | |
3 | 79 |
given an index, find the range and interpolate