Lab: Image Display/Data Type Conversion

[Exercises] [Workspace]

Purpose: The purpose of this lab is to demonstrate effects due to data type conversions. The lab exercises will also help to develop an awareness of transformations that occur when data is displayed by the image display routines.

Activities:

  1. Generate a sine wave and experiment with data type conversion.

    1. Generate a synthetic sine wave in the horizontal direction of size 128x128, amplitude 2.0, and data type "float". Use the following operator from the cantata menus

      1. Glyphs:Input/Output:Generate Data:Sinusoid
      2. Open the Sinusoid pane
      3. Set the size to be 128 x 128
      4. To generate a sine wave of amplitude 2.0 along along the horizontal dimension, select the "sin(w+h+d+t+e)" option and set "Amplitude" to 2.0. Set the "Number of sine waves" to 1.0 along Width, and to 0 along all other dimensions.
      5. Set the "Data Type" parameter to float and close the pane.
      6. Verify the sinusoid properties by extracting a horizontal line using Glyphs:Data Manip:Size & Region Operators:Extract and plot it using Glyphs:Visualization:Plot Display:Display 2D Plot.
      7. Display the sinusoidal image using Glyphs:Visualization:Non-Interactive Display:Display Image

    2. Insert a Convert Type operator into the network, and set up Display Image and Display 2D Plot to automatically place the image and plot on screen. This can be done by selecting the following operator from the cantata menus:

      1. Glyphs:Data Manip:Data Conversion:Convert Type
      2. Insert Convert Type into the network you created in part A after the Sinusoid operator. Connect the output of Convert Type to both the Display Image operator and the Extract operator. This will allow you to watch both the image and the signal as you run the experiments in part C.
      3. To make the plot automatically place on the screen, open the Display 2D Plot pane, select the "X Window Placement" option, and set it to -1. Select "Y Window Placement" and set it to 0. This will place the plot in the upper right hand corner of your screen.
      4. To reduce the size of the 2D Plot window, in the Display 2D Plot pane select "Window Width" and set it to 256; select "Window Height" and set it to 128. Close the pane.
      5. To automatically place the image, open the Display Image pane, set both the "X Window Placement" and the "Y Window Placement" to 1. This will place the image in the upper left hand corner of your screen.

    3. Modify the parameters for the Convert Type operator to perform the following experiments. You may wish to leave the Convert Type pane open, since you will be making several changes there. If you change a live field (indicated by a lightening bolt), you must hit return for the change to take effect.

      1. Set "Output Data Type" to Bit. Select the "Run" button on the Convert Type pane, then run the rest of the workspace by selecting the "Run Workspace" icon on the tool bar.

        Discussion: Converting the original float image to bit sets all data values greater than zero to 1 and all values less than or equal to zero to 0. Note that all zeros are displayed as black, and all 1's are displayed as white.

      2. Set "Output Data Type" to Byte. Run the operators.

        Discussion: Converting to byte results in 5 levels, which is the integer quantization of the floating point sinusoid ranging from -2 to +2. Note again that the lowest value is displayed as black, the highest level as white, and the other values are displayed as intermediate grey shades.

      3. Set "Output Data Type" to Byte, Scaling Factor of 255/4

        Discussion: This conversion provides a larger range of integer data values, producing a better image of the sinusoid.

      4. Set "Output Data Type" to Unsigned Byte (Remember to set the "Scale Factor" back to 1)
      5. Set "Output Data Type" to Unsigned Byte, Scaling Factor of 255/4, Offset Value of 128
      6. Set "Output Data Type" to Complex (Set the "Scale Factor" back to 1, and the "Offset Value" to 0)


Exercises

  1. Repeat the same experiments using the types Short, Unsigned Short, Integer, and Unsigned Integer.
  2. Convert a floating point image into an unsigned byte (o to 255) image, preserving the integrity of the image as much as possible. Implement 2 solutions. The first using the operator Convert Type, and the other using the operator Normalize.


Khoros Workspace
Execute the visual program c1s5display-type.wk



Main DIP Menu
DIP Feedback Form
Copyright © 1997-1995 KRI, ISTEC, Ramiro Jordán, Roberto Lotufo. All Rights Reserved