Contribution: Ramp.cs by Russell Plume in DotNet C#.
This note introduces the most commonly used colour ramps for mapping colours onto a range of scalar values as is often required in data visualisation. The colour space will be based upon the RGB system.
Grey Scale
The most basic mapping of some scalar value to a colour ramp is to use either an intensity ramp from black to a single colour or use the greyscale ramp from black to white. Black normally being the low end of the range of values, and white the high end. On the colour cube this is a diagonal line between the two opposite corners, the red, green, blue components are all the same.

The map from black to white is usually just a linear ramp, for a
value (v) which varies from vmin to vmax, the colour is
red = green = blue = (v - vmin) / (vmax - vmin)

The most commonly used colour ramp is often refer to as the "hot- to-cold" colour ramp. Blue is chosen for the low values, green for middle values, and red for the high as these seem "intuitive" bounds. One could ramp between these points on the colour cube but this involves moving diagonally across the faces of the cube. Instead we add the colours cyan and yellow so that the colour ramp only moves along the edges of the colour cube from blue to red. This not only makes the mapping easier and faster but introduces more colour variation. The following illustrates the path on the colour cube.

The colour ramp is shown below along with the transition values.

Again there is a linear relationship of the scalar value with colour within each of the 4 colour bands. In some applications the variable being represented with the colour map is circular in nature in which case a cyclic colour map is desirable. The above can be simply modified to pass through magenta to yield one of many possible circular colour maps.

A more general case ramps between N colours, each colour has a corresponding value within the range of values of the variable being mapped. The points within the colour cube can be linearly ramped between the points or the transition can be smoothed by some interpolation function such a bezier curve. For example a 3 colour ramp for terrain visualisation might choose 3 heights and three corresponding colours.

Displayed as a colour ramp

The resulting terrain map

