Keywords: front-page

## Lab: Building Pseudo Color Tables

[Exercises] [Workspace]

Purpose: The purpose of this experiment is to demonstrate how to build a pseudo-color table suitable for images.

Activities:

1. Convert the image $DIP/data/head.kdf to "Unsigned Short" with Convert Type operator and visualize with Display Image operator.

   1. Glyphs:Input/Output:Data Files:User defined
   2. Glyphs:Data Manip:Data Conversion:Convert Type
   3. Glyphs:Visualization:Non-Interactive Display:Display Image

2. From the image $DIP/data/head.kdf, extract its maximum and minimum values into the cantata variables "val_max" and "val_min" respectively. Use the operator Print Stats.

   1. Glyphs:Data Manip:Analysis & Information:Print Stats
   2. Open the Print Stats menu and select the "Minima Value" and "Maxima Value" parameters.

3. Build the sinusoidal color table.

   1. Use the Sinusoid operator to build the Green component of the color table.

      1. Glyphs:Input/Output:Generate Data:Sinusoid

                    Width               = 1
                    Height              = val_max - val_min + 1
                    Height Phase Offset = -90
                    Other parameters (default)

   2. Duplicate the Sinusoid operator to build the Blue component of the color table.

      1. Open the pane of the Sinusoid glyph and set the parameters

                    Width               = 1
                    Height              = val_max - val_min + 1
                    Height Phase Offset = 0
                    Other parameters (default)

   3. Use the Negative operator connected to the Blue sinusoid component to generate the Red component.
   4. Plot these three sinusoidal signals using the Interactive 2D/3D Plot glyph

      1. Glyphs:Visualization:Plot Display:Interactive 2D/3D Plot
      2. Before running this network, to assure that the variables "val_min" and "val_man" are set before the Sinusoid glyphs, connect the output control connection of Print Stats to the input control connections of the Sinusoid glyphs.

4. Append these three signals together in the Width dimension in the following order: Red, Green and Blue. Use the Append operator.

   1. Glyphs:Data Manip:Size & Region Operators:Append
   2. Open the Append glyph and select the width dimension to append the signals

5. Normalize and convert the data to "unsigned byte" in the range of 0 255, using the Normalize operator connected to the output of the Append operator.

   - Glyphs:Data Manip:Data Conversion:Normalize
   - Open the Normalize operator and set "Unsigned Byte" as the output data type.

6. Append this normalized color table to a constant color table with zeros with size 3 x "val_min"

   1. Glyphs:Input/Output:Generate Data:Constant
   2. Open the Constant glyph and set the parameters

                 Width  = 3
                 Height = val_min

   3. Connect the output control connection of the Print Stats glyph to the input control connection of the Constant glyph.

7. Duplicate the Append glyph, connect the output of the Constant glyph to its first input and the output of the Normalize glyph to its second input. Open its pane and set "Height" as the dimension to append the data.
8. Convert this data into a Map colortable using the Copy from Value operator and display the colortable using the Display Palette operator.

   1. Glyphs:Data Manip:Segment Operators:Copy from Value
   2. Glyphs:Visualization:Map Display & Manip:Display Palette
   3. Open the Copy from Value glyph and select "Map" and the segment to copy the data to.

9. Apply this colortable to the "Unsigned Short" image. Use the following glyphs:

   1. Glyphs:Data Manip:Segment Operators:Insert Segments
   2. Glyphs:Data Manip:Map Operators:Map Data
   3. Glyphs:Data Manip:Object Attributes:Set Attribute
   4. Glyphs:Visualization:Non-Interactive Display:Display Image
   5. Open the Set Attribute operator and select RGB as the color model

Khoros Workspace
Execute the visual program c4s10build-pseudo-color.wk