【机器视觉】 measure_pos算子
00. 目錄
文章目錄
- 00. 目錄
- 01. 概述
- 02. 簽名
- 03. 描述
- 04. 注意
- 05. 參數(shù)
- 06. 結(jié)果
- 07. 附錄
01. 概述
measure_pos - 提取垂直于矩形或環(huán)形弧的直線邊緣。
02. 簽名
measure_pos(Image : : MeasureHandle, Sigma, Threshold, Transition, Select : RowEdge, ColumnEdge, Amplitude, Distance)
03. 描述
measure_pos提取垂直于矩形或環(huán)形弧長軸的直邊。
該算法通過計(jì)算垂直于矩形或環(huán)形弧的長軸的“切片”中的灰度值的均值以獲得一維邊緣輪廓。采樣是在矩形中心的整數(shù)行和列位置(在矩形的坐標(biāo)系中)的圖像Image中的亞像素位置完成的。由于這含有可以在多次測量中重復(fù)使用的一些計(jì)算,所以使用算子gen_measure_rectangle2或gen_measure_arc來執(zhí)行一次這些計(jì)算,從而顯著提高了measure_pos的速度。由于在灰度值的亞像素計(jì)算中存在精度和速度之間的折衷,并且因此在所提取的邊緣位置的準(zhǔn)確度中,可以在gen_measure_rectangle2中選擇不同的插值方案。 (插值僅影響與圖像軸不對齊的矩形。)使用gen_measure_rectangle2生成的measure對象在MeasureHandle中傳遞。
在計(jì)算出一維邊緣輪廓之后,通過將輪廓與標(biāo)準(zhǔn)偏差Sigma的高斯平滑核的導(dǎo)數(shù)進(jìn)行卷積來計(jì)算亞像素邊緣位置。可以用構(gòu)成振幅閾值的參數(shù)Threshold(即邊緣的一階導(dǎo)數(shù)的絕對值)來選擇顯著邊緣。請注意,幅度值按Sigmasqrt(2pi)比例縮放。另外,可以僅選擇正邊緣,即在矩形或弧的長軸方向上構(gòu)成暗到亮的過渡的邊緣(Transition = ‘positive’),或者只有負(fù)邊緣,即,亮到暗過渡(Transition =‘negative’)或兩種類型的邊緣(Transition =‘a(chǎn)ll’)。最后,可以選擇返回哪個邊緣點(diǎn)。如果Select設(shè)置為’all’,則返回所有邊緣點(diǎn)。如果設(shè)置為’first’,則只返回第一個提取的邊緣點(diǎn),而設(shè)置為’last’,則只返回最后一個。
提取的邊緣將把位于矩形或圓弧長軸上的單個點(diǎn)(RowEdge,ColumnEdge)作為提取的邊緣返回。 Amplitude返回相應(yīng)的邊緣振幅。 另外,連續(xù)的邊緣點(diǎn)之間的距離以Distance返回。 這里, Distance[i]對應(yīng)于Edge[i]和Edge[i+1]之間的距離,即,元組Distance 含有比(RowEdge 和ColumnEdge)的長度-1個元素
原文描述:
measure_pos extracts straight edges which lie perpendicular to the major axis of a rectangle or annular arc.
For an explanation of the concept of 1D measuring see the introduction of chapter 1D Measuring.
The algorithm of measure_pos works by averaging the gray values in “slices” perpendicular to the major axis of the rectangle or annular arc in order to obtain a one-dimensional edge profile. The sampling is done at subpixel positions in the image Image at integer row and column distances (in the coordinate frame of the rectangle) from the center of the rectangle. Since this involves some calculations which can be used repeatedly in several measurements, the operator gen_measure_rectangle2 or gen_measure_arc is used to perform these calculations only once, thus increasing the speed of measure_pos significantly. Since there is a trade-off between accuracy and speed in the subpixel calculations of the gray values, and thus in the accuracy of the extracted edge positions, different interpolation schemes can be selected in gen_measure_rectangle2. (The interpolation only influences rectangles not aligned with the image axes.) The measure object generated with gen_measure_rectangle2 is passed in MeasureHandle.
After the one-dimensional edge profile has been calculated, subpixel edge locations are computed by convolving the profile with the derivatives of a Gaussian smoothing kernel of standard deviation Sigma. Salient edges can be selected with the parameter Threshold, which constitutes a threshold on the amplitude, i.e., the absolute value of the first derivative of the edge. Note that the amplitude values are scaled by the factor . Additionally, it is possible to select only positive edges, i.e., edges which constitute a dark-to-light transition in the direction of the major axis of the rectangle or the arc (Transition = ‘positive’), only negative edges, i.e., light-to-dark transitions (Transition = ‘negative’), or both types of edges (Transition = ‘a(chǎn)ll’). Finally, it is possible to select which edge points are returned. If Select is set to ‘a(chǎn)ll’, all edge points are returned. If it is set to ‘first’, only the first of the extracted edge points is returned, while it is set to ‘last’, only the last one is returned.
The extracted edges are returned as single points which lie on the major axis of the rectangle or arc in (RowEdge,ColumnEdge). The corresponding edge amplitudes are returned in Amplitude. In addition, the distance between consecutive edge points is returned in Distance. Here, Distance[i] corresponds to the distance between Edge[i] and Edge[i+1], i.e., the tuple Distance contains one element less than the tuples RowEdge and ColumnEdge.
執(zhí)行信息
● 多線程類型:可重入(與非獨(dú)占算子并行運(yùn)行)。
● 多線程范圍:全局(可以從任何線程調(diào)用)。
● 不并行處理。
04. 注意
只有邊緣是直的并垂直于矩形或弧的長軸,measure_pos返回的結(jié)果才有意義。 因此它不應(yīng)該用于從曲面對象中提取邊緣。 此外用戶應(yīng)確保矩形或弧線盡可能接近垂直于圖像中的邊緣。 此外,西格瑪不能大于約0.5 * Length1(對于Lenth1請參見gen_measure_rectangle2)。
應(yīng)該記住,為了效率的原因,measure_pos會忽略Image的ROI域。 如果圖像中的特定區(qū)域應(yīng)該從measurement中排除,則應(yīng)該生成具有適當(dāng)修改的參數(shù)的新measure對象。
05. 參數(shù)
Image (input_object) 單通道圖像→ object (byte / uint2 / real)
輸入圖像。
MeasureHandle (input_control) measure_id → (integer)
Measure對象句柄。
Sigma (input_control) number → (real)
高斯模糊的Sigma值
Default value: 1.0
Suggested values: 0.4, 0.6, 0.8, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 7.0, 10.0
Typical range of values: 0.4 ≤ Sigma ≤ 100 (lin)
Minimum increment: 0.01
Recommended increment: 0.1
Restriction: Sigma >= 0.4
Threshold (input_control) number → (real)
最小邊緣幅度。
Default value: 30.0
Suggested values: 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 90.0, 110.0
Typical range of values: 1 ≤ Threshold ≤ 255 (lin)
Minimum increment: 0.5
Recommended increment: 2
Transition (input_control) string → (string)
亮到暗或者暗到亮的邊緣。
Default value: ‘a(chǎn)ll’
List of values: ‘a(chǎn)ll’, ‘negative’, ‘positive’
Select (input_control) string → (string)
要選擇返回的點(diǎn)。
Default value: ‘a(chǎn)ll’
List of values: ‘a(chǎn)ll’, ‘first’, ‘last’
RowEdge (output_control) point.y-array → (real)
邊緣中心的Row坐標(biāo)。
ColumnEdge (output_control) point.x-array → (real)
邊緣中心的Column坐標(biāo)。
Amplitude (output_control) real-array → (real)
邊緣的邊緣幅度(帶符號)。
Distance (output_control) real-array → (real)
連續(xù)邊之間的距離。
06. 結(jié)果
如果參數(shù)值正確,則算子measure_pos返回值2(H_MSG_TRUE)。 否則會引發(fā)異常。
HDevelop例程
measure_pin.hdev 測量IC的引腳
measure_ic_leads.hdev 測量IC的引線
measure_fill_level.hdev 檢查細(xì)頸瓶的液位
measure_arc.hdev 測量金屬部件沿著圓弧的的寬度
gen_measure_rectangle2.hdev 測量垂直于給定線的邊緣
gen_measure_arc.hdev 測量垂直于給定弧的邊
create_drawing_object_rectangle2.hdev 使用繪圖對象在矩形內(nèi)交互測量直邊
3d_coordinates.hdev 測量世界坐標(biāo)中的傾斜物體
程序示例
07. 附錄
7.1 機(jī)器視覺博客匯總
網(wǎng)址:https://dengjin.blog.csdn.net/article/details/116837497
總結(jié)
以上是生活随笔為你收集整理的【机器视觉】 measure_pos算子的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【机器视觉】 measure_pairs
- 下一篇: 【机器视觉】 measure_proje