C Source for the "standard" hot-to-cold colour ramp.
/*
Return a RGB colour value given a scalar v in the range [vmin,vmax]
In this case each colour component ranges from 0 (no contribution) to
1 (fully saturated), modifications for other ranges is trivial.
The colour is clipped at the end of the scales if v is outside
the range [vmin,vmax]
typedef struct {
double r,g,b;
} COLOUR;
*/
COLOUR GetColour(double v,double vmin,double vmax)
{
COLOUR c = {1.0,1.0,1.0}; // white
double dv;
if (v < vmin)
v = vmin;
if (v > vmax)
v = vmax;
dv = vmax - vmin;
if (v < (vmin + 0.25 * dv)) {
c.r = 0;
c.g = 4 * (v - vmin) / dv;
} else if (v < (vmin + 0.5 * dv)) {
c.r = 0;
c.b = 1 + 4 * (vmin + 0.25 * dv - v) / dv;
} else if (v < (vmin + 0.75 * dv)) {
c.r = 4 * (v - vmin - 0.5 * dv) / dv;
c.b = 0;
} else {
c.g = 1 + 4 * (vmin + 0.75 * dv - v) / dv;
c.b = 0;
}
return(c);
}
Note about gamma
Please note that the above are not corrected for the gamma of the display device. As such the colours may indeed appear different on different diaplays. The gamma of displays can be adjusted and typically have a power relationship, that is, if (r,g,b) is the colour being displayed, it will appear as (rG,gG,bG). In order to achieve a display colour or (r,g,b) the inverse of the gamma function needs to be created, namely (r1/G,g1/G,b1/G). Note also that the gamma value G is not necessarily the same for each (r,g,b) component.
Written By Paul Bourke
June 2003
Many applications in computer graphics use colour and/or opacity ramps, in particular, visualisation using volume rendering. In this and other cases one often just requires colour and opacity index tables for 256 states. The following is a straightforward approach to storing such index colour maps, it has been adopted from the OGLE volume rendering software, at least this means there is one other piece of software that uses the format rather than dreaming up an entirely new format.
Example (ramp1.dat)
This is the standard blue to green to red colour map. The columns are the index value follwed by the red, green, blue values ranging from 0 (no contribution) to 255 (full contribution).
0 0 0 255 64 0 255 254 128 1 255 0 192 255 252 0 1 0 3 255 65 0 255 249 129 5 255 0 193 255 247 0 2 0 7 255 66 0 255 246 130 9 255 0 194 255 244 0 3 0 11 255 67 0 255 241 131 13 255 0 195 255 239 0 4 0 15 255 68 0 255 238 132 17 255 0 196 255 236 0 5 0 19 255 69 0 255 233 133 21 255 0 197 255 231 0 6 0 23 255 70 0 255 230 134 25 255 0 198 255 228 0 7 0 27 255 71 0 255 225 135 29 255 0 199 255 223 0 8 0 31 255 72 0 255 222 136 33 255 0 200 255 220 0 9 0 35 255 73 0 255 217 137 37 255 0 201 255 215 0 10 0 39 255 74 0 255 214 138 41 255 0 202 255 212 0 11 0 43 255 75 0 255 209 139 45 255 0 203 255 207 0 12 0 47 255 76 0 255 206 140 49 255 0 204 255 204 0 13 0 51 255 77 0 255 201 141 53 255 0 205 255 199 0 14 0 55 255 78 0 255 198 142 57 255 0 206 255 196 0 15 0 59 255 79 0 255 193 143 61 255 0 207 255 191 0 16 0 63 255 80 0 255 190 144 66 255 0 208 255 188 0 17 0 67 255 81 0 255 185 145 70 255 0 209 255 183 0 18 0 71 255 82 0 255 182 146 74 255 0 210 255 180 0 19 0 75 255 83 0 255 177 147 78 255 0 211 255 175 0 20 0 79 255 84 0 255 174 148 82 255 0 212 255 172 0 21 0 83 255 85 0 255 169 149 86 255 0 213 255 167 0 22 0 87 255 86 0 255 166 150 90 255 0 214 255 164 0 23 0 91 255 87 0 255 161 151 94 255 0 215 255 159 0 24 0 95 255 88 0 255 158 152 98 255 0 216 255 156 0 25 0 99 255 89 0 255 153 153 102 255 0 217 255 151 0 26 0 103 255 90 0 255 150 154 106 255 0 218 255 148 0 27 0 107 255 91 0 255 145 155 110 255 0 219 255 143 0 28 0 111 255 92 0 255 142 156 114 255 0 220 255 140 0 29 0 115 255 93 0 255 137 157 118 255 0 221 255 135 0 30 0 119 255 94 0 255 134 158 122 255 0 222 255 132 0 31 0 123 255 95 0 255 129 159 126 255 0 223 255 127 0 32 0 127 255 96 0 255 126 160 129 255 0 224 255 123 0 33 0 132 255 97 0 255 122 161 134 255 0 225 255 119 0 34 0 135 255 98 0 255 118 162 137 255 0 226 255 115 0 35 0 140 255 99 0 255 114 163 142 255 0 227 255 111 0 36 0 143 255 100 0 255 110 164 145 255 0 228 255 107 0 37 0 148 255 101 0 255 106 165 150 255 0 229 255 103 0 38 0 151 255 102 0 255 102 166 153 255 0 230 255 99 0 39 0 156 255 103 0 255 98 167 158 255 0 231 255 95 0 40 0 159 255 104 0 255 94 168 161 255 0 232 255 91 0 41 0 164 255 105 0 255 90 169 166 255 0 233 255 87 0 42 0 167 255 106 0 255 86 170 169 255 0 234 255 83 0 43 0 172 255 107 0 255 82 171 174 255 0 235 255 79 0 44 0 175 255 108 0 255 78 172 177 255 0 236 255 75 0 45 0 180 255 109 0 255 74 173 182 255 0 237 255 71 0 46 0 183 255 110 0 255 70 174 185 255 0 238 255 67 0 47 0 188 255 111 0 255 66 175 190 255 0 239 255 63 0 48 0 191 255 112 0 255 61 176 193 255 0 240 255 59 0 49 0 196 255 113 0 255 57 177 198 255 0 241 255 55 0 50 0 199 255 114 0 255 53 178 201 255 0 242 255 51 0 51 0 204 255 115 0 255 49 179 206 255 0 243 255 47 0 52 0 207 255 116 0 255 45 180 209 255 0 244 255 43 0 53 0 212 255 117 0 255 41 181 214 255 0 245 255 39 0 54 0 215 255 118 0 255 37 182 217 255 0 246 255 35 0 55 0 220 255 119 0 255 33 183 222 255 0 247 255 31 0 56 0 223 255 120 0 255 29 184 225 255 0 248 255 27 0 57 0 228 255 121 0 255 25 185 230 255 0 249 255 23 0 58 0 231 255 122 0 255 21 186 233 255 0 250 255 19 0 59 0 236 255 123 0 255 17 187 238 255 0 251 255 15 0 60 0 239 255 124 0 255 13 188 241 255 0 252 255 11 0 61 0 244 255 125 0 255 9 189 246 255 0 253 255 7 0 62 0 247 255 126 0 255 5 190 249 255 0 254 255 3 0 63 0 252 255 127 0 255 1 191 254 255 0 255 255 0 0
Opacity maps are stored in the same way even though the rgb colour information is usually redundant (r == g == b). Having the opacity map separate from the colour map allows one to use them interchangably, if the rgb values of a map used as an opacity map are not equal then the application can choose how to derive the single opacity value (eg: use the red channel, use the magnitude of the colour....).
Collection of colour ramps and associated data file
| 01.dat | |
| 02.dat | |
| 03.dat | |
| 04.dat | |
| 05.dat | |
| 06.dat | |
| 07.dat | |
| 08.dat | |
| 09.dat | |
| 10.dat | |
| 11.dat | |
| 12.dat | |
| 13.dat | |
| 14.dat | |
| 15.dat | |
| 16.dat | |
| 17.dat | |
| 18.dat | |
| 19.dat | |
| 20.dat | |
| 21.dat | |
| 22.dat |
A useful colour picker interface is often based upon the HSV colour system, sometimes the HSL. The layout of the colour table is often as follows although there is some variation in the functions used for saturation and value. All the colours in rgb space lie on the surface of the colour cube.

Example
As a web based paint selection interface, note the extra bar for grey scale selection.

