You are here: Start » Program Examples » Washers
Washers
Aim
This example shows how to find washers with defects or not properly centered.
Input
Set of images with multiple washers.
Output
Image with marked broken and not properly centered washers.
Histogram of distances between inner and outer contour of a washer.
Hints
Washers can be located by thresholding image and splitting resulting region into blobs.
Filter FitCircleToStripe can be used to find inner and outer circle of a washer.
Solution (FIS)
-
Use EnumerateImages filter to load input images.
-
Add ThresholdToRegion filter. Set inMinValue to Auto and inMaxValue to 200.0 to extract washers.
-
Add SplitRegionIntoBlobs filter to obtain separate washers.
-
Use RegionMassCenter filter to calculate washer centers.
-
Create a step macrofilter and name it MeasureWasher.
-
Connect outImage to MeasureWasher to create a new macrofilter input.
-
Connect outMassCenter to MeasureWasher to create a new macrofilter input.
-
Double-click on MeasureWasher to edit the macrofilter.
-
Add CreateCoordinateSystemFromPoint filter and connect inMassCenter to inPoint.
-
Add FitCircleToStripe filter. Connect inImage to inImage. Connect outCoordinateSystem to inFittingFieldAlignment, that way you will only need to specify fitting field for one washer.
-
Run program to refresh the image and coordinate system, they will be later used to specify fitting field.
-
Specify inFittingField. In fitting field editor select washer with coordinate system inside:
-
Set inScanCount to 20 and inMaxIncompleteness to 0. This will make the filter detect only complete washers and skip broken ones.
-
Using Show/Hide Ports show outInnerCircle.Center and outOuterCircle.Center.
-
Add PointToPointDistance to measure distance between two circle centers.
-
Connect outDistance to Macrofilter Outputs to create a new output.
-
Navigate to parent macrofilter (Main).
-
-
To create histogram of distances:
-
Add RemoveNils filter for type Real to process only non-broken washers.
-
Connect outDistance to inArray.
-
Add CreateHistogram filter and set inBinSize to 0.100.
-
-
Create a step macrofilter and name it DrawResults.
-
Connect outImage to DrawResults to create a new macrofilter input. Check Array checkbox.
-
Connect outMassCenter and outDistance to DrawResults in order to create new inputs. Check Array checkbox.
-
Double-click on DrawResults to edit the macrofilter.
-
Add a new formula to generate labels for washers. Create Real? input inDistance.
-
Create formula outputs:
This will mark washer as valid when distance between centers is less than 0.5 and the washer is not broken.
- Add DrawStrings_TwoColors filter to draw labels on the image. Use inMassCenter as location.
-
Macrofilter Main
Macrofilter MeasureWasher measures distance between centers of inner and outer contours of a washer
Macrofilter DrawResults draws inspection results on input image
Used Filters
Icon | Name | Description |
---|---|---|
![]() |
EnumerateImages | Emulates image acquisition with images stored on disk. |
![]() |
DrawStrings_TwoColors | Draws strings (text) on an image with two colors, depending on the status of each string (usually: green or red for pass/fail status). |
![]() |
ThresholdToRegion | Extraction of a region of objects that can be defined by a salient brightness. |
![]() |
PointToPointDistance | Measures the distance between two points. |
![]() |
CreateCoordinateSystemFromPoint | Most often used to define an object alignment from results of 1D Edge Detection or Blob Analysis. |
![]() |
CreateHistogram | Creates the histogram of the array of real numbers. |
![]() |
RegionMassCenter | Computes a point with coordinates equal to the average coordinates of the region's pixels. |
![]() |
FitCircleToStripe | Precise detection of ring-shaped objects, whose rough location is known beforehand. |
![]() |
SplitRegionIntoBlobs | Segmentation of a region into individual objects when the objects do not touch each other. |
![]() |
RemoveNils | This filter is useful e.g. when inspecting multiple objects while some of the inspections may fail (Nil result). RemoveNils is used to ignore the failed cases in the final result. |
Further Readings
- Formulas - Detailed information about using formulas.
- Local Coordinate Systems - This article describes basic concept of using the coordinate systems.
- Shape Fitting - This article presents usage of the Shape Fitting technique.
- Shape Fitting Filter Group - List of all filters used to perform Shape Fitting.