Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]

TrueColor Displays


IDL supports the use of some TrueColor displays with 24 bits per pixel. TrueColor displays have multiple channels. That is, they store information about each primary color component (red, green, and blue) of a pixel separately. A TrueColor display with n bits per memory channel can display 23n simultaneous colors, as opposed to the 2n simultaneous colors available with a normal indexed (pseudo) color display. Images can be transferred to and from each individual memory channel, or to all channels simultaneously.

The X Window visuals TrueColor and DirectColor are among the TrueColor devices supported by IDL.

Configuration

The TrueColor display is configured as a single display with three channels:

Channel
Number
Output
0
All colors
1
Red
2
Green
3
Blue

Lookup Tables

Warning
Not all TrueColor display systems have writable color lookup tables.

Each output channel, red, green, or blue, is routed through its own 8-bit deep, 256 element lookup table. The lookup tables can be used to compensate for color inaccuracies generated by the display hardware or present in the acquisition process. Initially, each lookup table is loaded with a linear ramp, mapping its input directly to its output.

As the TrueColor lookup tables are of the same size and number of elements as those on a pseudo-color display, operation of the TVLCT procedure, which loads the lookup tables, is unchanged.

Furthermore, if the same image is loaded into each channel, operation of the display mimics that of a standard 8-bit deep pseudo-color display. Most, but not all, IDL image processing procedures written for a standard color display will run on a TrueColor display without modification. The routines that transfer images to the display, TV and TVSCL, write the same 8-bit data to each channel (channel 0) if no channel parameter is present. The function TVRD, which reads data from the display, returns the maximum value contained in the three-color channels for each pixel if no channel parameter is present.

Color Indices

The color index specifier can range from 0 to 224-1. The system variable field !D.N_COLORS, which contains the number of colors, is set to 224 on a TrueColor display.The system variable field, !D.TABLE_SIZE, contains the number of RGB color table elements.

The low 8 bits, bits 0 to 7, of the color index are written to the red channel; bits 8 to 15 are written to the green; and bits 16 to 23 are written to the blue. For example, a given RGB, the index is R + 256(G + 256B). To create a plot with a given color (assuming linear lookup tables), use the following statement:

PLOT, X, Y, COLOR = R + 256L * (G + 256L * B) 

TrueColor Images

Images can be transferred to and from the display in either 8-bit or 24-bit mode. The CHANNEL parameter specifies the source or destination channel number for 8-bit images, and the TRUE keyword indicates for 24-bit images the method of channel interleaving. If neither keyword parameter is present, the 8-bit image is written to all three-color channels, yielding the same effect as if the channel parameter is specified as 0.

For example, to transfer three 8-bit images contained in the arrays R, G, and B to their respective channels, use the following statements:

;Load red in channel 1: 
TV, R, 0, 0, 1 
;Load green in channel 2: 
TV, G, 0, 0, 2 
;Load blue in channel 3: 
TV, B, 0, 0, 3	 

The position parameters (0, 0 above) can be altered to write to any location in the window.

For 24-bit images, the RGB data can be interleaved by pixel, by line, or by image. Use the TRUE parameter to specify the method of interleaving. A c column by l line TrueColor image is dimensioned as follows:

TRUE Value
Dimensions
Interleaving
1 (3, c, l) Pixel
2 (c, 3, l) Line
3 (c, l, 3) Image

For example, to write a TrueColor, line interleaved image contained in the variable t, with its lower-left corner at coordinate (100, 200), use the following statement:

TV, T, 100, 200, TRUE = 2 

Reading Images

To read from the display to an IDL variable or expression, use the TVRD function with either the CHANNEL parameter or TRUE keyword parameter. The calling sequence for TVRD is:

Result = TVRD([X0, Y0, Nx, Ny, Channel])

where (X0Y0) specifies the window coordinate of the lower-left corner of the rectangle to be read, and (NxNy) contains the number of columns and rows to read. Note that all parameters to TVRD are optional. If no arguments are supplied, the entire area of the display device is returned.

When used without the TRUE parameter, TVRD returns an (NxNy) byte image read from the indicated channel. If the channel number is not specified or is zero, the maximum RGB value of each pixel is returned, approximating the luminance.

If present and nonzero, the TRUE keyword indicates that a TrueColor image is to be read and specifies the index of the dimension over which color is interleaved. The result is a (3, NxNy) pixel interleaved array if TRUE is 1; or an (Nx, 3, Ny) line interleaved array if TRUE is 2; or an (NxNy, 3) image interleaved array if TRUE is 3.

Some examples of TVRD follow.

; Read a 512 ´ 512 image, starting at (0, 0), 
; from the red channel into R: 
R = TVRD(0, 0, 512, 512, 1) 
; Read a TrueColor 512 ´ 512, line interleaved image, 
; starting at (0, 0) into T. The variable T is 
; now dimensioned (512, 3, 512): 
T = TVRD(0, 0, 512, 512, TRUE = 2) 
; Read the maximum RGB value of each pixel into L: 
L = TVRD(0, 0, 512, 512) 

Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]