Example: Color Table Manipulator

The following example creates a custom manipulator that allows you to interactively change the palette applied to a single-plane image. After activating the manipulator by selecting the Color Table tool icon on the toolbar, position the cursor over the image and with the mouse button held down, move the mouse to the right or left to change the palette.

Example Code
The class definition code for this example iTool is included in the file example3tool__define.pro in the examples/doc/itools subdirectory of the IDL distribution. Run the example procedure by entering example3tool__define at the IDL command prompt or view the file in an IDL Editor window by entering .EDIT example3tool__define.pro.

A segment of the tool created in this example is shown in the following figure.

Figure 8-2: Custom iTool with Color Table Manipulator

lutmanip.jpg

This example creates three files:

Once you have created and compiled the necessary files, see Running the Color Table Manipulator Example for instructions on how to recreate the display shown in the previous figure.

Color Table Manipulator Class Definition

Define the color table manipulator (example3_manippalette__define.pro). This class definition file initializes the manipulator, creates a cursor, and defines the manipulator actions in response to mouse and keyboard events.

Example Code
The class definition code for this example manipulator is included in the file example3_manippalette__define.pro in the examples/doc/itools subdirectory of the IDL distribution. Run the example procedure by entering example3_manippalette__define at the IDL command prompt or view the file in an IDL Editor window by entering .EDIT example3_manippalette__define.pro.

Custom Tool Class Definition for the Color Table Manipulator

Create the class definition for the tool containing the custom manipulator (example3tool__define.pro). This example inherits the IDLitToolImage class functionality. In the tool initialization, register the custom manipulator. The DESCRIPTION string appears in the status area when the manipulator is activated.

Example Code
The class definition code for this example tool is included in the file example3tool__define.pro in the examples/doc/itools subdirectory of the IDL distribution. Run the example procedure by entering example3tool__define at the IDL command prompt or view the file in an IDL Editor window by entering .EDIT example3tool__define.pro.

Tool Launch Routine for Custom Color Table Manipulator

Create a launch routine (example3tool.pro) for the tool containing the custom color table manipulator. Create an IDLImagePixels type of IDLitData object if the user initializes the tool with a data argument.

Example Code
The class definition code for this example manipulator is included in the file example3_manippalette__define.pro in the examples/doc/itools subdirectory of the IDL distribution. Run the example procedure by entering example3_manippalette__define at the IDL command prompt or view the file in an IDL Editor window by entering .EDIT example3_manippalette__define.pro.

Running the Color Table Manipulator Example

Save and compile all of the files. Enter the following at the command line to reproduce the display shown in Example: Color Table Manipulator.

ctboneFile = FILEPATH('ctbone157.jpg', $ 
   SUBDIRECTORY = ['examples', 'data']) 
READ_JPEG, ctboneFile, ctboneImg 
 
; Launch the example tool with the input data. 
example3tool, ctboneImg 

Select the Color Table tool on the toolbar and move the cursor over the image. Hold down the left-mouse button and drag the cursor to the right and left to scroll through the available color tables. You can also use the right and left arrow keys to modify the color table value.