You are here: Start » AVL.NET » AVL.CreateEdgeModel

AVL.CreateEdgeModel

Creates a model for edge-based template matching.

Namespace:AvlNet
Assembly:AVL.NET.dll

Syntax

C++
C#
 
public static void CreateEdgeModel
(
	AvlNet.Image inImage,
	NullableRef<AvlNet.Region> inTemplateRegion,
	AvlNet.Rectangle2D? inReferenceFrame,
	int inMinPyramidLevel,
	int? inMaxPyramidLevel,
	float inSmoothingStdDev,
	float inEdgeThreshold,
	float inEdgeHysteresis,
	float inMinAngle,
	float inMaxAngle,
	float inAnglePrecision,
	float inMinScale,
	float inMaxScale,
	float inScalePrecision,
	float inEdgeCompleteness,
	INullable<AvlNet.EdgeModel> outEdgeModel,
	out AvlNet.Point2D? outEdgeModelPoint,
	INullable<SafeList<AvlNet.Path>> diagEdges,
	INullable<SafeList<AvlNet.Image>> diagEdgePyramid
)

Parameters

Name Type Range Default Description
inImageAvlNet.ImageImage from which model will be extracted.
inTemplateRegionAvlNet.NullableRef<AvlNet.Region>Region of the image from which model will be extracted. Default value: atl::NIL.
inReferenceFrameAvlNet.Rectangle2D?Exact position of the model object in the image. Default value: atl::NIL.
inMinPyramidLevelint<0, 12>0Defines the index of the lowest reduced resolution level used to speed up computations. Default value: 0.
inMaxPyramidLevelint?<0, 12>Defines the number of reduced resolution levels used to speed up computations. Default value: atl::NIL.
inSmoothingStdDevfloat<0.0f, INF>0.0fStandard deviation of the gaussian smoothing applied before edge extraction. Default value: 0.0f.
inEdgeThresholdfloat<0.0f, INF>35.0fHigher threshold for edge magnitude. Default value: 35.0f.
inEdgeHysteresisfloat<0.0f, INF>15.0fThreshold hysteresis value for edge magnitude. Default value: 15.0f.
inMinAnglefloat-180.0fStart of range of possible rotations. Default value: -180.0f.
inMaxAnglefloat180.0fEnd of range of possible rotations. Default value: 180.0f.
inAnglePrecisionfloat<0.001f, 10.0f>1.0fDefines angular resolution of the matching process. Default value: 1.0f.
inMinScalefloat<0.0f, INF>1.0fStart of range of possible scales. Default value: 1.0f.
inMaxScalefloat<0.0f, INF>1.0fEnd of range of possible scales. Default value: 1.0f.
inScalePrecisionfloat<0.001f, 10.0f>1.0fDefines scale resolution of the matching process. Default value: 1.0f.
inEdgeCompletenessfloat<0.01f, 1.0f>1.0fDetermines what fraction of the edges will be present in the created model. Default value: 1.0f.
outEdgeModelAvlNet.INullable<AvlNet.EdgeModel>Created model that can be used by LocateMultipleObjects_Edges. This parameter cannot be null.
outEdgeModelPointAvlNet.Point2D?The middle point of the created model.
diagEdgesAvlNet.INullable<AvlNet.SafeList<AvlNet.Path>>Visualization of the model edges found at the original resolution. This parameter cannot be null.
diagEdgePyramidAvlNet.INullable<AvlNet.SafeList<AvlNet.Image>>Visualization of the edges found at different resolution levels. This parameter cannot be null.

Description

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_Edges 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 diagEdges 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_Edges 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_Edges as an occurrence of the object. By default, it is set to the bounding box of the edges found in inTemplateRegion.

Examples

Following example creates an EdgeModel object for loaded mount.jpg image. It is a part of the bigger Basic Template Matching Example.

SafeNullableRef<EdgeModel> model = Nullable.CreateSafe<EdgeModel>();
    using (var modelImage = new Image())
    {
        AVL.LoadImage("mount.jpg", false, modelImage);
        AVL.CreateEdgeModel(modelImage, 0, 0.0f, 35.0f, 15.0f, 0.0f, 360.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, model);
    }

Remarks

For more information about local coordinate systems please refer to the following article.

Additional information about Template Matching can be found in Machine Vision Guide: Template Matching

Hardware Acceleration

This operation supports automatic parallelization for multicore and multiprocessor systems.

Hardware acceleration settings may be manipulated with Settings class.

Errors

List of possible exceptions:

Error type Description
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.

Function Overrides

See also