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.
- 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.
- Add FillRegionHoles filter.
- 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:
- 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.
- Add AverageChannels filter. Connect macrofilter's inImage with inImage.
- Add RegionContours filter.
- Add DrawPaths_SingleColor filter.
- Add another DrawPaths_SingleColor filter.
- Connect outImage to macrofilter outputs and name it outImage.
|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.|