You are here: Start » Program Examples » Comparing Golden Template

Comparing Golden Template

Aim

This example shows how to find defects on the bottle head. Golden Template technique can be used to find even the smallest defect.

Input

Set of images with a single bottle head.

Output

Image with marked defects on it.

Hints

Best way to find defects is to locate bottle head using Template Matching and compare the matches using Golden Template technique.

In this case one should use the CompareGoldenTemplate_Edges filter.

Labeling connections is explained in this article.

Solution (Studio)

  1. In Workspace Explorer open workspace Examples and in Film strip window select CompareTemplate dataset. Drag the Image channel to the ACQUIRE section.

  2. Find the position of an object - add the LocateSingleObject_Edges1 and prepare a template model like on the image below:

    Thanks to using two separated areas in Template Matching, the location is more precise, while model is still tiny.

  3. Add the CompareGoldenTemplate_Edges and connect the inImage to the output of the ReadFilmstrip.

  4. Using the Golden Template Editor, select a template on the first image. Set the EdgeThreshold to 30 and the EdgeHysteresis to 20.

  5. Configure the CompareGoldenTemplate_Edges filter with the same values as in the Golden Template Editor. Set the inEdgeThreshold to 30.0 and the inEdgeHysteresis to 20.

  6. Add the DilateRegion filter and connect it to data from the outDefects to expand defects region and make it more visible.

  7. Connect the dilated region with the inRegions of the DrawRegions_SingleColor to draw defect regions on an output image.

Macrofilter Main uses the Template Matching and Golden Template techniques to find defects on a bottle head.

Used Filters

Icon Name Description
DrawRegions_SingleColor Draws regions on an image with a single color.
CompareGoldenTemplate_Edges Finding general object defects by analyzing missing or excessive edges.
DilateRegion Making the region thicker or filling-in small holes within it.
LocateSingleObject_Edges1 Detection of an object whose outlines are sharp and rigid. Often one of the first filters in a program.

Further Readings