Aurora Visio Studio TOP » Program Examples » Pins
Pins
目的
The task is to measure distances between consecutive pins and how far away they are from the center.
Input
An image in which pins are present.
Output
A set of measured distances and an image where the measured distances are drawn.
ヒント
The pins are the brightest elements of the image as well as the smallest. Using the ImageLocalMaxima would allow to find their locations. To measure distances the PointSequenceDistances can be used.
Solution (AVS)
-
In Workspace Explorer open workspace Examples and in Film strip window select Pins dataset. Drag the Image channel to the ACQUIRE section.
-
While the pins are one of the brightest elements in the image, there are also other similarly bright elements. To filter those unwanted elements out add the DifferenceOfGaussians filter. This filter will calculate the difference between two smoothed images. Since pins are very small and surrounded by dim background they should disappear after strong smoothing.
- Set the inStdDev parameter to 2.
-
Run the program once and drag the output of the filter to the preview. As you can see only the pins are visible in the image and the rest of the image is very dark. Now use the color picker tool (from the panel shown in the image below) and check the pins' brightness. Each pin has brightness of at least 40 and no other element is so bright. The picture below shows where the picker tool can be found.
-
Now add the ImageLocalMaxima filter and set the inMinValue parameter to 40. In this step we want to measure only the upper row of pins, so click on the "..." icon next to the inRoi in the Properties window to open the editor. After that choose the image from the ReadFilmstrip as the reference image (in the top bar of the editor) and draw a rectangle around the upper row of pins (see picture below). Close the editor, drag the outLocalMaxima.Point output to the preview and run the program once again.
-
Now you can see the detected points in the preview. However, they are not sorted. To sort them from left to right add the SortArray filter of type Point2D. Connect the outLocalMaxima.Point to the inArray. To change the order of the points along a horizontal axis we need only their x coordinates. Right click the outLocalMaxima.Point and choose Property outputs and the X. Connect the newly created output to the inValues.
-
In the following steps we will need to know the segment which is formed by the top row pins. To fit a segment to points add the FitSegmentToPoints filter and connect the outSortedArray to its input.
-
Now we can measure the distance between the consecutive points. We can do it by using the PointSequenceDistances. Add it and connect the outSortedArray to its input.
-
Now we need to do the same for the bottom row. The easiest way to to do this is by making a custom macrofilter and copying it. Select all the blocks after the ReadFilmstrip, right click them and select Extract step....
- You can change the name of the filter. Here it is named "InspectRowOfPins".
- Enter the filter and drag the inRoi input to the top bar of the filter ("Macrofilter Inputs"). Now the ROI can be changed outside the filter.
- Now drag the outConnectingSegments, the outDistances and the outSortedArray to the "macrofilter Outputs" bar to make new outputs.
-
Go back up to the Main filter of the program. Now select the newly created macrofilter and copy it so that you have two instances of it.
-
Since you created the inRoi input, you have to once again select the region in which the pins are. For the first filter select the region corresponding to the upper row and for the second filter - the bottom row.
-
The program calculates distances between consecutive points of one row. Now we need to measure the distance to the center. To find the centerline add the LerpSegments filter. Set its inIgnoreOrientation to True. Connect the outConnectingSegments of both the InspectRowOfPins macrofilters to its inSegment0 and inSegment1 inputs.
-
Add the PointToLineDistance filter. Connect the outSortedArray output of one of the InspectRowOfPins macrofilter to the inPoint input. Then connect the outSegment to the inLine.
-
Now repeat the previous step but this time connect the outSortedArray from the second macrofilter.
-
The program now calculates the distances between points and the centerline.
-
Create another macrofilter from the last three blocks. Make sure it returns all the important data. Then drag the outputs to the preview.
- It is good practice to name the ports of macrofilters in a descriptive way. For example, notice how the ports are named in the example program.
マクロフィルタ メイン
Macrofilter InspectRowOfPins
Macrofilter CheckVerticalDistances
使用したフィルタ
アイコン | 名前 | 説明 |
---|---|---|
DifferenceOfGaussians | Emphasizes high-frequency image features such as lines or patches / dots. | |
PointSequenceDistances | Measures the distances between consecutive points of a point sequence. | |
PointToLineDistance | Measures the distance between a point and a line. | |
FitSegmentToPoints | Finding a locally optimal segment. Good enough when the number of outliers is small. | |
ImageLocalMaxima | Detection of characteristic points, usually after some image transformations. | |
SortArray | Changes the order of the input array elements according to an ascending/descending sequence of the value array. | |
LerpSegments | Linearly interpolates between two segments. |
その他の資料
- Shape Fitting - シェイプ フィッティング テクニックの使用法を紹介します。