Keywords: front-page

## Lab: Display of Image Attributes

[Exercises] [Workspace]

Purpose: The purpose of this lab is to explore techniques for visually enhancing image features, or attributes, so that the results of an analysis are more easily understood. This experiment describes a procedure to generate an image where the visual appearance of each connected region is associated with its area.

Activities:

1. Import a data set, label it, calculate its statistics, and plot its histogram.

   1. Select and display the image $DIP/data/blobs.kdf.

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

   2. Label the image and display it. Use the Labeling (mmach) operator of the MMACH toolbox.

      1. Glyphs:MMACH:Connected Filters:Labeling (mmach)

   3. Pseudocolor the labeled image with the Autocolor operator, using the "random" colormap option. This enables better visualization of the connected regions.

      1. Glyphs:Visualization:Map Display & Manip:Autocolor
      2. Glyphs:Visualization:Non-Interactive Display:Display Image

   4. Use the Statistics operator to find out the maximum pixel value in the labeled image from Step B (open the operator and select the "maximum" option). This gives the number of regions in the image.

      1. Glyphs:Data Manip:Analysis & Information:Statistics
      2. Glyphs:Input/Output:Information:File Viewer

   5. Take the Histogram of the labeled image (from Step 2) with "Bin width" set to 1 and "Number of bins" set to the number of regions obtained in step D. Print the histogram contents using Print Data. This table gives the area (number of pixels) of each region.

      1. Glyphs:Data Manip:Histogram Operators:Histogram
      2. Glyphs:Input/Output:Information:Print Data
      3. Glyphs:Input/Output:Information:File Viewer

2. Use the table just built (output of Histogram) as a colormap to the labeled image. The resultant image will have pixels representing the area of each connected region. Remember that the background has a large area and the histogram should be modified to have value 0 (black) as the number of pixels with value 0 (background). Perform the following steps:

   1. Change the contents of the histogram at index 0 to 0, using the operators Constant and Inset to put an image of a single pixel of value 0 on the histogram vector at position 0.

      1. Glyphs:Input/Output:Generate Data:Constant
      2. Glyphs:Data Manip:Size & Region Operators:Inset

   2. Transfer the "Value Segment" of the table to "Map Segment" using the Copy from Value operator. Now the file becomes a colormap.

      1. Glyphs:Data Manip:Segment Operators:Copy from Value

   3. Insert the labeled image into the colormap using the operator Insert Segments.

      1. Glyphs:Data Manip:Segment Operators:Insert Segments

   4. Map the colormap through the value data using the Map Data operator.

      1. Glyphs:Data Manip:Map Operators:Map Data

   5. Finally display the image using the Display Image operator. Passing the mouse over a region, the pixel value will indicate its area.

      1. Glyphs:Visualization:Non-Interactive Display:Display Image

Khoros Workspace
Execute the visual program c4s11label-display-area.wk