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

Comparing Golden Template

Aim:

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

Input:

A set of images of a single bottle cap.

Output:

An image with marked defects on it.

Hints:

The best way to find defects is to locate the bottle cap using Template Matching and compare the matches using the Golden Template technique.

In this case, you should use the CompareGoldenTemplate_Edges filter.

Labeling connections is explained in this article.

Solution (Studio)

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

  2. Find the position of the object - add the LocateSingleObject_Edges1 and prepare a template model as shown in the image below:

    By using two separate areas in Template Matching, the location is more precise, while the model is still small.

  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 the defects region and make it more visible.

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

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

Used Filters

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

Further Readings