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

Shape Fitting: Measuring holes (shape_fitting)

Aim

Devise an algorithm that finds the radius of an inspected part.

Input

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

Images are stored in 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 inner and outer borders of the inspected object. The sizes of circles in the image are variable. Take some 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 (AVS)

  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 the other 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 holes count using Blob analysis technique,
  • Calculate 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.