Keywords: front-page

## Lab: Data Representation

[Exercises] [Workspace]

Purpose: The purpose of this lab exercise is to become familiar with image data representation and display, and how to acquire and use data object information.

Activities:

1. Display an image and print the header information

   1. Specify an image: Select the following from cantata's category pulldown menus

      1. Glyphs:Input/Output:Data Files:User defined
      2. Open the pane for User defined by clicking in its top left corner.
      3. In the pane, select the "Input File" button to invoke the browser
      4. Clear the text in the "Directory / Filename:" field and type:"$DIP/data/" and hit return. This will update the browser with a listing of the files in that data directory.
      5. Select the image "gull.kdf"
      6. Close the User defined pane

   2. Print data object information: Select the following from cantata's category pulldown menus

      1. Glyphs:Input/Output:Information:Data Object Info
      2. Glyphs:Input/Output:Information:File Viewer
      3. Connect the output of User defined to the input of Data Object Info by clicking in the correspondent colored squares.
      4. Connect the output of Data Object Info to the input of File Viewer
      5. Run the Data Object Info operator by clicking in the button in the middle of the operator.
      6. Run the File Viewer operator

         The file viewer shows that this data object only has value data, the pixel data type is unsigned byte, and the sizes of the value data are Width = 256, Height = 256, Depth = 1, Time = 1, Element = 1

   3. Display the image: Select the following from cantata's category pulldown menus

      1. Glyphs:Visualization:Non-Interactive Display:Display Image
      2. Connect the output of User defined to the input of Display Image
      3. Run the Display Image Operator
      4. Move mouse around the image window and observe the pixel values at the specified location indicated in the position window (at the lower left, below the image).
      5. To exit the display operator, click on the "Quit" button, press the "q" key, or perform a double-click in the display window.

2. Examples of Images with Distinct Data Types

   1. Image of type BIT

      1. Open the pane for User defined
      2. Select the "Input File" button to invoke the browser
      3. Select $DIP/data/numbers.pbm
      4. Run the workspace.

         This image value data type is bit, and its size is:

         Width = 162, Height = 117, Depth = 1, Time = 1, Element = 1.

         Only two values can be represented by bit data, 0 and 1. The display program shows the actual values of each pixel in the position window. Note that if the display program displayed the true grey levels of 0 and 1 on the screen, you would not be able to see the numbers in the image; 0 and 1 are so close that the image would look entirely black. To compensate for this, the Display Image operator internally normalizes the data between 0 and the maximum number of grey levels that can be displayed by your screen (ie., 0 - 255 for an 8-plane display). This is done for display purposes only; the data values are not altered.

   2. Image of type FLOAT

      1. Select $DIP/data/log-enhance-problem.kdf in the User defined pane as you did before.
      2. Run the workspace.

         This image value data type is Float, and its size is:

         Width = 128, Height = 128, Depth = 1, Time = 1, Element = 1.

         As was described above with bit data, the actual data values are printed in the position window of the Display Image operator, but the data has been internally normalized for display purposes.

   3. Image of type COMPLEX

      1. Select $DIP/data/2dfft.kdf in the User defined pane as you did before.
      2. Run the workspace.

         The data type of this image is Complex, and its size is :

         Width = 128, Height = 128, Depth = 1, Time = 1, Element = 1.

         You may need to resize the display window with the window manager to view the complex values printed in the position window. To visualize the complex data, the Display Image operator first calculates a real values for the data (log(magnitude + 1)), and then normalizes those values.

   4. Color image, 3 elements (RGB) per pixel, pixel type Unsigned Byte

      1. Select $DIP/data/gull-color.kdf in the User defined pane as you did before.
      2. Run the workspace.

         The data type of this image is Unsigned byte; this object has a Color Space Model defined as RBG; its size is:

         Width = 256, Height = 256, Depth = 1, Time = 1, Element = 3. The values of all 3 elements for each pixel are printed in the position window.

3. Visualization using Plots

   1. Plot a 1D signal

      1. Select $DIP/data/heart-beat-signal.kdf in the User defined pane as you did before.
      2. From the cantata menu, select Glyphs:Visualization:Plot Display:Display 2D Plot
      3. Connect the output of User defined to the input of Display 2D Plot
      4. Delete the Display Image operator by selecting it and choosing the menu `Edit : Delete`.
      5. Run the workspace.

         This data sequence has size of Width = 701, and Height, Depth, Time and Elements = 1. The data type is double.

4. Animation, or Sequencing, of Multiple Images

   1. Animation of a Volume

      1. Select $DIP/data/bluntfin.kdf in the User defined pane as you did before.
      2. From the cantata menu, select Glyphs:Visualization:Interactive Display:Animate
      3. Connect the output of User defined to the input of Animate
      4. Delete the Display 2D Plot operator
      5. Run the workspace.

         The data type of this object is Float, and its size is:

         Width = 40, Height = 32, Depth = 32, Time = 1, Elements = 1. To watch the animation through depth, select the run button.

5. Save the workspace by selecting File:Save As... pulldown menu. In this way, you can later recover the workspace by opening it with the menu File:Open.
6. Clear the workspace for the next lesson.

Exercises

1. Extract and interpret the header information of the following images: $DIP/data/ruler.kdf and $DIP/data/spine.kdf.

Khoros Workspace
Execute the visual program c1s1data-representation.wk