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 the part.

Input

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

Images are stored in shape_fitting directory.

Output

The calculated radius size and the count of smaller holes around the main mount.

Hints

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

Use the FitCircleToEdges filter to find inner and outer borders of the object under inspection. The sizes of circles in the image are variable. Prepare some margin for detection of the circle radius.

Calculate the radius of an element using CircleToCircleDistance filter.

Solution (AVS)

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

  2. Add 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 second FitCircleToEdges filter. Create a circle a bit smaller then the circle in the image.

  5. To calculate the part's radius add 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.