You are here: Start » Program Examples » Rubber Ring
Rubber Ring
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
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.
Labeling connections is explained in this article.
Solution (FIS)
- Add EnumerateImages filter.
- Add new step macrofilter, name it DetectRing, connect outImage to it and get inside.
- Add ThresholdToRegion_Color filter and connect macrofilter's inImage with inImage.
- Click on ThresholdToRegion_Color filter and set inMaxDifference to 20 to increase the maximum difference between the image pixel and reference color.
- Add CloseRegion filter.
- Connect outRegion with inRegion.
- Click on CloseRegion filter set inRadiusX to 10.
- Add FillRegionHoles filter.
- Connect outRegion with inRegion.
- Click on FillRegionHoles filter and set inMaxHoleArea to 10000 to avoid filling the area inside the rubber ring.
- Add OpenRegion filter. Connect outRegion with inRegion.
- Connect outRegion to macrofilters outputs and name it outRingRegion.
- Go back to Main and add new step macrofilter, name it GetOuterAndInnerContour. Connect outRingRegion from a previous macrofilter to it and name it inRingRegion.
- Get inside the macrofilter and add RegionContours filter.
- Connect inRingRegion with inRegion.
- Add ConvertToEquidistantPath filter. Connect outContours with inPath.
- Add GetArrayElements filter of Path type. Connect outPath with inArray.
- Connect outValue1 and outValue2 to macrofilter outputs and name them outOuter and outInner respectively.
- Go back to Main and add PathToPathDistanceProfile filter. Connect outOuter with inPath1 and outInner with inPath2.
- Add ClassifyByRange filter of Segment2D type. Make these changes:
- Connect outConnectingSegments with inArray.
- Connect outDistances with inValues.
- Click on ClassifyByRange filter and in Properties window:
- Add new step macrofilter, name it DrawDefects and:
- Get inside the macrofilter and add ReverseArray filter.
- Right-click on inErrors, find Property outputs and select Point1 and Point2.
- Connect inErrors.Point1 with inArray.
- Add JoinArrays filter and connect inErrors.Point2 with inArray1. Connect outArray with inArray2.
- Add MakePath filter.
- Connect outJoinedArray with inPoints.
- Click on MakePath filter and set inClosed to True.
- Add AverageChannels filter. Connect macrofilter's inImage with inImage.
- Add RegionContours filter.
- Connect macrofilter's inRingRegion with inRegion.
- Click on RegionContours filter and set inContourMode to PixelEdges.
- Add DrawPaths_SingleColor filter.
- Connect outImage with inImage.
- Connect outContours from RegionContours filter and connect with inPaths.
- Set inColor to green.
- Add another DrawPaths_SingleColor filter.
- Connect outImage from a previous filter with inImage of the current one.
- Connect outPath with inPaths.
- Set inDrawingStyle.Thickness to 5.
- Set inDrawingStyle.PointSize to 2.
- Connect outImage to macrofilter outputs and name it outImage.
Macrofilter Main
Macrofilter DetectRing
Macrofilter GetOuterAndInnerContour
Macrofilter DrawDefects
Used Filters
Icon | Name | Description |
---|---|---|
![]() |
EnumerateImages | Emulates image acquisition with images stored on disk. |
![]() |
ThresholdToRegion_Color | Color analysis with a given reference color. |
![]() |
ConvertToEquidistantPath | Creates a new path whose characteristic points lie on the input path, but are equally spaced. |
![]() |
ReverseArray | Creates an array of the input array elements in reversed order. |
![]() |
JoinArrays | Concatenates the input arrays one after another. |
![]() |
GetArrayElements | Extracts up to 8 individual elements from an array. |
![]() |
DrawPaths_SingleColor | Draws paths on an image with a single color. |
![]() |
MakePath | Creates a path structure. |
![]() |
PathToPathDistanceProfile | Computes the profile of distances between two paths. |
![]() |
FillRegionHoles | Adds pixels to the input region so that it contains no holes. |
![]() |
RegionContours | Computes an array of closed paths corresponding to the contours of the input region. |
![]() |
ClassifyByRange | E.g. selection of the objects (e.g. blobs) whose associated values (e.g. area) meet the specified minimum and maximum requirements. |
![]() |
OpenRegion | Removing small parts from a region without making it thinner. |
![]() |
AverageChannels | Creates a monochromatic image by averaging the input image channels. |
![]() |
CloseRegion | Filling-in small gaps in a region without making it thicker. |
Further Readings
- Array - Link to all operations based on arrays in FabImage Studio.
- Blob Analysis - Article presents detailed information about the Blob Analysis technique.