[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:
-
Follow the same steps to build the workspace explained in Lab 1
"Feature Extraction".
-
Create a "feature file" using the Pad operator.
-
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.
-
Glyphs:Data Manip:Size & Region Operators:Pad
-
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.
-
Plot the extracted features which is considered the "feature file"
-
Glyphs:Visualization:Plot Display:Display 2D Plot
-
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
-
Build the reference file using the Extract and Inset operators.
-
Glyphs:Data Manip:Size & Region Operators:Extract (5)
-
Glyphs:Data Manip:Size & Region Operators:Inset (5)
-
Align all five Extract operators vertically.
-
Align four of the five Inset operators vertically and to the
right of the Extract operators.
-
Place the fifth Inset operator to the right of the other four Inset
operators.
-
Connect the Extract and Inset operators to build the "prototyping
file".
-
Connect the output of Pad to each of the five Extract
Operators.
-
Connect the output of the first and second Extract operators to
both inputs of the first Inset operator.
-
Connect the output of the first Inset operator (part ii above)
to the first input of the second Inset operator.
-
Connect the output of the third Extract operator to the second
input of the second Inset operator (part iii above).
-
Connect the output of the second Inset operator to the first
input of the third Inset operator.
-
Connect the output of the fourth Extract operator to the second
input of the third Inset operator.
-
Connect the output of the third Inset operator to the first
input of the fourth Inset operator.
-
Connect the output of the fifth Extract operator to the second
input of the fourth Inset operator.
-
Connect the output the fourth Inset operator to the first input
of the fifth Inset operator.
-
Don't worry about the second input of the fifth Inset operator
right now, you will deal with that later.
-
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
-
Set "Specify Region Origin" Width = 0.
-
All other parameters should be turned off.
-
Open the pane for the second Extract operator and set necessary
parameters to define the "nail" reference object for the "prototyping"
file.
-
Set "Specify Region Size" Width = 1
-
Set "Specify Region Origin" Width = 1.
-
All other parameters should be turned off.
-
Open the pane for the third Extract operator and set necessary
parameters to define the "ring screw" reference object for the
"prototyping" file.
-
Set "Specify Region Size" Width = 1
-
Set "Specify Region Origin" Width = 2.
-
All other parameters should be turned off.
-
Open the pane for the fourth Extract operator and set necessary
parameters to define the "tee-pin" reference object for the
"prototyping" file.
-
Set "Specify Region Size" Width = 1
-
Set "Specify Region Origin" Width = 5.
-
All other parameters should be turned off.
-
Open the pane for the fifth Extract operator and set necessary
parameters to define the "dot noise" reference object for the
"prototyping" file.
-
Set "Specify Region Size" Width = 1
-
Set "Specify Region Origin" Width = 18.
-
All other parameters should be turned off.
-
Open the pane for the first Inset operator and set necessary
parameters to build the "prototyping" file from the extracted
reference objects.
-
Turn on the parameter "Use Input 2 Sub-Object Position"
-
Set the "Width Coordinate" to 1.
-
Open the pane for the second Inset operator and set necessary
parameters.
-
Turn on the parameter "Use Input 2 Sub-Object Position"
-
Set the "Width Coordinate" to 2.
-
Open the pane for the third Inset operator and set necessary
parameters.
-
Turn on the parameter "Use Input 2 Sub-Object Position"
-
Set the "Width Coordinate" to 3.
-
Open the pane for the fourth Inset operator and set necessary
parameters.
-
Turn on the parameter "Use Input 2 Sub-Object Position"
-
Set the "Width Coordinate" to 4.
-
Append a class number to each object in the "element"
direction. You can create sequential class numbers for each of the
object.
-
Use the Piecewise Linear operator to create the sequential class
numbers.
-
Glyphs:Khoros 1:Generate Data:Piecewise Linear
-
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
-
Insert the sequential class numbers as the last element of the
"prototyping" file.
-
Connect the output of Piecewise Linear to the second input of the
fifth Inset operator (see part 3 B x).
-
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.
-
Glyphs:Khoros 1:Classification:Minimum Distance
-
Connect the "feature file" (output of "Pad" to the first input
of Minimum Distance.
-
Connect the "prototyping file" (output of the fifth Inset to
the second input of Minimum Distance.
-
View the classified results.
-
You can view the value data directly using the Print Data
and File Viewer operators.
-
Glyphs:Input/Output:Information:Print Data
-
Glyphs:Input/Output:Information:File Viewer
-
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:
-
Glyphs:Data Manip:Reorganize Data:Switch Axes
-
Connect the output of Minimum Distance to the input of Switch Axes.
-
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
-
Glyphs:Data Manip:Segment Operators:Copy from Value
-
Connect the output of Switch Axes to the input of Copy from Value
-
Open the pane for Copy from Value and set "Select Data
Segments(s)" to Map
-
Glyphs:Data Manip:Segment Operators:Insert Segments
-
Connect the output of Labeling (mmach) to the first input of
"Insert Segments"
-
Connect the output of Copy from Value to the second input of Insert Segments.
-
Glyphs:Data Manip:Map Operators:Map Data
-
Connect the output of Insert Segments to the input of Map Data.
-
Auto color and display the output using the Autocolor
and Display Image operators.
-
Glyphs:Visualization:Map Display & Manip:Autocolor
-
Glyphs:Visualization:Non-Interactive Display:Display Image
-
Connect the output of Map Data to the input of Autocolor.
-
Run the workspace.
Exercises
-
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.
-
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