Lab: Classification

[Exercises] [Workspace]

Purpose: The purpose of this exercise is to classify the image features extracted in Lab 1. This involves creating a "feature file" and a "prototyping file". The feature file corresponds to the features extracted previously and the prototyping file contains a sample of each class along with a class number. These two files combined are used to perform minimum distance classification.

Activities:

  1. Follow the same steps to build the workspace explained in Lab 1 "Feature Extraction".
  2. Create a "feature file" using the Pad operator.

    1. Once the selected features have been extracted using Shape Analysis, set the background to object 0 and its feature value to -1 using the Pad operator.

      1. Glyphs:Data Manip:Size & Region Operators: Pad

      2. Open the pane for Pad and set a couple of parameters.

        Set the "Padded Width" to 27 which corresponds to the number of objects extracted by "Shape Analysis". You can confirm this by examining the "ASCII File" output of Shape Analysis. Set the "Real Pad Value" to -1 which will represent the feature value.

    2. Plot the extracted features which is considered the "feature file"

      1. Glyphs:Visualization:Plot Display: Display 2D Plot

  3. First, create a "prototyping file" which contains one sample of each class and the class number for that sample. This "prototyping file" will be used along with the "feature file" above to classify the objects. To build the "prototyping file", keep from the "feature file" (part 2 B above) only the objects that will be used as reference. The reference objects you will use are listed as follows:

    Background: Object 0

    Nail: Object 1

    Ring Screw: Object 2

    Tee-Pin: Object 5

    Dot Noise: Object 18

    1. Build the reference file using the Extract and Inset operators.

      1. Glyphs:Data Manip:Size & Region Operators: Extract (5)

      2. Glyphs:Data Manip:Size & Region Operators: Inset (5)

      3. Align all five Extract operators vertically.
      4. Align four of the five Inset operators vertically and to the right of the Extract operators.
      5. Place the fifth Inset operator to the right of the other four Inset operators.

    2. Connect the Extract and Inset operators to build the "prototyping file".

      1. Connect the output of Pad to each of the five Extract Operators.
      2. Connect the output of the first and second Extract operators to both inputs of the first Inset operator.
      3. Connect the output of the first Inset operator (part ii above) to the first input of the second Inset operator.
      4. Connect the output of the third Extract operator to the second input of the second Inset operator (part iii above).
      5. Connect the output of the second Inset operator to the first input of the third Inset operator.
      6. Connect the output of the fourth Extract operator to the second input of the third Inset operator.
      7. Connect the output of the third Inset operator to the first input of the fourth Inset operator.
      8. Connect the output of the fifth Extract operator to the second input of the fourth Inset operator.
      9. Connect the output the fourth Inset operator to the first input of the fifth Inset operator.
      10. Don't worry about the second input of the fifth Inset operator right now, you will deal with that later.
      11. Open the pane for the first Extract operator and set necessary parameters to define the "background" reference object for the "prototyping" file.

        i. Set "Specify Region Size" Width = 1

      12. Set "Specify Region Origin" Width = 0.
      13. All other parameters should be turned off.

    3. Open the pane for the second Extract operator and set necessary parameters to define the "nail" reference object for the "prototyping" file.

      1. Set "Specify Region Size" Width = 1
      2. Set "Specify Region Origin" Width = 1.
      3. All other parameters should be turned off.

    4. Open the pane for the third Extract operator and set necessary parameters to define the "ring screw" reference object for the "prototyping" file.

      1. Set "Specify Region Size" Width = 1
      2. Set "Specify Region Origin" Width = 2.
      3. All other parameters should be turned off.

    5. Open the pane for the fourth Extract operator and set necessary parameters to define the "tee-pin" reference object for the "prototyping" file.

      1. Set "Specify Region Size" Width = 1
      2. Set "Specify Region Origin" Width = 5.
      3. All other parameters should be turned off.

    6. Open the pane for the fifth Extract operator and set necessary parameters to define the "dot noise" reference object for the "prototyping" file.

      1. Set "Specify Region Size" Width = 1
      2. Set "Specify Region Origin" Width = 18.
      3. All other parameters should be turned off.

    7. Open the pane for the first Inset operator and set necessary parameters to build the "prototyping" file from the extracted reference objects.

      1. Turn on the parameter "Use Input 2 Sub-Object Position"
      2. Set the "Width Coordinate" to 1.

    8. Open the pane for the second Inset operator and set necessary parameters.

      1. Turn on the parameter "Use Input 2 Sub-Object Position"
      2. Set the "Width Coordinate" to 2.

    9. Open the pane for the third Inset operator and set necessary parameters.

      1. Turn on the parameter "Use Input 2 Sub-Object Position"
      2. Set the "Width Coordinate" to 3.

    10. Open the pane for the fourth Inset operator and set necessary parameters.

      1. Turn on the parameter "Use Input 2 Sub-Object Position"
      2. Set the "Width Coordinate" to 4.

  4. Append a class number to each object in the "element" direction. You can create sequential class numbers for each of the object.

    1. Use the Piecewise Linear operator to create the sequential class numbers.

      1. Glyphs:Khoros 1:Generate Data: Piecewise Linear

      2. Set the following parameters:

        Number Rows = 1

        Number Cols = 5 (for the 5 objects)

        Number Bands = 1

        Sampling Freq = 1

        Minimum Value = 0

        Maximum Value = 5

        X Period = 5

        Y Period = 1

        X Rise Time = 5

        Y Rise Time = 0

        X and Y Fall times both = 0

        X and Y Pulse Widths both = 0

    2. Insert the sequential class numbers as the last element of the "prototyping" file.

      1. Connect the output of Piecewise Linear to the second input of the fifth Inset operator (see part 3 B x).

  5. Classify the data using the Minimum Distance classify operator. Note that this operator assigns to each object the closest class according to the feature distance.

    1. Glyphs:Khoros 1:Classification: Minimum Distance

    2. Connect the "feature file" (output of "Pad" to the first input of Minimum Distance.
    3. Connect the "prototyping file" (output of the fifth Inset to the second input of Minimum Distance.

  6. View the classified results.

    1. You can view the value data directly using the Print Data and File Viewer operators.

      1. Glyphs:Input/Output:Information: Print Data

      2. Glyphs:Input/Output:Information: File Viewer

    2. Display the classified image by creating map segment which contains the feature classification data (output from Minimum Distance). This can be done using the following operators:

      1. Glyphs:Data Manip:Reorganize Data: Switch Axes

      2. Connect the output of Minimum Distance to the input of Switch Axes.
      3. Open the pane for Switch Axes and set the following:

        Assign Input Width to Output: Height

        Assign Input Height to Output: Width

        Assign Input Height to Output: Depth

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

      5. Connect the output of Switch Axes to the input of Copy from Value
      6. Open the pane for Copy from Value and set "Select Data Segments(s)" to Map
      7. Glyphs:Data Manip:Segment Operators: Insert Segments

      8. Connect the output of Labeling (mmach) to the first input of "Insert Segments"
      9. Connect the output of Copy from Value to the second input of Insert Segments.
      10. Glyphs:Data Manip:Map Operators: Map Data

      11. Connect the output of Insert Segments to the input of Map Data.

    3. Auto color and display the output using the Autocolor and Display Image operators.

      1. Glyphs:Visualization:Map Display & Manip: Autocolor

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

      3. Connect the output of Map Data to the input of Autocolor.
      4. Run the workspace.


Exercises

  1. Using the same technique as in the "Area Distribution" lab (Lab 11 of the "Image Manipulation" section), assign the class value to each classified object pixel. Remember that the output of the Minimum Distance classify is a "width" vector and a color table is a "height" vector.
  2. Use more features for the classification. For instance, use the first three invariant moments.


Khoros Workspace
Execute the visual program c10s2shape-classify.wk



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