Industrial Data Science
in C# and .NET:
Simple. Fast. Reliable.
 
 

ILNumerics - Technical Computing

Modern High Performance Tools for Technical

Computing and Visualization in Industry and Science

tgt

Managing Colormaps

Colormaps are used in ILNumerics whenever a color is to be derived from a single numerical value. Colormaps behave similar to lookup tables. They define an arbitrary data range and a corresponding color for every number within that range. Data values are translated to positions into the colormap and the final color is computed by linear interpolation.

The data value associated to every grid point is mapped to a specific data range first. The position of the data value within the data range is then used to find the position within the colormap.

Data ranges by default are automatically derived from the maximum and minimum data values. However, if the data values currently available reflect only a subset of the underlying data, the data range is used to set the inherent global maximum and minimum values.

Several colormaps are predefined in ILNumerics. Arbitrary colormaps can be created by the user. Colormaps are built out of a collection of key points, each representing a color and an alpha value. Key points have a distinct position in the colormap associated to them. The data for the predefined colormap Jet for example, is made out of 6 key frames, each encoding a position and 4 tuple for the RGBA values. The key frames are arranged as a 6 x 5 matrix and can be fetched from the Colormap.Data property:

Predefined colormaps usually store key points with positions in the range 0…1. However, while being recommended this is not necessary. Positions of the key frames may have arbitrary limits.

Custom colormaps can easily be created and altered by providing a custom matrix with key points to the Data property of an existing colormap. The following example alters the Jet colormap. It replaces the color for the green keypoint with white:

Another interesting option is to apply distortion to a colormap in order for it to better adapt the data. By transforming the key point positions, colormaps are – for example - easily scaled exponentially to “move” interesting color changes in the map to the interesting data range: