Back to Adaptive Vision Library website

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

CompareGoldenTemplate_Intensity


Compares an image with a template image considered to have no defects.

Header:AVL.h

Syntax

C++
C#
 
void avl::CompareGoldenTemplate_Intensity
(
	const avl::Image& inImage,
	const avl::GrayGoldenTemplate& inGoldenTemplate,
	atl::Optional<const avl::CoordinateSystem2D&> inGoldenTemplateAlignment,
	float inMaxDifference,
	int inMinDefectRadius,
	avl::Region& outDefects,
	avl::Region& outDifferenceRegion,
	bool& outDefectsPresent,
	avl::Region& outEdgeRegion,
	atl::Optional<avl::Rectangle2D&> outObjectPosition = atl::NIL
)

Parameters

Name Type Range Default Description
inImage const Image& Input image
inGoldenTemplate const GrayGoldenTemplate& Golden gray template containing image of an object with no defects
inGoldenTemplateAlignment Optional<const CoordinateSystem2D&> NIL Adjusts the golden template to the position of the inspected object
inMaxDifference float 0.0 - 20.0f Maximal allowed difference between corresponding pixels of the input and golden images
inMinDefectRadius int 0 - 1 Minimal radius of a defect
outDefects Region& Region of detected defects
outDifferenceRegion Region& Region of pixels differing too much between the golden image and the input image
outDefectsPresent bool& Flag indicating whether any defects were detected
outEdgeRegion Region& Region of pixels that will not be compared
outObjectPosition Optional<Rectangle2D&> NIL Position of the object being compared

Description

This filter compares pixels of the input images against a template image stored in passed inGoldenTemplate input. Then creates a region containing only pixels in which intensity difference is higher than inMaxDifference value as a result. This method is especially useful for finding defects like: smudges, noises and dust particles. It can be used for finding missing holes or changes in complex shapes.

When the defected pixels are found only consistent regions are selected. Minimal radius of accepted region is set in inMinDefectRadius.

You can define a part of an image when defining inGoldenTemplate.

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_Intensity filter.
  • Set inMaxDifference to a value that assures detection of all true defects and no false ones. Verify this with the outDefects output.
  • Dismiss very small defects by setting inMinDefectRadius.

Examples

CompareGoldenTemplate_Intensity performed on sample image. A part of the object is missing – it is marked in blue on the right.

Remarks

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

Errors

Error type Description
DomainError No valid golden template on input in CompareGoldenTemplate_Intensity.
DomainError Input image format is incompatible with golden template image format in CompareGoldenTemplate_Intensity.

See Also

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