You are here: Start » Program Examples » Rubber Ring (Simple)

Rubber Ring (Simple)

Aim:

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

Input:

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

Output:

Proper and improper segments of the rubber band.

Hints:

It is possible to achieve this goal in many ways. In this solution, we will use Blob Analysis as it is one of the easiest approaches.

Labeling connections is explained in this article.

Solution (AVS):

  1. In Workspace Explorer, open the workspace Examples, and in the Filmstrip window, select the RubberRing dataset. Drag the Image channel to the ACQUIRE section.
  2. Add the ThresholdToRegion_HSx and connect the ReadFilmstrip output with the inRgbImage.
  3. Click on the ThresholdToRegion_HSx filter and make these changes in the Properties window (in the left bottom corner):

The values above were chosen based on information from the diagHSxImage diagnostic output, which displays HSV values. Using the color-picker tool, you should easily get these values as well. Please note that they are prompted as RGB values, but they are HSV values, in fact.

HSV values obtained with a color-picker tool.

  1. Add the CloseRegion filter to close the region corresponding to the rubber ring. Connect the outRegion from a previous filter with the inRegion of the current one.
  2. Click on the CloseRegion filter. In the Properties window:
  3. Add the FillRegionHoles filter to fill the holes in the region. Connect the outRegion to the inRegion.
  4. Click on the FillRegionHoles filter and in Properties window set the inMaxHoleArea to 10000 to avoid filling the area inside the rubber ring.
  5. Add the OpenRegion filter to find the bolder area of the rubber ring. Connect the outRegion to the inRegion.
  6. Click on the OpenRegion filter. In the Properties window:
  7. Now add a new Step macrofilter, name it DrawDefects and add the following inputs to it:
  8. Enter the newly-created macrofilter and add the RegionContours filter.
  9. Connect the inRingRegion with the inRegion. Click on the RegionContours filter and set the inContourMode to PixelEdges.
  10. Add another RegionContours filter to get an array of closed paths corresponding to the contours of the input region and connect inErrors to its inRegion input. Set the inContourMode to PixelEdges.
  11. Add the AverageChannels filter to get a grayscale image and connect macrofilter's inImage to the inImage.
  12. Add the DrawPaths_SingleColor filter.
  13. Click on the DrawPaths_SingleColor and, in Properties window, make these changes:
  14. Add another DrawPaths_SingleColor filter.
  15. Click on the DrawPaths_SingleColor filter and, in Properties window, make these changes:
  16. Connect the outImage to macrofilter outputs and name it outImage.

Macrofilter Main

Macrofilter DrawDefects

Used Filters

Icon Name Description
AverageChannels Creates a monochromatic image by averaging the input image channels.
CloseRegion Filling-in small gaps in a region without making it thicker.
DrawPaths_SingleColor Draws paths on an image with a single color.
FillRegionHoles Adds pixels to the input region so that it contains no holes.
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.
ThresholdToRegion_HSx Extraction of a region characterized with a specific color.

Further Readings

  • Blob Analysis - Article presents detailed information about the Blob Analysis technique.