You are here: Start » Function Reference » Computer Vision » Template Matching » CreateEdgeModel1
Creates a model for edge-based template matching.
Applications: Dynamic creation of models in the runtime environment (normally they are created interactively in Studio).
void avl::CreateEdgeModel1 ( const avl::Image& inImage, atl::Optional<const avl::Region&> inTemplateRegion, atl::Optional<const avl::Rectangle2D&> inReferenceFrame, int inMinPyramidLevel, atl::Optional<int> inMaxPyramidLevel, float inSmoothingStdDev, float inEdgeThreshold, float inEdgeHysteresis, float inMinAngle, float inMaxAngle, float inAnglePrecision, float inMinScale, float inMaxScale, float inScalePrecision, float inEdgeCompleteness, atl::Conditional<avl::EdgeModel>& outEdgeModel, atl::Optional<atl::Conditional<avl::Point2D>&> outEdgeModelPoint = atl::NIL, atl::Optional<atl::Conditional<atl::Array<avl::Path>>&> outEdges = atl::NIL, atl::Conditional<atl::Array<avl::Image> >& diagEdgePyramid )
|inImage||const Image&||Image from which model will be extracted|
|inTemplateRegion||Optional<const Region&>||NIL||Region of the image from which model will be extracted|
|inReferenceFrame||Optional<const Rectangle2D&>||NIL||Exact position of the model object in the image|
|inMinPyramidLevel||int||0 - 12||0||Defines the index of the lowest reduced resolution level used to speed up computations|
|inMaxPyramidLevel||Optional<int>||0 - 12||NIL||Defines the number of reduced resolution levels used to speed up computations|
|inSmoothingStdDev||float||0.0 -||0.0f||Standard deviation of the gaussian smoothing applied before edge extraction|
|inEdgeThreshold||float||0.0 -||35.0f||Higher threshold for edge magnitude|
|inEdgeHysteresis||float||0.0 -||15.0f||Threshold hysteresis value for edge magnitude|
|inMinAngle||float||-180.0f||Start of range of possible rotations|
|inMaxAngle||float||180.0f||End of range of possible rotations|
|inAnglePrecision||float||0.001 - 10.0||1.0f||Defines angular resolution of the matching process|
|inMinScale||float||0.0 -||1.0f||Start of range of possible scales|
|inMaxScale||float||0.0 -||1.0f||End of range of possible scales|
|inScalePrecision||float||0.001 - 10.0||1.0f||Defines scale resolution of the matching process|
|inEdgeCompleteness||float||0.01 - 1.0||1.0f||Determines what fraction of the edges will be present in the created model|
|outEdgeModel||Conditional<EdgeModel>&||Created model that can be used by LocateMultipleObjects_Edges|
|outEdgeModelPoint||Optional<Conditional<Point2D>&>||NIL||The middle point of the created model|
|outEdges||Optional<Conditional<Array<Path>>&>||NIL||Visualization of the model edges found at the original resolution|
|diagEdgePyramid||Conditional<Array<Image> >&||Visualization of the edges found at different resolution levels|
The computation of following outputs can be switched off by passing value
atl::NIL to these parameters: outEdgeModelPoint, outEdges.
Read more about Optional Outputs.
The operation creates an Edge Matching model for the object represented in inTemplateRegion region in inImage image. The resulting model can be matched against any image using the LocateMultipleObjects_Edges1 filter.
The model consists of a pyramid of iteratively downsampled images, the original image being the first of them. The inMaxPyramidLevel parameter determines how many additional images of the pyramid shall be computed. Its value has great influence on computation speed. Therefore it is highly recommended to set its value as high as possible, at the same time ensuring that the model edges are at least 2^inMaxPyramidLevel pixels far from the inImage image frame. However, if it is set too high and no model edges are found on some pyramid level, an error with appropriate description occurs.
The inEdgeThreshold and inEdgeHysteresis parameters control the hysteresis threshold (as in ThresholdImage_Hysteresis) used in the edge extraction (as in DetectEdges_AsRegion) phase of the model creation. It is an important part of using the filter to set these parameters properly, because only found edge pixels determine how good the later matching process will be. Therefore the outEdges and diagEdgePyramid are the crucial parameters for experiments, because they show found edges in the model image and edge pixels found at different resolution levels, respectively.
The inMinAngle and inMaxAngle parameters describe possible rotation angles of the model, i.e. only those object occurrences will be later found by LocateMultipleObjects_Edges1 whose rotation angles are in the range <inMinAngle,inMaxAngle>. The inAnglePrecision parameter controls the angular resolution of the matching process. The model is created in several rotations. The angles of consecutive rotations differ by an angle step from each other. The value of this angle step is determined on the basis of inAnglePrecision. Its value represents the multiplicity of the automatically computed angle step used as an actual step. So the greater inAnglePrecision is, the greater accuracy can be achieved and the lower is the chance of missing object occurrences. In practice however increasing inAnglePrecision above a certain threshold (unique for every object) does not increase the accuracy, only the computation time.
The inReferenceFrame is a characteristic rectangle, the position of which will be returned by LocateMultipleObjects_Edges1 as an occurrence of the object. By default, it is set to the bounding box of the edges found in inTemplateRegion.
Read more about Local Coordinate Systems in Machine Vision Guide: Local Coordinate Systems.
Additional information about Template Matching can be found in Machine Vision Guide: Template Matching
This operation supports automatic parallelization for multicore and multiprocessor systems.
List of possible exceptions:
|DomainError||Incorrect scale range in CreateEdgeModel.|
|DomainError||Minimal pyramid level cannot be greater than maximal pyramid level in CreateEdgeModel.|
|DomainError||Region of interest exceeds an input image in CreateEdgeModel.|
- LocateSingleObject_Edges1 – Finds a single occurrence of a predefined template on an image by comparing object edges.
- LocateMultipleObjects_Edges1 – Finds all occurrences of a predefined template on an image by comparing object edges.