You are here: Start » Program Examples » Inset Distances
Inset Distances
Aim
The task is to devise an algorithm which would compute the distance between ridges.
Input
The set of images with variable positions of the object as in the picture below:
Output
Detected ridges in the image with computed distance between them (the width of a gap):
Hints
As the position of ridges slightly changes, think of a way to locate the ridges without using the Template Matching technique. You could use some other part of the image to find its alignment. Using the Region Analysis it is possible to determine the location of holes and based on this information to create a local coordinate system.
Labeling connections is explained in this article.
Solution (FIS)
-
Load images into your program using EnumerateImages.
-
Add the ThresholdToRegion filter. Connect outImage from the previous filter to inImage of the current one. Set the inRoi input as follows:
-
Add SplitRegionIntoBlobs. Connect outRegion from the previous filter to the inRegion of the current one. Set inMaxBlobArea to 1000 so that only smallest blobs are left.
-
Add the RegionMassCenter filter. Connect outBlobs to inRegion. Right-click on the outMassCenter output, find Property Outputs and choose X. It should appear as a new output of the filter.
-
Add the GetSortedElements filter of Point2D type. Connect outMassCenter to inArray and outMassCenter.X to inValues. It will sort the blobs according to their X coordinate.
-
Add CreateCoordinateSystemFromSegment. Right-click on its inSegment input and connect outElement0 and outElement1 to inSegment.Point1 and inSegment.Point2 respectively.
-
Add the ScanExactlyNRidges filter and:
- Connect the outImage output from EnumerateImages to inImage,
- Connect outCoordinateSystem to inScanPathAlignment,
- Set a following scanning path:
- Set inRidgeCount to 2,
- Choose outGaps.Width from the list of available outputs and drag it on a preview window.
Macrofilter Main
Used Filters
Icon | Name | Description |
---|---|---|
![]() |
EnumerateImages | Emulates image acquisition with images stored on disk. |
![]() |
GetSortedElements | Returns elements corresponding to 8 smallest/biggest values from the array of values. |
![]() |
ThresholdToRegion | Extraction of a region of objects that can be defined by a salient brightness. |
![]() |
CreateCoordinateSystemFromSegment | Creates a coordinate system with the origin on a given segment. |
![]() |
ScanExactlyNRidges | Very fast detection (or presence verification) of thin structures like wires or scale marks. |
![]() |
RegionMassCenter | Computes a point with coordinates equal to the average coordinates of the region's pixels. |
![]() |
SplitRegionIntoBlobs | Segmentation of a region into individual objects when the objects do not touch each other. |
Further Readings
- 1D Edge Detection - The article explaining how edge detection filters work.
- Array - Link to all operations based on arrays in FabImage Studio.
- Blob Analysis - Article presents detailed information about the Blob Analysis technique.
- Local Coordinate Systems - This article describes basic concept of using the coordinate systems.