Back to Adaptive Vision Library website

You are here: Start » Function Reference » Image Analysis » CompareGoldenTemplate_Edges

CompareGoldenTemplate_Edges


Header: AVL.h
Namespace: avl
Module: FoundationPro

Compares image edges with the edges of a perfect template. Significant differences are considered defects.

Syntax

C++
C#
 
void avl::CompareGoldenTemplate_Edges
(
	const avl::Image& inImage,
	const avl::EdgeGoldenTemplate& inGoldenTemplate,
	const avl::CoordinateSystem2D& inGoldenTemplateAlignment,
	float inStdDevX,
	atl::Optional<float> inStdDevY,
	float inEdgeThreshold,
	float inEdgeHysteresis,
	int inMaxDistance,
	avl::Region& outDefects,
	bool& outDefectsPresent,
	avl::Region& outMissingEdges,
	avl::Region& outExcessiveEdges,
	atl::Optional<avl::Region&> outImageEdges = atl::NIL,
	atl::Optional<avl::Region&> outGoldenEdges = atl::NIL,
	atl::Optional<avl::Region&> outMatchingEdges = atl::NIL,
	atl::Optional<avl::Rectangle2D&> outObjectPosition = atl::NIL
)

Parameters

Name Type Range Default Description
inImage const Image& Input image
inGoldenTemplate const EdgeGoldenTemplate& Golden edge template containing image with no defects
inGoldenTemplateAlignment const CoordinateSystem2D& Adjusts the golden template to the position of the inspected object
inStdDevX float 0.0 - 2.0f Amount of horizontal smoothing used by the edge filter
inStdDevY Optional<float> 0.0 - NIL Amount of vertical smoothing used by the edge filter (Auto = inStdDevX)
inEdgeThreshold float 0.0 - 35.0f Sufficient edge strength; edges of that strength will always be detected on the input image
inEdgeHysteresis float 0.0 - 15.0f Value by which the edge threshold is decreased for edge points neighboring with sufficiently strong edges
inMaxDistance int 0 - 3 Maximal allowed distance between corresponding edges on the input and golden image
outDefects Region& Region of detected defects
outDefectsPresent bool& Flag indicating whether any defects were detected
outMissingEdges Region& Edges present on the golden image that are missing on the input image
outExcessiveEdges Region& Edges that are not present on the golden image
outImageEdges Optional<Region&> NIL Edges on the input image
outGoldenEdges Optional<Region&> NIL Edges on the golden image
outMatchingEdges Optional<Region&> NIL Golden edges present on the input image
outObjectPosition Optional<Rectangle2D&> NIL Position of the object being compared

Optional Outputs

The computation of following outputs can be switched off by passing value atl::NIL to these parameters: outImageEdges, outGoldenEdges, outMatchingEdges, outObjectPosition.

Read more about Optional Outputs.

Description

This filter compares edges given input image with an image stored in a golden template and then, as a result, creates a region containing only pixels where edges are different.

This method is especially useful for finding defects of the object shape. Due to invulnerability to color changes, it may be used in appliances with changing light conditions.

Parameter inMaxDistance defines the maximal distances of two edges that should be treated as the same edge.

To prepare image and area to be compared in it you can use CreateGoldenTemplate_Edges filter or property window.

Mostly the inEdgeThreshold and inEdgeHysteresis parameters should have the same value as in CreateGoldenTemplate_Edges filter. The values should be changed however if the brightness of the input image is significantly different from the brightness of the golden image used in CreateGoldenTemplate_Edges. The inEdgeThreshold can be also decreased slightly if one wants to concentrate on missing edges or increased to concentrate on excessive edges.

More information about this technique can be found in Machine Vision Guide: Golden Template.

Hints

  • A golden template comparison filter should be preceded with filters finding the object in certain location. Most typically we do this with LocateSingleObject_Edges filter.
  • Connect the inImage input with the image containing the object.
  • Select an image with a perfect object and use it to create golden template using the CreateGoldenTemplate_Edges filter.
  • Set inEdgeThreshold, inEdgeHysteresis, inStdDevX and inStdDevY as in DetectEdges_AsRegion filter. These will control detection of the edges used for object comparison.
  • Set inMaxDistance to specify the maximum spatial deviation between the edges on the input image and the edges on the template.

Remarks

Due to performance, it is recommended to create a template using the CreateGoldenTemplate_Edges filter outside a main loop of a program. It will create a model only once, instead of each iteration.

Errors

List of possible exceptions:

Error type Description
DomainError No valid golden template on input in CompareGoldenTemplate_Edges.

See Also