You are here: Start » Tutorial Exercises » Shape Fitting: Measuring holes

Shape Fitting: Measuring holes

Aim:

Devise an algorithm to the radius of an inspected part.

Input:

A set of images depicting a single element. The radius and the number of holes are variable.

Images are stored in the shape_fitting directory.

Output:

The calculated radius length.

Hints:

The object under inspection is always located in a fixed position.

Use the FitCircleToEdges filter to find the inner and outer borders of the inspected object. The sizes of circles in the image are variable. Consider a margin for detection of the circle radius into account.

Calculate the radius of an element using the CircleToCircleDistance filter.

Labeling connections is explained in this article.

Solution (FIS):

  1. Add the EnumerateImages filter to retrieve images from the input directory.

  2. Add the FitCircleToEdges filter and select a scanning circle using the first loaded image as a background. The image below shows the circle editor with the background set and the circle created. The circle is selected with a small margin.

  3. Set inScanCount to 20 in FitCircleToEdges. Select the inFittingField.Width size to cover the image edge. In the image below this value is set to 45.

  4. To detect the outer border of the part, add another FitCircleToEdges filter. Set inScanCount and the inFittingField.Width size the same as in the previous filter. Create a circle that is a bit smaller than the perimeter of the object in the image. Change inEdgeScanParams.EdgeTransition to DarkToBright and inFittingMethod to GeometricLandau.

  5. To calculate the part's radius, add the CircleToCircleDistance filter and use the previously found circles.

Macrofilter Main performs measurements using Shape Fitting technique.

Additional Tasks:

  • Calculate the holes count using Blob analysis technique,
  • Calculate the holes number using 1D Edge Detection technique.

Further Readings

  • 1D Edge Detection - The article explaining how edge detection filters work.
  • Blob Analysis - Article presents detailed information about the Blob Analysis technique.
  • Shape Fitting - This article presents usage of the Shape Fitting technique.