You are here: Start » Program Examples » Rubber Ring

Rubber Ring


The aim of the program is to detect improperly assembled segments of a rubber band.


An image of a chip with an assembled rubber band around it.


Proper and improper segments of the rubber band.


This is another variant of the same example but using more advanced techniques. If you do not feel secure enough, please see the simpler variant here Rubber Ring (Simple). The effect is just the same and the solution is more user-friendly though.

In this example we use similar techniques as in the simpler variant but enriched by additional filters.

Solution (AVS)

  1. Add EnumerateImages filter.
  2. Add new step macrofilter, name it DetectRing, connect outImage to it and get inside.
  3. Add ThresholdToRegion_Color filter and connect macrofilter's inImage with inImage.
  4. Click on ThresholdToRegion_Color filter and set inMaxDifference to 20 to increase the maximum difference between the image pixel and reference color.
  5. Add CloseRegion filter.
  6. Add FillRegionHoles filter.
  7. Add OpenRegion filter. Connect outRegion with inRegion.
  8. Connect outRegion to macrofilters outputs and name it outRingRegion.
  9. Go back to Main and add new step macrofilter, name it GetOuterAndInnerContour. Connect outRingRegion from a previous macrofilter to it and name it inRingRegion.
  10. Get inside the macrofilter and add RegionContours filter.
  11. Connect inRingRegion with inRegion.
  12. Add ConvertToEquidistantPath filter. Connect outContours with inPath.
  13. Add GetArrayElements filter of Path type. Connect outPath with inArray.
  14. Connect outValue1 and outValue2 to macrofilter outputs and name them outOuter and outInner respectively.
  15. Go back to Main and add PathToPathDistanceProfile filter. Connect outOuter with inPath1 and outInner with inPath2.
  16. Add ClassifyByRange filter of Segment2D type. Make these changes:
  17. Click on ClassifyByRange filter and in Properties window:
    • Set inMinimum to 0 to define a minimal distance.
    • Set inMaximum to 30 to define a maximal distance.
  18. Add new step macrofilter, name it DrawDefects and:
    • Connect outImage to it and name it inImage.
    • Connect outRingRegion from DetectRegion macrofilter to it and name it inRingRegion.
    • Connect outHigher to it and name it inErrors.
  19. Get inside the macrofilter and add ReverseArray filter.
  20. Right-click on inErrors, find Property outputs and select Point1 and Point2.
  21. Connect inErrors.Point1 with inArray.
  22. Add JoinArrays filter and connect inErrors.Point2 with inArray1. Connect outArray with inArray2.
  23. Add MakePath filter.
  24. Add AverageChannels filter. Connect macrofilter's inImage with inImage.
  25. Add RegionContours filter.
  26. Add DrawPaths_SingleColor filter.
  27. Add another DrawPaths_SingleColor filter.
  28. Connect outImage to macrofilter outputs and name it outImage.

Macrofilter Main

Macrofilter DetectRing

Macrofilter GetOuterAndInnerContour

Macrofilter DrawDefects

Used Filters

Icon Name Description
GetArrayElements Extracts up to 8 individual elements from an array.
CloseRegion Filling-in small gaps in a region without making it thicker.
ConvertToEquidistantPath Creates a new path whose characteristic points lie on the input path, but are equally spaced.
ThresholdToRegion_Color Color analysis with a given reference color.
PathToPathDistanceProfile Computes the profile of distances between two paths.
ReverseArray Creates an array of the input array elements in reversed order.
FillRegionHoles Extends the input region so that it contains also all the pixels previously lying in its holes.
ClassifyByRange E.g. selection of the objects (e.g. blobs) whose associated values (e.g. area) meet the specified minimum and maximum requirements.
DrawPaths_SingleColor Draws paths on an image with a single color.
JoinArrays Concatenates the input arrays one after another.
AverageChannels Creates a monochromatic image by averaging the input image channels.
EnumerateImages Emulates image acquisition with images stored on disk.
MakePath Creates a path structure.
OpenRegion Removing small parts from a region without making it thinner.
RegionContours Computes an array of closed paths corresponding to the contours of the input region.

Further Readings

  • Array - Link to all operations based on arrays in Adaptive Vision Studio.
  • Blob Analysis - Article presents detailed information about the Blob Analysis technique.