At the time a grayscale image is displayed on the screen, Vision converts the value of each pixel of the image into red, green, and blue intensities for the corresponding pixel displayed on the screen. This process uses a color table, called a palette, which associates a color to each possible grayscale value of an image. Vision provides the capability to customize the palette used to display an 8-bit grayscale image.

When to Use

With palettes, you can produce different visual representations of an image without altering the pixel data. Palettes can generate effects, such as photonegative displays or color-coded displays. In the latter case, palettes are useful for detailing particular image constituents in which the total number of colors is limited.

Displaying images in different palettes helps emphasize regions with particular intensities, identify smooth or abrupt gray-level variations, and convey details that might be difficult to perceive in a grayscale image. For example, the human eye is much more sensitive to small intensity variations in a bright area than in a dark area. Using a color palette may help you distinguish these slight changes.

Concepts

A palette is a pre-defined or user-defined array of RGB values. It defines for each possible gray-level value a corresponding color value to render the pixel. The gray-level value of a pixel acts as an address that is indexed into the table, returning three values corresponding to a red, green, and blue (RGB) intensity. This set of RGB values defines a palette in which varying amounts of red, green, and blue are mixed to produce a color representation of the value range.

In the case of 8-bit grayscale images, pixels can take 28, or 256, values ranging from 0 to 255. Color palettes are composed of 256 RGB elements. A specific color is the result of applying a value between 0 and 255 for each of the three color components: red, green, and blue. If the red, green, and blue components have an identical value, the result is a gray level pixel value.

A gray palette associates different shades of gray with each value so as to produce a linear and continuous gradation of gray, from black to white. You can set up the palette to assign the color black to the value 0 and white to 255, or vice versa. Other palettes can reflect linear or nonlinear gradations going from red to blue, light brown to dark brown, and so on.

Vision has five predefined color palettes. Each palette emphasizes different shades of gray.

In-Depth Discussion

The following sections introduce the five predefined palettes available in NI Vision. The graphs in each section represent the color tables used by each palette. The horizontal axes of the graphs represent the input gray-level range [0, 255], and the vertical axes represent the RGB intensities assigned to a given gray-level value.

Gray Palette

This palette has a gradual gray-level variation from black to white. Each value is assigned to an equal amount of red, green, and blue in order to produce a gray-level.

Temperature Palette

This palette has a gradation from light brown to dark brown. 0 is black and 255 is white.

Rainbow Palette

This palette has a gradation from blue to red with a prominent range of greens in the middle value range. 0 is blue and 255 is red.

Gradient Palette

This palette has a gradation from red to white with a prominent range of light blue in the upper value range. 0 is black and 255 is white.

Binary Palette

This palette has 17 cycles of 15 different colors. The following table illustrates these colors, where g is the gray-level value.

g = R G B Resulting Color
1 255 0 0 Red
2 0 255 0 Green
3 0 0 255 Blue
4 255 255 0 Yellow
5 255 0 255 Purple
6 0 255 255 Aqua
7 255 127 0 Orange
8 255 0 127 Magenta
9 127 255 0 Bright green
10 127 0 255 Violet
11 0 127 255 Sky blue
12 0 255 127 Sea green
13 255 127 127 Rose
14 127 255 127 Spring green
15 127 127 255 Periwinkle

The values 0 and 255 are special cases. A value of 0 results in black, and a value of 255 results in white.

This periodic palette is appropriate for the display of binary and labeled images.