Written by Paul Bourke
February 1997
Index colour systems are still prevalent in many graphical computer systems. An index colour system is one in which colour is specified by an integer normally from 0 up to the number of colours in the colour table. Each entry in the colour table gives the red, green, blue components for that particular index.
In such colour systems the colour table is sometimes fixed. In these cases you can only use the preset colours. When a particular colour is required which isn't in the table the closest may be used or a number of colours that are in the table may be dithered in order to approximate the desired colour.
A more common situation is when the colour table is of a fixed size but the actual RGB values at each position in the table can be changed. Therefore, if you require a wide range of a particular hue you can load up the colour table accordingly. It also leads to situations where one might want to optimise the colour table to best represent a particular image. For example if an image only contains 100 different colours then irrespective of what these colours are, a colour table containing these colours will allow the image to be represented exactly. A much more common situation is when the colour table isn't large enough to hold all the different colours desired, in these cases one might engage in a process called "colour table optimisation" where one attempts to load the colour table with colours so that the image can be best represented.
In yet other systems the colour table can be made as large as desired. One often then wants to create a colour table for a particular task. The remained of this document will describe the most unbiased method of creating a colour table in cases where you don't know what colours will be required and thus want an equal sampling of the RGB colour space

There are two processes involved. The first is creating the entries in the colour table, the second is given an RGB value determining the index of its closest representation in the table. In what follows, an RGB triple will be floating point numbers in the inclusive range [0,1]. If your colour space uses different ranges then simple scaling converts one range to the [0,1] range used here.
To create a n sampling along each r,g,b axis will result in n3 colour values. Converting from (r,g,b) triples into the colour index is
Some examples of colour tables are illustrated below. The index ranges from 0 top left, increasing left to right - top to bottom. The index in the bottom right cell is n3-1.
3x3x3 sampling
4x4x4 sampling

5x5x5 sampling

6x6x6 sampling

