You are here:
Start »
Program Examples »
Radiator Holes
Radiator Holes
Aim:
The task is to detect holes on the radiator and measure the distance between their centers.
Input:
An image of the radiator. The position is stable, but may slightly vary.

Output
Detected circles and segments between them.

Hints:
Shape Fitting allows for precise detection of line segments, circles, arcs, and paths with sub-pixel precision. Therefore, this technique is the best choice in cases that require high
precision of the measurements, like this one. Use the FitCircle filter and remember that right-clicking on the input or the output of a filter will show advanced properties.
Solution (FIS):
►Click here to show the solution.
▼Click here to hide the solution.
-
In Workspace Explorer, open the workspace Examples, and in the Filmstrip window, select the Radiator dataset. Drag the Image channel to the ACQUIRE section.
-
Add the first FitCircleToEdges filter and create an appropriate fitting field for the biggest hole. After that, generate a
Global Parameter by right-clicking on the
FittingField and selecting Extract Global Parameter option.
-
Set the inScanCount to 100 to increase the number of points that will be searched.
-
Set the inScanWidth to 13 to make a scanning field wider, so that the scanning results will be more resistant to noise.
-
To detect the four similar holes at the same time, add the second FitCircleToEdges filter. It will be executed in an array mode. To do so, create a
Global Parameter. Its type should be CircleFittingFieldArray. Then set
the appropriate Fitting Fields as shown:

-
The inFittingField is hidden by default, use the Show/HidePorts and select the inFittingField to make it visible, then connect the
Global Parameter there:

-
Set the inScanCount to 25 to increase the number of points that will be searched to estimate the position of the circle.
-
Set the EdgeTransition to DarkToBright as the background in the smaller holes is darker than the surface of the radiator.
-
To create segments connecting the centers of detected circles, use the MakeSegment filter. Connect the outCircle.Center from both FitCircleToEdges filters to the individual inPoint inputs.
Drop the outSegment on the preview window. To extract information about the length, use the Show/HidePorts and choose the
outSegment.Length.
-
To prevent the algorithm from calculating the distance between centers, when the lack of detection occurs, use the SkipArrayWithNils to omit any array containing the Nil value. Connect the outCircle.Center output to the inArray input to apply it.
-
Add the PointSequenceDistances filter that measures the distances between consecutive points in the input array. The question mark in the name of the filter indicates that it will be executed conditionally. It means that the distance will not be measured
if at least one circle is not detected.
Macrofilter Main

Used Filters
►Click here to show the filters list.
▼Click here to hide the filters list.
Icon |
Name |
Description |
 |
FitCircleToEdges |
Precise detection of a circular object or hole, whose rough location is known beforehand. |
 |
MakeSegment |
Creates a segment structure from individual fields. |
 |
PointSequenceDistances |
Measures the distances between consecutive points of a point sequence. |
 |
SkipArrayWithNils |
Changes an array with conditional elements into a conditional array. Can be useful if some processing should be performed only when all expected objects are correctly detected. |
Further Readings
- Shape Fitting - This article presents usage of the Shape Fitting technique.