|
IDL Reference Guide: Procedures and Functions |
|
The XPALETTE procedure is a utility that displays a widget interface that allows interactive creation and modification of color tables using the RGB, CMY, HSV, or HLS color systems. This procedure can interpolate the space between color indices (to create smooth color transitions) or edit individual colors.
This routine is written in the IDL language. Its source code can be found in the file xpalette.pro in the lib/utilities subdirectory of the IDL distribution.
Calling XPALETTE causes a graphical interface to appear. The elements of this interface are described below.
Three plots show the current red, green, and blue vectors.
The center of the XPALETTE widget is a status region containing:
A panel of 8 buttons control common XPALETTE functions:
This section of the interface allows you to select the color system used to modify individual colors. The "Select Color System" pulldown menu lets you select from four different systems—RGB, CMY, HSV, and HLS. Depending upon the current system, 3 sliders below the pulldown menu allow you to alter the current color.
A display on the right side of the XPALETTE interface shows the current color map as a series of squares. Color index 0 is at the upper left. The color index increases monotonically by rows going left to right and top to bottom. The current color index is indicated by a special marker symbol. There are 4 ways to change the current color:
XPALETTE uses two colors from the current color table as drawing foreground and background colors. These are used for the RGB plots on the left, and the current index marker on the right. This means that if the user set these two colors to the same value, the XPALETTE display could become unreadable (like writing on black paper with black ink). XPALETTE minimizes this possibility by noting changes to the color map and always using the brightest available color for the foreground color and the darkest for the background. Thus, the only way to make XPALETTE's display unreadable is to set the entire color map to a single color, which is highly unlikely. The only side effect of this policy is that you may notice XPALETTE redrawing the entire display after you've modified the current color. This simply means that the change has made XPALETTE pick new drawing colors.
XPALETTE [, /BLOCK] [, GROUP=widget_id] [, UPDATECALLBACK=`procedure_name' [, UPDATECBDATA=value]]
None
Set this keyword to have XMANAGER block when this application is registered. By default, BLOCK is set equal to zero, providing access to the command line if active command line processing is available. Note that setting BLOCK=1 will cause all widget applications to block, not just this application. For more information, see the documentation for the NO_BLOCK keyword to XMANAGER.
| Note Only the outermost call to XMANAGER can block. Therefore, to have XPALETTE block, any earlier calls to XMANAGER must have been called with the NO_BLOCK keyword. See the documentation for the NO_BLOCK keyword to XMANAGER for an example. |
The widget ID of the widget that calls XPALETTE. When this ID is specified, a death of the caller results in a death of XPALETTE.
Set this keyword to a string containing the name of a user-supplied procedure that will be called when the color table is updated by XLOADCT. The procedure may optionally accept a keyword called DATA, which will be automatically set to the value specified by the optional UPDATECBDATA keyword.
Set this keyword to a value of any type. It will be passed via the DATA keyword to the user-supplied procedure specified via the UPDATECALLBACK keyword, if any. If the UPDATECBDATA keyword is not set the value accepted by the DATA keyword to the procedure specified by UPDATECALLBACK will be undefined.
This example uses a single color (orange) to highlight pixels within the spine of the CT scan image. Then, starting with the entry that was changed to orange, a range of entries is selected and replaced with a ramp from orange to white to highlight the bones within this image. Complete the following steps for a detailed description of the process.
| Example Code See usingxpalette.pro in the examples/doc/image subdirectory of the IDL installation directory for code that duplicates this example. The BLOCK keyword is set when using XPALETTE to force the example routine to wait until the Done button is pressed to continue. If the BLOCK keyword was not set, the example routine would produce all of the displays at once and then end. |
ctscan.dat binary file:
ctscanFile = FILEPATH('ctscan.dat', $
SUBDIRECTORY = ['examples', 'data'])
ctscanSize = [256, 256]
ctscanImage = READ_BINARY(ctscanFile, $ DATA_DIMS = ctscanSize)
DEVICE, DECOMPOSED = 0
ctscan.dat file with the B-W LINEAR color table:LOADCT, 0 WINDOW, 0, TITLE = 'ctscan.dat', $ XSIZE = ctscanSize[0], YSIZE = ctscanSize[1] TV, ctscanImage
As shown in the following figure, the B-W LINEAR color table does not distinguish all of the aspects of this image. The XPALETTE utility can be used to change the color table.
![]() |
XPALETTE
Select the Predefined button in the XPALETTE utility to change the color table to Rainbow + white.
Click on the Done button after you select the Rainbow + white color table in XLOADCT and then click on the Done button in XPALETTE.
The following figure shows the resulting XPALETTE and XLOADCT displays.
![]() |
TV, ctscanImage
![]() |
You can use XPALETTE to change a single color within the current color table. For example, you can change the color at index number 115 to orange.
XPALETTE
Change its color to orange by moving the RGB (red, green, and blue) sliders (Orange is made up of 255 red, 128 green, and 0 blue)
Click on the Done button after changing the Red, Green, and Blue sliders.
Use TV to redisplay the image to include the last changes made in the XPALETTE utility:
TV, ctscanImage
The orange values now highlight some areas of the spine, kidney, and bones as shown in the following figure.
![]() |
You can highlight the bones even further by interpolating a new range in between the orange and white indices.
Click on the 115th index and select the Set Mark button.
Click on the highest index (which is usually 255 but it could be less) and then select the Interpolate button.
To see the result of this interpolation within XPALETTE, click on the Redraw button.
Click Done and redisplay the image:
TV, ctscanImage
The following figure displays the image using the modified color table.
![]() |
| Note You can add this modified color table to the list of pre-defined color tables using MODIFYCT. See the "Examples" section of MODIFYCT. |
LOADCT, MODIFYCT, XLOADCT, TVLCT
IDL Online Help (March 06, 2007)