Keywords: front-page

## Lab: Image Visualization

[Exercises] [Workspace]

Purpose: The purpose of this lab exercise is to use non-interactive and interactive methods to extract regions from an image, and to experiment with various ways of visualizing this data. The second exercise in the lab demonstrates how to extract and plot a 1D intensity profile of an image.

Activities:

1. Extract a region from an image, expand it for a "zoomed" display, print the data values, and visualize the region using a Display 3D Plot.

   1. Read the image $DIP/data/gull.kdf and display it. Select the following operators from the cantata menus

      1. Glyphs:Input/Output:Data Files:User defined
      2. Glyphs:Visualization:Non-Interactive Display:Display Image
      3. Connect these operators

   2. There is an alternative way to select the images used in the course: When the File Browser is opened in the User defined operator, click in the icon on the top left part of the browser. The browser toggles to what is called "Aliases Browser". Select "dip-image:" category and then you can select the image file.
   3. Extract a Region of Interest (ROI) around the seagull's eye using the Extract operator. From the cantata menu, select

      1. Glyphs:Data Manip:Size & Region Operators:Extract
      2. Open the Extract pane, and set the following parameters

             	Region Size: 	Width  10
             			Height 10
             	Region Origin: 	Width 194
             			Height 23

      3. Connect the User defined operator to the Extract operator

   4. Zoom the ROI image for better visualization using the Expand operator. From the cantata menus, select the following operators

      1. Glyphs:Data Manip:Size & Region Operators:Expand
      2. Glyphs:Visualization:Non-Interactive Display:Display Image
      3. Open the Expand pane and select a proper magnification factor.
      4. Connect the output of Expand to the input of Display Image and run the operators to visualize the "zoomed" data

   5. Print the pixel values of the ROI image (10 x 10) by first converting the image to ASCII . From the cantata menus, select the following operators

      1. Glyphs:Input/Output:Export Data:Supported Formats
      2. Glyphs:Input/Output:Information:File Viewer
      3. Open the Supported Formats pane and select "ASCII"
      4. Connect the the output of Extract to Supported Formats
      5. Connect the the output of Supported Formats to File Viewer
      6. Run the operators to print the actual values

   6. Print the data using the Print Data operator in place of Supported Formats. The Print Data operator allows each pixel in a line along with its coordinates. From the cantata menu, select the following operator

      1. Glyphs:Input/Output:Information:Print Data
      2. Connect the output of Extract to Print Data
      3. Connect the output of Print Data to File Viewer
      4. Run these operators to display this type of formatting

   7. Display a surface plot of the ROI image using the operator Display 3D Plot. From the cantata menu, select

      1. Glyphs:Visualization:Plot Display:Display 3D Plot
      2. connect the output of Extract to the input of Display 3D Plot and run Display 3D Plot
      3. Select the following parameters by clicking on the options button of the plot display window:

             	Plot Type:	    Wireframe
             	Rotation About X:   130
             	Rotation About Z:   0
             	Eye Distance:	    1

         In this surface plot, the pixel intensity values are the height information.

2. Use Non-Interactive and Interactive Region of Interest extraction to extract a vertical intensity profile of the image and visualize as an image and as a Display 2D Plot.

   1. Get a vertical intensity profile of the image using the Extract operator. The vertical line extracted is a 1D signal. You can display it using the Display Image operator, but this data can be better visualized using the Display 2D Plot operator. From the cantata menu, select

      1. Glyphs:Data Manip:Size & Region Operators:Extract
      2. Glyphs:Visualization:Plot Display:Display 2D Plot
      3. Open the Extract pane. In this case we are extracting the entire vertical line, thus is is not necessary to specify any parameters in the height direction. Select only the width parameters:

             	Region Size: 	Width  1
             	Region Origin: 	Width  128

      4. Connect the output of the User defined to the input of Extract
      5. Connect the output of Extract to the input of Display 2D Plot
      6. Run these Operators

   2. Get a vertical intensity profile of the image using interactive ROI Extraction. From the cantata menu, select

      1. Glyphs:Visualization:Interactive ROI Extraction:Extract ROI
      2. Open the Extract ROI pane and change the "ROI Presentation" option to "Signal". Select "Line" as the ROI shape.
      3. Close the pane and run Extract ROI
      4. Place the mouse cursor at the top of the image so that the position window reads (128 x 0 = 61). Press the left mouse button down. While keeping the button depressed, drag the cursor down to the bottom of the image, drawing a straight line. Release the mouse button. The line will be extracted, and a plot of it displayed.

Khoros Workspace
Execute the visual program c1s2image-visual.wk