color interpolation


I have a color map with different colors associated with different values. If I want to show the color of a value that sits between two adjacent values in the color map, how do I calculate the color to be used? Should I use the linear interpolation of the two adjacent colors based on the position of the value on the color map? For example, assume the two adjacent colors and values are (c1, v1) and (c2, v2). The value in between v1 and v2 is v. Then the color to be used for v is (v-v1)/(v2-v1)*(c2-c1) + c1 for R, G, B. Your advice is much appreciated.