Back to Adaptive Vision Library website

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

AvsFilter_CompareGoldenTemplate_Intensity


This is Filter Equivalent. This function may be present in generated code, but should not be used in hand-written code.

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

Syntax

void avl::AvsFilter_CompareGoldenTemplate_Intensity
(
	CompareGoldenTemplate_IntensityState& ioState,
	const avl::Image& inImage,
	const avl::Image& inGoldenImage,
	atl::Optional<const avl::Region&> inRoi,
	atl::real inEdgeThreshold,
	int inEdgeDilation,
	bool inStaticModel,
	atl::real inMaxDifference,
	int inMinDefectRadius,
	avl::Region& outDefects,
	avl::Region& outDifferenceRegion,
	bool& outDefectsPresent,
	avl::Region& outRoi
)

Parameters

Name Type Range Default Description
ioState CompareGoldenTemplate_IntensityState& Object used to maintain state of the function.
inImage const Image& Input image
inGoldenImage const Image& Reference image containing no defects
inRoi Optional<const Region&> NIL Range of pixels to be processed
inEdgeThreshold real 0.0 - 10.0f Minimum strength of edges on the golden image near which comparison is NOT performed
inEdgeDilation int 0 - 1 Defines for how far from the detected edges comparison is NOT performed
inStaticModel bool True Flag indicating whether model should be created only in the first iteration
inMaxDifference real 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
outRoi Region& Region of pixels that were compared

Description

This filter compares pixels of two input images and as a result creates a region containing only pixels in which intensity difference is higher than inMaxDifference value. 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.

Filter finds edges on an image and removes nearby pixels to avoid comparing pixels near edges which may contains some distortions due to shadows or changes in lightning. Input inEdgeDilation defines the width of the quiet zone around the edges and the parameter inEdgeThreshold define how strong must be change of the color between pixels to treat them as an edge.

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

To compare only part of an image use the CropImageToRectangle filter. Golden Template image can be stored in Global Parameter.

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 and cropping it to an image where the location and the size of the object are fixed. Most typically we do this with LocateSingleObject_Edges and CropImageToRectangle filters.
  • Connect the inImage input with the image containing the object at fixed location and size. Make sure that this image is available (the program was previously run).
  • Select an image with a perfect object and copy it to the inGoldenImage input (usually we copy it from the output of the CropImageToRectangle filter). It is recommended to use a global parameter here.
  • Set inEdgeThreshold to a value that assures detection of all object edges, so that defects appearing near the edges can be ignored. Also set inEdgeDilation to specify the margin around the edges. Verify these two settings with the outRoi output – it should be empty near the edges.
  • 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.
  • Set inStaticModel to False only if the value on the inGoldenImage input changes over time.

Examples

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

Remarks

Input inStaticModel allows to compute comparison model in the first iteration of the filter execution. This option may speedup computation in time-critical appliances.

See Also