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 CompareGoldenTemplate_Edges filter.
Labeling connections is explained in this article.
Solution (Studio)
-
Add the EnumerateImages filter to load images from the images directory.
-
Find the position of an object add filter LocateSingleObject_Edges and prepare a template model like on the image below:
Thanks to using two separated areas in Template Matching location is more precise, while model is still tiny.
-
Add filter CompareGoldenTemplate_Edges and connect to inImage output of EnumerateImages.
-
Using the Golden Template Editor select a template on the first image. Set EdgeThreshold to 30 and EdgeHysteresis to 20.
-
Configure the CompareGoldenTemplate_Edges filter with the same values as in Golden Template Editor. Set inEdgeThreshold to 30.0 and inEdgeHysteresis to 20.
-
Add DilateRegion filter and connect to it data from outDefects to expand defects region and make it more visible.
- Connect dilated region with inRegions of filter DrawRegions_SingleColor to draw defect regions on output image.
Macrofilter Main uses the Template Matching and Golden Template techniques to find defects on a bottle head.
Used Filters
Icon | Name | Description |
---|---|---|
![]() |
CompareGoldenTemplate_Edges | Finding general object defects by analyzing missing or excessive edges. |
![]() |
LocateSingleObject_Edges | Detection of an object whose outlines are sharp and rigid. Often one of the first filters in a program. |
![]() |
EnumerateImages | Emulates image acquisition with images stored on disk. |
![]() |
DilateRegion | Making the region thicker or filling-in small holes within it. |
![]() |
DrawRegions_SingleColor | Draws regions on an image with a single color. |
Further Readings
- Golden Template - Article explaining how Golden Template technique works.
- Template Matching - Most detailed description of the Template Matching technique.