classPiiShapeContextOperation
#include <PiiShapeContextOperation.h>
An operation that calculates shape descriptors using the Shape Context technique.
Inherits PiiDefaultOperation
Description
Feature points are selected on the boundary curve of an object, and the shape context feature vector is calculated for each.
The shape context is 2-dimensional histogram that stores the occurrences of boundary pixels with respect to a selected key point in polar coordinates. The discretization of the sampling grid can be controlled by the angles and distances properties.
Inputs
limits input. See PiiBoundaryFinderOperation.
boundaries.
Outputs
Properties
|
int
|
The number of quantization bins for angle in the polar coordinate system. |
|
bool
|
Controls the effect of points that are far away from the key point. |
|
int
|
The number of quantization bins for distance in the polar coordinate system. |
|
double
|
A scaling factor for the growing distance bins. |
|
PiiMatching::InvarianceFlags
|
Invariance properties of the descriptor. |
|
Controls how key points are selected on the boundary curves. |
|
|
double
|
The size of the first quantization bin for distance. |
|
int
|
Sample spacing in |
|
Controls how incoming shapes are joined to form objects. |
|
|
double
|
Tolerance in |
Public types
|
enum
|
{ SelectEveryNthPoint, SelectImportantPoints }
Key point selection modes. |
|
enum
|
{ DoNotJoinShapes, JoinNestedShapes, JoinAllShapes }
Different ways of joining shapes into object descriptors. |
Constructors and destructor
Public member functions
|
int
|
( )
|
|
virtual void
|
(
Checks the operation for execution. |
|
bool
|
|
|
int
|
( )
|
|
double
|
( )
|
|
PiiMatching::InvarianceFlags
|
( )
|
|
double
|
( )
|
|
int
|
( )
|
|
void
|
(
|
|
void
|
(
|
|
void
|
(
|
|
void
|
(
|
|
void
|
(
|
|
void
|
|
|
void
|
(
|
|
void
|
(
|
|
void
|
|
|
void
|
(
|
|
( )
|
|
|
double
|
( )
|
Protected member functions
|
virtual void
|
( )
Executes one round of processing. |
Property details
-
int angles
[read, write]The number of quantization bins for angle in the polar coordinate system.
The default value is 8, which means 45 degree wide quantization bins.
-
bool collectDistantPoints
[read, write]Controls the effect of points that are far away from the key point.
If the distance between the key point and another point is greater than minDistance * distanceScale ^ (distances - 1), it is "far away". If this flag is
true, all these points will be collected to the last distance bin. If the value isfalse, the points will be discarded. This makes it possible to switch between a local and global descriptor. The default value isfalse. -
int distances
[read, write]The number of quantization bins for distance in the polar coordinate system.
The default value is five.
-
double distanceScale
[read, write]A scaling factor for the growing distance bins.
The first distance bin will be from zero to minDistance. The second one will be from
minDistancetominDistance*distanceScaleand so on. The last bin will be fromminDistance*distanceScale^ (distances- 2) tominDistance*distanceScale^ (distances- 1). The default value is 2.2. -
PiiMatching::InvarianceFlags invariance
[read, write]Invariance properties of the descriptor.
The shape context descriptor can be made invariant agains rotations (
RotationInvariant) and scale (ScaleInvariant). Other invariance type will be ignored. Rotation invariance is achieved by normalizing the descriptors according to local boundary orientation. Scale invariance is achieved by dividing distances between points by their mean value. In scale invariant mode, minDistance must be set relative to the mean (squared) distance. The default value isRotationInvariant. -
KeyPointSelectionMode keyPointSelectionMode
[read, write]Controls how key points are selected on the boundary curves.
The default value is
SelectEveryNthPoint. -
double minDistance
[read, write]The size of the first quantization bin for distance.
Distance is quantized into growing bins. Everything closer than
minDistancewill be put into the first distance bin. The default value is five. -
int samplingStep
[read, write]Sample spacing in
SelectEveryNthPointmode.The default value is one, which means that every vertex of the incoming boundary polygon is considered a key point.
-
ShapeJoiningMode shapeJoiningMode
[read, write]Controls how incoming shapes are joined to form objects.
The default is
JoinAllShapes. -
double tolerance
[read, write]Tolerance in
SelectImportantPointsmode.The maximum allowed deviation between an original boundary point and a reduced edge. The tolerance is used in
SelectImportantPointsmode to get rid of approximately co-linear boundary points. For example, a value of 5 will allow straightening an edge as far as the maximum deviation from a boundary pixel to the straightened edge is less than 5 pixels. The default value is 3.
Enumeration details
-
enum KeyPointSelectionMode
Key point selection modes.
-
SelectEveryNthPoint- every Nth point of the boundary polygon is selected as a key point. The samplingStep property can be used to change the spacing. -
SelectImportantPoints- select points that are important in preserving the shape of the boundary. In this mode, the operation will first simplify the polygon representing a boundary so that only the end points of approximately co-linear point sequences are retained. These end points are then selected as key points.
-
-
enum ShapeJoiningMode
Different ways of joining shapes into object descriptors.
-
DoNotJoinShapes- every incoming shape is treated as a separate object. The operation will output one shape context descriptor for each incoming boundary, even for nested ones. -
JoinNestedShapes- nested shapes are treated as a single object. In this mode, both inner and outer boundaries of an object will be used in building the shape context descriptor. The number of descriptors varies. -
JoinAllShapes- all incoming shapes are assumed to belong to a single object. Thelimitsinput is not used in this mode.
-
Function details
-
PiiShapeContextOperation
() -
int angles
() -
virtual void check
(- bool reset
[virtual]Checks the operation for execution.
This function creates a suitable flow controller by calling createFlowController(). It then sets the flow controller to the active processor and sets the processor as the input controller for all inputs.
If you change socket groupings in your overridden implementation, please call PiiDefaultOperation::check() after that. Otherwise, your new groupings will not be in effect.
Reimplemented from PiiDefaultOperation.
-
bool collectDistantPoints
() -
int distances
() -
double distanceScale
() -
PiiMatching::InvarianceFlags invariance
() -
KeyPointSelectionMode keyPointSelectionMode
() -
double minDistance
() -
int samplingStep
() -
void setAngles
(- int angles
-
void setCollectDistantPoints
(- bool collectDistantPoints
-
void setDistances
(- int distances
-
void setDistanceScale
(- double distanceScale
-
void setInvariance
(- PiiMatching::InvarianceFlags invariance
-
void setKeyPointSelectionMode
-
void setMinDistance
(- double minDistance
-
void setSamplingStep
(- int samplingStep
-
void setShapeJoiningMode
-
void setTolerance
(- double tolerance
-
ShapeJoiningMode shapeJoiningMode
() -
double tolerance
() -
virtual void process
()[protected, virtual]Executes one round of processing.
This function is invoked by the processor if the necessary preconditions for a new processing round are met. This function does all the necessary calculations to create output objects and sends them to output sockets.
Calls to process(), syncEvent(), and setProperty() are synchronized and cannot occur simultaneously. PiiDefaultOperation ensures this by locking processLock() for reading before calling process().
Note: With time-consuming operations, one should occasionally check that the operation hasn't been interrupted, i.e. that state() returns
Running.Exceptions
- PiiExecutionException
-
whenever an unrecoverable error occurs during a processing round, the operation is interrupted, or finishes execution due to end of input data.
Reimplemented from PiiDefaultOperation.
Add a note
Not a single note added yet. Be the first, add yours.