Keywords: front-page

## Lab: Contours

[Exercises] [Workspace]

Purpose: The purpose of this lab exercise is to use mathematical morphology to define contours of a binary image, and to show how this operation can be applied to analyze object perimeters.

Activities:

1. Read 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. Use the 3x3 Str.El. operator to build a 3x3 "cross" structure element.

   1. Glyphs:MMACH:Structural Element:3x3 Str.El.

3. Use the Erosion and Subtract operators to generate the contour of the blobs image. Display the resulting contour image.

   1. Glyphs:MMACH:Dilation and Erosion:Erosion
   2. Glyphs:Arithmetic:Two Operand Arithmetic:Subtract
   3. Glyphs:Visualization:Non-Interactive Display:Display Image

4. Label the contour image with the Labeling (mmach) operator. Which connectivity you should use in this operator? Display the results of the labeling operation.

   1. Glyphs:MMACH:Connected Filters:Labeling (mmach)
   2. Glyphs:Visualization:Non-Interactive Display:Display Image

5. Calculate and plot the Histogram of the labeled contour image. Use the Statistics operator to determine the number of labeled regions and set the "Bin width" to this value. Set the histogram "Minimum" to 1 so that the background count is not included in the histogram. View the histogram as a discrete plot.

   1. Glyphs:Data Manip:Analysis & Information:Statistics
   2. Glyphs:Data Manip:Histogram Operators:Histogram
   3. Glyphs:Visualization:Plot Display:Display 2D Plot

Exercises

1. Try other forms of contour: dilation - original.
2. Try other contour topology: 3x3 box, 8-connected contour.

Khoros Workspace
Execute the visual program c9s5contour.wk