Finding the index of the colour closest to a particular (r,g,b) triple is accomplished as follows
where nint(x) is the nearest integer to x.
Note
If an odd sampling is used then the colour table will have a sampling of grey values (the diagonal of the colour cube where r = g = b)
Many colour tables are restricted to one byte for the index, that is, up to 256 entries. It is common in these cases to use a 6x6x6 sampling and fill in the remaining 40 colour table entries with red, blue, green, and grey 10 sample ramps.
Strictly speaking the samples generated as above are not all equally distributed, the 8 vertices of the colour cube are less likely than colours along the 12 edges which in turn are less likely than points lying near the 6 planes which are less likely that interior points.
The Macintosh 256 Colour PaletteThe following shows the RGB value of each colour in the default 256 Macintosh palette. The first column is the index, column 2 to 4 are the RGB values in the range 0 to 65535, columns 5 to 7 are the RGB values in the range of 0 to 1. The palette is arranged as follows: there are 256 colours to allocate, an even distribution of colours through the colour cube might be desirable but 256 is not the cube of an integer. 6x6x6 is 216 and so the first 216 colours are an equal 6x6x6 sampling of the colour cube. This leaves 40 colours to allocate, this has been done by choosing a ramp of 10 shades each for red, green, blue and grey. |
![]()
|
The table
| Index | Red | Green | Blue | Red | Green | Blue |
| 0 | 65535 | 65535 | 65535 | 1 | 1 | 1 |
| 1 | 65535 | 65535 | 52428 | 1 | 1 | 0.8 |
| 2 | 65535 | 65535 | 39321 | 1 | 1 | 0.6 |
| 3 | 65535 | 65535 | 26214 | 1 | 1 | 0.4 |
| 4 | 65535 | 65535 | 13107 | 1 | 1 | 0.2 |
| 5 | 65535 | 65535 | 0 | 1 | 1 | 0 |
| 6 | 65535 | 52428 | 65535 | 1 | 0.8 | 1 |
| 7 | 65535 | 52428 | 52428 | 1 | 0.8 | 0.8 |
| 8 | 65535 | 52428 | 39321 | 1 | 0.8 | 0.6 |
| 9 | 65535 | 52428 | 26214 | 1 | 0.8 | 0.4 |
| 10 | 65535 | 52428 | 13107 | 1 | 0.8 | 0.2 |
| 11 | 65535 | 52428 | 0 | 1 | 0.8 | 0 |
| 12 | 65535 | 39321 | 65535 | 1 | 0.6 | 1 |
| 13 | 65535 | 39321 | 52428 | 1 | 0.6 | 0.8 |
| 14 | 65535 | 39321 | 39321 | 1 | 0.6 | 0.6 |
| 15 | 65535 | 39321 | 26214 | 1 | 0.6 | 0.4 |
| 16 | 65535 | 39321 | 13107 | 1 | 0.6 | 0.2 |
| 17 | 65535 | 39321 | 0 | 1 | 0.6 | 0 |
| 18 | 65535 | 26214 | 65535 | 1 | 0.4 | 1 |
| 19 | 65535 | 26214 | 52428 | 1 | 0.4 | 0.8 |
| 20 | 65535 | 26214 | 39321 | 1 | 0.4 | 0.6 |
| 21 | 65535 | 26214 | 26214 | 1 | 0.4 | 0.4 |
| 22 | 65535 | 26214 | 13107 | 1 | 0.4 | 0.2 |
| 23 | 65535 | 26214 | 0 | 1 | 0.4 | 0 |
| 24 | 65535 | 13107 | 65535 | 1 | 0.2 | 1 |
| 25 | 65535 | 13107 | 52428 | 1 | 0.2 | 0.8 |
| 26 | 65535 | 13107 | 39321 | 1 | 0.2 | 0.6 |
| 27 | 65535 | 13107 | 26214 | 1 | 0.2 | 0.4 |
| 28 | 65535 | 13107 | 13107 | 1 | 0.2 | 0.2 |
| 29 | 65535 | 13107 | 0 | 1 | 0.2 | 0 |
| 30 | 65535 | 0 | 65535 | 1 | 0 | 1 |
| 31 | 65535 | 0 | 52428 | 1 | 0 | 0.8 |
| 32 | 65535 | 0 | 39321 | 1 | 0 | 0.6 |
| 33 | 65535 | 0 | 26214 | 1 | 0 | 0.4 |
| 34 | 65535 | 0 | 13107 | 1 | 0 | 0.2 |
| 35 | 65535 | 0 | 0 | 1 | 0 | 0 |
| 36 | 52428 | 65535 | 65535 | 0.8 | 1 | 1 |
| 37 | 52428 | 65535 | 52428 | 0.8 | 1 | 0.8 |
| 38 | 52428 | 65535 | 39321 | 0.8 | 1 | 0.6 |
| 39 | 52428 | 65535 | 26214 | 0.8 | 1 | 0.4 |
| 40 | 52428 | 65535 | 13107 | 0.8 | 1 | 0.2 |
| 41 | 52428 | 65535 | 0 | 0.8 | 1 | 0 |
| 42 | 52428 | 52428 | 65535 | 0.8 | 0.8 | 1 |
| 43 | 52428 | 52428 | 52428 | 0.8 | 0.8 | 0.8 |
| 44 | 52428 | 52428 | 39321 | 0.8 | 0.8 | 0.6 |
| 45 | 52428 | 52428 | 26214 | 0.8 | 0.8 | 0.4 |
| 46 | 52428 | 52428 | 13107 | 0.8 | 0.8 | 0.2 |
| 47 | 52428 | 52428 | 0 | 0.8 | 0.8 | 0 |
| 48 | 52428 | 39321 | 65535 | 0.8 | 0.6 | 1 |
| 49 | 52428 | 39321 | 52428 | 0.8 | 0.6 | 0.8 |
| 50 | 52428 | 39321 | 39321 | 0.8 | 0.6 | 0.6 |
| 51 | 52428 | 39321 | 26214 | 0.8 | 0.6 | 0.4 |
| 52 | 52428 | 39321 | 13107 | 0.8 | 0.6 | 0.2 |
| 53 | 52428 | 39321 | 0 | 0.8 | 0.6 | 0 |
| 54 | 52428 | 26214 | 65535 | 0.8 | 0.4 | 1 |
| 55 | 52428 | 26214 | 52428 | 0.8 | 0.4 | 0.8 |
| 56 | 52428 | 26214 | 39321 | 0.8 | 0.4 | 0.6 |
| 57 | 52428 | 26214 | 26214 | 0.8 | 0.4 | 0.4 |
| 58 | 52428 | 26214 | 13107 | 0.8 | 0.4 | 0.2 |
| 59 | 52428 | 26214 | 0 | 0.8 | 0.4 | 0 |
| 60 | 52428 | 13107 | 65535 | 0.8 | 0.2 | 1 |
| 61 | 52428 | 13107 | 52428 | 0.8 | 0.2 | 0.8 |
| 62 | 52428 | 13107 | 39321 | 0.8 | 0.2 | 0.6 |
| 63 | 52428 | 13107 | 26214 | 0.8 | 0.2 | 0.4 |
| 64 | 52428 | 13107 | 13107 | 0.8 | 0.2 | 0.2 |
| 65 | 52428 | 13107 | 0 | 0.8 | 0.2 | 0 |
| 66 | 52428 | 0 | 65535 | 0.8 | 0 | 1 |
| 67 | 52428 | 0 | 52428 | 0.8 | 0 | 0.8 |
| 68 | 52428 | 0 | 39321 | 0.8 | 0 | 0.6 |
| 69 | 52428 | 0 | 26214 | 0.8 | 0 | 0.4 |
| 70 | 52428 | 0 | 13107 | 0.8 | 0 | 0.2 |
| 71 | 52428 | 0 | 0 | 0.8 | 0 | 0 |
| 72 | 39321 | 65535 | 65535 | 0.6 | 1 | 1 |
| 73 | 39321 | 65535 | 52428 | 0.6 | 1 | 0.8 |
| 74 | 39321 | 65535 | 39321 | 0.6 | 1 | 0.6 |
| 75 | 39321 | 65535 | 26214 | 0.6 | 1 | 0.4 |
| 76 | 39321 | 65535 | 13107 | 0.6 | 1 | 0.2 |
| 77 | 39321 | 65535 | 0 | 0.6 | 1 | 0 |
| 78 | 39321 | 52428 | 65535 | 0.6 | 0.8 | 1 |
| 79 | 39321 | 52428 | 52428 | 0.6 | 0.8 | 0.8 |
| 80 | 39321 | 52428 | 39321 | 0.6 | 0.8 | 0.6 |
| 81 | 39321 | 52428 | 26214 | 0.6 | 0.8 | 0.4 |
| 82 | 39321 | 52428 | 13107 | 0.6 | 0.8 | 0.2 |
| 83 | 39321 | 52428 | 0 | 0.6 | 0.8 | 0 |
| 84 | 39321 | 39321 | 65535 | 0.6 | 0.6 | 1 |
| 85 | 39321 | 39321 | 52428 | 0.6 | 0.6 | 0.8 |
| 86 | 39321 | 39321 | 39321 | 0.6 | 0.6 | 0.6 |
| 87 | 39321 | 39321 | 26214 | 0.6 | 0.6 | 0.4 |
| 88 | 39321 | 39321 | 13107 | 0.6 | 0.6 | 0.2 |
| 89 | 39321 | 39321 | 0 | 0.6 | 0.6 | 0 |
| 90 | 39321 | 26214 | 65535 | 0.6 | 0.4 | 1 |
| 91 | 39321 | 26214 | 52428 | 0.6 | 0.4 | 0.8 |
| 92 | 39321 | 26214 | 39321 | 0.6 | 0.4 | 0.6 |
| 93 | 39321 | 26214 | 26214 | 0.6 | 0.4 | 0.4 |
| 94 | 39321 | 26214 | 13107 | 0.6 | 0.4 | 0.2 |
| 95 | 39321 | 26214 | 0 | 0.6 | 0.4 | 0 |
| 96 | 39321 | 13107 | 65535 | 0.6 | 0.2 | 1 |
| 97 | 39321 | 13107 | 52428 | 0.6 | 0.2 | 0.8 |
| 98 | 39321 | 13107 | 39321 | 0.6 | 0.2 | 0.6 |
| 99 | 39321 | 13107 | 26214 | 0.6 | 0.2 | 0.4 |
| 100 | 39321 | 13107 | 13107 | 0.6 | 0.2 | 0.2 |
| 101 | 39321 | 13107 | 0 | 0.6 | 0.2 | 0 |
| 102 | 39321 | 0 | 65535 | 0.6 | 0 | 1 |
| 103 | 39321 | 0 | 52428 | 0.6 | 0 | 0.8 |
| 104 | 39321 | 0 | 39321 | 0.6 | 0 | 0.6 |
| 105 | 39321 | 0 | 26214 | 0.6 | 0 | 0.4 |
| 106 | 39321 | 0 | 13107 | 0.6 | 0 | 0.2 |
| 107 | 39321 | 0 | 0 | 0.6 | 0 | 0 |
| 108 | 26214 | 65535 | 65535 | 0.4 | 1 | 1 |
| 109 | 26214 | 65535 | 52428 | 0.4 | 1 | 0.8 |
| 110 | 26214 | 65535 | 39321 | 0.4 | 1 | 0.6 |
| 111 | 26214 | 65535 | 26214 | 0.4 | 1 | 0.4 |
| 112 | 26214 | 65535 | 13107 | 0.4 | 1 | 0.2 |
| 113 | 26214 | 65535 | 0 | 0.4 | 1 | 0 |
| 114 | 26214 | 52428 | 65535 | 0.4 | 0.8 | 1 |
| 115 | 26214 | 52428 | 52428 | 0.4 | 0.8 | 0.8 |
| 116 | 26214 | 52428 | 39321 | 0.4 | 0.8 | 0.6 |
| 117 | 26214 | 52428 | 26214 | 0.4 | 0.8 | 0.4 |
| 118 | 26214 | 52428 | 13107 | 0.4 | 0.8 | 0.2 |
| 119 | 26214 | 52428 | 0 | 0.4 | 0.8 | 0 |
| 120 | 26214 | 39321 | 65535 | 0.4 | 0.6 | 1 |
| 121 | 26214 | 39321 | 52428 | 0.4 | 0.6 | 0.8 |
| 122 | 26214 | 39321 | 39321 | 0.4 | 0.6 | 0.6 |
| 123 | 26214 | 39321 | 26214 | 0.4 | 0.6 | 0.4 |
| 124 | 26214 | 39321 | 13107 | 0.4 | 0.6 | 0.2 |
| 125 | 26214 | 39321 | 0 | 0.4 | 0.6 | 0 |
| 126 | 26214 | 26214 | 65535 | 0.4 | 0.4 | 1 |
| 127 | 26214 | 26214 | 52428 | 0.4 | 0.4 | 0.8 |
| 128 | 26214 | 26214 | 39321 | 0.4 | 0.4 | 0.6 |
| 129 | 26214 | 26214 | 26214 | 0.4 | 0.4 | 0.4 |
| 130 | 26214 | 26214 | 13107 | 0.4 | 0.4 | 0.2 |
| 131 | 26214 | 26214 | 0 | 0.4 | 0.4 | 0 |
| 132 | 26214 | 13107 | 65535 | 0.4 | 0.2 | 1 |
| 133 | 26214 | 13107 | 52428 | 0.4 | 0.2 | 0.8 |
| 134 | 26214 | 13107 | 39321 | 0.4 | 0.2 | 0.6 |
| 135 | 26214 | 13107 | 26214 | 0.4 | 0.2 | 0.4 |
| 136 | 26214 | 13107 | 13107 | 0.4 | 0.2 | 0.2 |
| 137 | 26214 | 13107 | 0 | 0.4 | 0.2 | 0 |
| 138 | 26214 | 0 | 65535 | 0.4 | 0 | 1 |
| 139 | 26214 | 0 | 52428 | 0.4 | 0 | 0.8 |
| 140 | 26214 | 0 | 39321 | 0.4 | 0 | 0.6 |
| 141 | 26214 | 0 | 26214 | 0.4 | 0 | 0.4 |
| 142 | 26214 | 0 | 13107 | 0.4 | 0 | 0.2 |
| 143 | 26300 | 4265 | 486 | 0.401312 | 0.0650797 | 0.00741588 |
| 144 | 13107 | 65535 | 65535 | 0.2 | 1 | 1 |
| 145 | 13107 | 65535 | 52428 | 0.2 | 1 | 0.8 |
| 146 | 13107 | 65535 | 39321 | 0.2 | 1 | 0.6 |
| 147 | 13107 | 65535 | 26214 | 0.2 | 1 | 0.4 |
| 148 | 13107 | 65535 | 13107 | 0.2 | 1 | 0.2 |
| 149 | 13107 | 65535 | 0 | 0.2 | 1 | 0 |
| 150 | 13107 | 52428 | 65535 | 0.2 | 0.8 | 1 |
| 151 | 13107 | 52428 | 52428 | 0.2 | 0.8 | 0.8 |
| 152 | 13107 | 52428 | 39321 | 0.2 | 0.8 | 0.6 |
| 153 | 13107 | 52428 | 26214 | 0.2 | 0.8 | 0.4 |
| 154 | 13107 | 52428 | 13107 | 0.2 | 0.8 | 0.2 |
| 155 | 13107 | 52428 | 0 | 0.2 | 0.8 | 0 |
| 156 | 13107 | 39321 | 65535 | 0.2 | 0.6 | 1 |
| 157 | 13107 | 39321 | 52428 | 0.2 | 0.6 | 0.8 |
| 158 | 13107 | 39321 | 39321 | 0.2 | 0.6 | 0.6 |
| 159 | 13107 | 39321 | 26214 | 0.2 | 0.6 | 0.4 |
| 160 | 13107 | 39321 | 13107 | 0.2 | 0.6 | 0.2 |
| 161 | 13107 | 39321 | 0 | 0.2 | 0.6 | 0 |
| 162 | 13107 | 26214 | 65535 | 0.2 | 0.4 | 1 |
| 163 | 13107 | 26214 | 52428 | 0.2 | 0.4 | 0.8 |
| 164 | 13107 | 26214 | 39321 | 0.2 | 0.4 | 0.6 |
| 165 | 13107 | 26214 | 26214 | 0.2 | 0.4 | 0.4 |
| 166 | 13107 | 26214 | 13107 | 0.2 | 0.4 | 0.2 |
| 167 | 13107 | 26214 | 0 | 0.2 | 0.4 | 0 |
| 168 | 13107 | 13107 | 65535 | 0.2 | 0.2 | 1 |
| 169 | 13107 | 13107 | 52428 | 0.2 | 0.2 | 0.8 |
| 170 | 13107 | 13107 | 39321 | 0.2 | 0.2 | 0.6 |
| 171 | 13107 | 13107 | 26214 | 0.2 | 0.2 | 0.4 |
| 172 | 13107 | 13107 | 13107 | 0.2 | 0.2 | 0.2 |
| 173 | 15976 | 14457 | 2622 | 0.243778 | 0.2206 | 0.0400092 |
| 174 | 13107 | 0 | 65535 | 0.2 | 0 | 1 |
| 175 | 13107 | 0 | 52428 | 0.2 | 0 | 0.8 |
| 176 | 13107 | 0 | 39321 | 0.2 | 0 | 0.6 |
| 177 | 13107 | 0 | 26214 | 0.2 | 0 | 0.4 |
| 178 | 13107 | 0 | 13107 | 0.2 | 0 | 0.2 |
| 179 | 13107 | 0 | 0 | 0.2 | 0 | 0 |
| 180 | 0 | 65535 | 65535 | 0 | 1 | 1 |
| 181 | 0 | 65535 | 52428 | 0 | 1 | 0.8 |
| 182 | 0 | 65535 | 39321 | 0 | 1 | 0.6 |
| 183 | 0 | 65535 | 26214 | 0 | 1 | 0.4 |
| 184 | 0 | 65535 | 13107 | 0 | 1 | 0.2 |
| 185 | 0 | 65535 | 0 | 0 | 1 | 0 |
| 186 | 0 | 52428 | 65535 | 0 | 0.8 | 1 |
| 187 | 0 | 52428 | 52428 | 0 | 0.8 | 0.8 |
| 188 | 0 | 52428 | 39321 | 0 | 0.8 | 0.6 |
| 189 | 0 | 52428 | 26214 | 0 | 0.8 | 0.4 |
| 190 | 0 | 52428 | 13107 | 0 | 0.8 | 0.2 |
| 191 | 0 | 52428 | 0 | 0 | 0.8 | 0 |
| 192 | 0 | 40000 | 65535 | 0 | 0.610361 | 1 |
| 193 | 0 | 39321 | 52428 | 0 | 0.6 | 0.8 |
| 194 | 0 | 39321 | 39321 | 0 | 0.6 | 0.6 |
| 195 | 0 | 39321 | 26214 | 0 | 0.6 | 0.4 |
| 196 | 0 | 39321 | 13107 | 0 | 0.6 | 0.2 |
| 197 | 0 | 39321 | 0 | 0 | 0.6 | 0 |
| 198 | 0 | 26214 | 65535 | 0 | 0.4 | 1 |
| 199 | 0 | 26214 | 52428 | 0 | 0.4 | 0.8 |
| 200 | 0 | 26214 | 39321 | 0 | 0.4 | 0.6 |
| 201 | 0 | 26214 | 26214 | 0 | 0.4 | 0.4 |
| 202 | 0 | 26214 | 13107 | 0 | 0.4 | 0.2 |
| 203 | 0 | 26214 | 0 | 0 | 0.4 | 0 |
| 204 | 0 | 13107 | 65535 | 0 | 0.2 | 1 |
| 205 | 0 | 13107 | 52428 | 0 | 0.2 | 0.8 |
| 206 | 0 | 13107 | 39321 | 0 | 0.2 | 0.6 |
| 207 | 0 | 13107 | 26214 | 0 | 0.2 | 0.4 |
| 208 | 0 | 13107 | 13107 | 0 | 0.2 | 0.2 |
| 209 | 0 | 13107 | 0 | 0 | 0.2 | 0 |
| 210 | 0 | 0 | 65535 | 0 | 0 | 1 |
| 211 | 0 | 0 | 52428 | 0 | 0 | 0.8 |
| 212 | 0 | 0 | 39321 | 0 | 0 | 0.6 |
| 213 | 0 | 0 | 26214 | 0 | 0 | 0.4 |
| 214 | 0 | 0 | 13107 | 0 | 0 | 0.2 |
| 215 | 61183 | 2079 | 4938 | 0.933593 | 0.0317235 | 0.0753491 |
| 216 | 56797 | 0 | 0 | 0.866667 | 0 | 0 |
| 217 | 48059 | 0 | 0 | 0.733333 | 0 | 0 |
| 218 | 43690 | 0 | 0 | 0.666667 | 0 | 0 |
| 219 | 34952 | 0 | 0 | 0.533333 | 0 | 0 |
| 220 | 30583 | 0 | 0 | 0.466667 | 0 | 0 |
| 221 | 21845 | 0 | 0 | 0.333333 | 0 | 0 |
| 222 | 17476 | 0 | 0 | 0.266667 | 0 | 0 |
| 223 | 8738 | 0 | 0 | 0.133333 | 0 | 0 |
| 224 | 4369 | 0 | 0 | 0.0666667 | 0 | 0 |
| 225 | 0 | 61166 | 0 | 0 | 0.933333 | 0 |
| 226 | 0 | 56797 | 0 | 0 | 0.866667 | 0 |
| 227 | 0 | 48059 | 0 | 0 | 0.733333 | 0 |
| 228 | 0 | 43690 | 0 | 0 | 0.666667 | 0 |
| 229 | 0 | 34952 | 0 | 0 | 0.533333 | 0 |
| 230 | 0 | 30583 | 0 | 0 | 0.466667 | 0 |
| 231 | 0 | 21845 | 0 | 0 | 0.333333 | 0 |
| 232 | 0 | 17476 | 0 | 0 | 0.266667 | 0 |
| 233 | 0 | 8738 | 0 | 0 | 0.133333 | 0 |
| 234 | 0 | 4369 | 0 | 0 | 0.0666667 | 0 |
| 235 | 0 | 0 | 61166 | 0 | 0 | 0.933333 |
| 236 | 0 | 0 | 56797 | 0 | 0 | 0.866667 |
| 237 | 0 | 0 | 48059 | 0 | 0 | 0.733333 |
| 238 | 0 | 0 | 43690 | 0 | 0 | 0.666667 |
| 239 | 0 | 0 | 34952 | 0 | 0 | 0.533333 |
| 240 | 0 | 0 | 30583 | 0 | 0 | 0.466667 |
| 241 | 0 | 0 | 21845 | 0 | 0 | 0.333333 |
| 242 | 0 | 0 | 17476 | 0 | 0 | 0.266667 |
| 243 | 0 | 0 | 8738 | 0 | 0 | 0.133333 |
| 244 | 0 | 0 | 4369 | 0 | 0 | 0.0666667 |
| 245 | 61166 | 61166 | 61166 | 0.933333 | 0.933333 | 0.933333 |
| 246 | 56797 | 56797 | 56797 | 0.866667 | 0.866667 | 0.866667 |
| 247 | 48059 | 48059 | 48059 | 0.733333 | 0.733333 | 0.733333 |
| 248 | 43690 | 43690 | 43690 | 0.666667 | 0.666667 | 0.666667 |
| 249 | 34952 | 34952 | 34952 | 0.533333 | 0.533333 | 0.533333 |
| 250 | 30583 | 30583 | 30583 | 0.466667 | 0.466667 | 0.466667 |
| 251 | 21845 | 21845 | 21845 | 0.333333 | 0.333333 | 0.333333 |
| 252 | 17476 | 17476 | 17476 | 0.266667 | 0.266667 | 0.266667 |
| 253 | 8738 | 8738 | 8738 | 0.133333 | 0.133333 | 0.133333 |
| 254 | 4369 | 4369 | 4369 | 0.0666667 | 0.0666667 | 0.0666667 |
| 255 | 0 | 0 | 0 | 0 | 0 | 0 |
The following is the C code that created the above colour table.
Source code
PhotoShop Index Colour Table Files
Performing colour remapping with indexed colour images in PhotoShop is particularly straightforward mainly because the colour table files are so easy to generate. The colour table files (which can be loaded into PhotoShop) consist of 256 RGB colour entries, each RGB colour component is stored as 1 byte. Each colour component ranges from 0 to 255. As such they are straightforward to generate mathematically with a programming language.
|
Example 1 On the Macintosh the file creator will need to be set to 8BIM and the file type to 8BCT
int main(int argc,char **argv)
{
int i;
for (i=0;i<256;i++) {
putchar(i);
putchar(0);
putchar(255-i);
}
}
|
![]()
|
|
Example 2 A circular red -> yellow -> green -> cyan -> blue -> magenta -> red colour table file in hexadecimal and the map shown visually in PhotoShop are illustrated below |
![]()
|
Address Hexadecimal data, 16 bytes per line ------- --------------------------------------- 0000000 ff00 00ff 0600 ff0c 00ff 1200 ff18 00ff 0000020 1e00 ff24 00ff 2a00 ff30 00ff 3600 ff3c 0000040 00ff 4200 ff48 00ff 4e00 ff54 00ff 5a00 0000060 ff60 00ff 6600 ff6c 00ff 7200 ff78 00ff 0000100 7e00 ff84 00ff 8a00 ff90 00ff 9600 ff9c 0000120 00ff a200 ffa8 00ff ae00 ffb4 00ff ba00 0000140 ffc0 00ff c600 ffcc 00ff d200 ffd8 00ff 0000160 de00 ffe4 00ff ea00 fff0 00ff f600 fffc 0000200 00fc ff00 f6ff 00f0 ff00 eaff 00e4 ff00 0000220 deff 00d8 ff00 d2ff 00cc ff00 c6ff 00c0 0000240 ff00 baff 00b3 ff00 aeff 00a8 ff00 a2ff 0000260 009c ff00 96ff 0090 ff00 8aff 0083 ff00 0000300 7eff 0078 ff00 71ff 006c ff00 66ff 0060 0000320 ff00 59ff 0054 ff00 4eff 0048 ff00 41ff 0000340 003c ff00 36ff 0030 ff00 29ff 0024 ff00 0000360 1eff 0018 ff00 11ff 000c ff00 06ff 0000 0000400 ff00 00ff 0600 ff0c 00ff 1200 ff18 00ff 0000420 1e00 ff24 00ff 2a00 ff30 00ff 3600 ff3c 0000440 00ff 4200 ff48 00ff 4e00 ff54 00ff 5a00 0000460 ff60 00ff 6600 ff6c 00ff 7200 ff78 00ff 0000500 7e00 ff84 00ff 8a00 ff90 00ff 9600 ff9c 0000520 00ff a200 ffa8 00ff ae00 ffb4 00ff ba00 0000540 ffc0 00ff c600 ffcc 00ff d200 ffd8 00ff 0000560 de00 ffe4 00ff ea00 fff0 00ff f600 fffc 0000600 00fc ff00 f6ff 00f0 ff00 eaff 00e4 ff00 0000620 deff 00d8 ff00 d2ff 00cc ff00 c6ff 00c0 0000640 ff00 baff 00b3 ff00 aeff 00a8 ff00 a2ff 0000660 009c ff00 96ff 0090 ff00 8aff 0083 ff00 0000700 7eff 0078 ff00 71ff 006c ff00 66ff 0060 0000720 ff00 59ff 0054 ff00 4eff 0048 ff00 41ff 0000740 003c ff00 36ff 0030 ff00 29ff 0024 ff00 0000760 1eff 0018 ff00 11ff 000c ff00 06ff 0000 0001000 ff06 00ff 0c00 ff12 00ff 1800 ff1e 00ff 0001020 2400 ff2a 00ff 3000 ff36 00ff 3c00 ff42 0001040 00ff 4800 ff4e 00ff 5400 ff5a 00ff 6000 0001060 ff66 00ff 6c00 ff72 00ff 7800 ff7e 00ff 0001100 8400 ff8a 00ff 9000 ff96 00ff 9c00 ffa2 0001120 00ff a800 ffae 00ff b400 ffba 00ff c000 0001140 ffc6 00ff cc00 ffd2 00ff d800 ffde 00ff 0001160 e400 ffea 00ff f000 fff6 00ff fc00 ffff 0001200 00fc ff00 f6ff 00f0 ff00 eaff 00e4 ff00 0001220 deff 00d8 ff00 d2ff 00cc ff00 c6ff 00c0 0001240 ff00 baff 00b3 ff00 aeff 00a8 ff00 a2ff 0001260 009c ff00 96ff 0090 ff00 8aff 0083 ff00 0001300 7eff 0078 ff00 71ff 006c ff00 66ff 0060 0001320 ff00 59ff 0054 ff00 4eff 0048 ff00 41ff 0001340 003c ff00 36ff 0030 ff00 29ff 0024 ff00 0001360 1eff 0018 ff00 11ff 000c ff00 06ff 0000
|
Example 3 Double (circular) grep ramp. |
![]()
|