You are here: Start » Program Examples » Washers
Washers
Aim:
This example shows how to find washers with defects or that are not properly centered.
Input:
A set of images with multiple washers.
Output:
An image with marked broken and not properly centered washers.
Histogram of distances between the inner and outer contour of a washer.
Hints:
Washers can be located by thresholding the image and splitting the resulting region into blobs.
The FitCircleToStripe filter can be used to find the inner and outer circle of a washer.
Labeling connections is explained in this article.
Solution (AVS):
-
In Workspace Explorer, open the workspace Examples, and in the Filmstrip window, select the Washers dataset. Drag the Image channel to the ACQUIRE section.
-
Add the ThresholdToRegion filter. Set the inMinValue to Auto and the inMaxValue to 200.0 to extract washers.
-
Add the SplitRegionIntoBlobs filter to obtain separate washers.
-
Use the RegionMassCenter filter to calculate washer centers. Click on the outMassCenter twice and change its name to MassCenters
-
Add the CreateCoordinateSystemFromPoint filter and connect MassCenter to the inPoint.
-
Add the FitCircleToStripe filter. Connect Image to the inImage. Connect the outCoordinateSystem to the inFittingFieldAlignment, so you will only need to specify the fitting field for one washer.
-
Run the program to refresh the image and coordinate system, as they will be later used to specify the fitting field.
-
Specify the inFittingField. In the fitting field editor, select the washer with the coordinate system inside:
-
Set the inScanCount to 20 and the inMaxIncompleteness to 0. This will make the filter detect only complete washers and skip broken ones.
-
Using Show/Hide Ports show the outInnerCircle.Center and the outOuterCircle.Center. Change their names to InnerCircleCenter and OuterCircleCenter
-
-
Add the PointToPointDistance filter to measure the distance between the centers of the inner and outer circle. Change the name of the output to the WasherErrorOrNil
-
To create a histogram of distances:
-
Add the RemoveNils filter of type Real to process only non-broken washers.
-
Connect outDistance to the inArray.
-
Add the CreateHistogram filter and set the inBinSize to 0.100.
-
-
Create a step macrofilter and name it DrawResults.
-
Connect the ReadFilmstrip output to the DrawResults to create a new macrofilter input. Check Array checkbox.
-
Connect the MassCenters and the WasherErrorOrNil to the DrawResults in order to create new inputs. Check Array checkbox.
-
Double-click on the DrawResults to edit the macrofilter.
-
Add a new formula to generate labels for washers. Create the Real? input inDistance.
-
Create formula outputs:
This will mark a washer as valid when the distance between centers is less than 0.5 and the washer is not broken.
- Add the DrawStrings_MultiColor filter to draw labels on the image. Use the inMassCenter as the location.
-
Macrofilter Main
Macrofilter DrawResults draws inspection results on the input image
Used Filters
Icon | Name | Description |
---|---|---|
![]() |
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. |
![]() |
DrawStrings_MultiColor | Draws strings (text) on an image with multiple colors. |
![]() |
FitCircleToStripe | Precise detection of ring-shaped objects, whose rough location is known beforehand. |
![]() |
PointToPointDistance | Measures the distance between two points. |
![]() |
RegionMassCenter | Computes a point with coordinates equal to the average coordinates of the region's pixels. |
![]() |
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. |
![]() |
SplitRegionIntoBlobs | Segmentation of a region into individual objects when the objects do not touch each other. |
![]() |
ThresholdToRegion | Extraction of a region of objects that can be defined by a salient brightness. |
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.