next up previous contents
Next: 16.1.3 Interpolating Data Values Up: 16.1 Scalar Field Visualization Previous: 16.1.1 Definition of a   Contents

16.1.2 Representing Data Values

There are a number of ways to represent scalar data values for visualization. The most obvious is color. A set of color values can be used to represent the range of values the data can assume. There are a few issues that must be considered when choosing color values. First, there are large set of color values that can be used to represent the color range. The colors should be chosen to make the values intuitive. A common technique is to use ``cold'' colors such as black, purple, blue for low values, and ``hot'' colors such as red, orange, and white to represent high values. Sometimes green hues are used to fill in the mid-range values. This ties into viewer expectations about heat and color, indicating the ``energy'' of the data values.

Colors tailored to the application space will give the most mileage. If the goal is to notice data discrepancies, make those values stand out from the rest of the color range. For example, unusual values can be shaded with red hues, with the rest of the value range shades of green. The color range can be made consistent by changing only the hue, fixing the saturation and brightness to only slow changes over the entire data range.

In general, chose one or more ``color paths'' through RGB color space to represent the data range, taking psychological and application specific factors into account.

Once colors are chosen, there are a number of ways to render them. The most obvious way is to map the data values to RGB values directly in the application. OpenGL can be used to simplify and accelerate the process and reduce the amount of work performed in the application.

One obvious way is to use color index values, choosing a colormap where data values index the desired colors. This approach is not recommended, however, for a number of reasons. First, it is a limited approach. Color index values must be integers, and the allowable range of values is limited by the maximum size of the colormap. Second, graphics API implementations are moving away from color index support, and many implementors don't emphasize the color index part of their implementations. Color index applications may be unaccelerated, and possibly not as well implemented as the RGBA path.

Fortunately, there is a better way to provide a mapping between data values and rgb colors: texture maps. The texture map can provide a mapping between data values, input as texture coordinates, to colors, which are mapped as colors in the texture map itself. Texture mapping is optimized and hardware accelerated on almost every implementation of OpenGL at the time of writing, and arbitrarily large mappings can be created using one or more texture maps.

A simple example might clarify this technique. Imagine a set of 50 data values to map colors onto:

  1. Create a 1D 64 entry texture map (you're limited to creating textures whose dimensions are powers-of-2)
  2. Load the first 50 entries of the texture with the color values corresponding to the first 50 data values.
  3. Choose a texture transformation matrix that maps the data values to the S values that index the corresponding texels. This will work if the data values can be mapped with a linear or perspective transformation to the appropriate texture coordinates. If your implementation supports a lookup table associated with texture filtering, such as GL_ TEXTURE_COLOR_TABLE_SGI, you can use the glColorTableSGI() command to create an arbitrary non-linear mapping between data value and texture coordinate. If you don't have this support, you can create a lookup table in the application.
  4. If you don't want to interpolate between data values, use GL_ NEAREST for GL_ TEXTURE_MIN_FILTER, and GL_ TEXTURE_MAG_FILTER, and use the same texture coordinates over all the vertices of the primitive you want to color. Remember that OpenGL indexes a texel by truncating the texture coordinate scaled by the texture size. This is written into the specification, so you can always look up the exact texel you want.
  5. If you do want to interpolate colors between data values, use GL_ LINEAR for GL_ TEXTURE_MIN_FILTER and GL_ TEXTURE_MAG_FILTER, and choose the correct data values at the sample points, letting texture filtering do the color interpolation for you. Since OpenGL texture mapping is perspective correct, you don't have to worry about perspective projection coloring artifacts.


next up previous contents
Next: 16.1.3 Interpolating Data Values Up: 16.1 Scalar Field Visualization Previous: 16.1.1 Definition of a   Contents
2001-01-10