对目标区域进行轮廓提取,可以用于判定形状等。
Region (input_object) | Regions for which the boundary is to be computed. | 区域 | ||||||
RegionBorder (output_object) | Resulting boundaries. | 输出的边界 | ||||||
BoundaryType (input_control) | Boundary type.
|
边界类型 |
Regions (input_object) | Input regions. | 区域 | ||||||
Contours (output_object) | Resulting contours. | 输出的边界 | ||||||
Mode (input_control) | Mode of contour generation.
|
轮廓生成方式 |
XLD (input_object) | Contours or polygons to be examined. | XLD |
Row (output_control) | Row coordinate of the center point of the enclosing rectangle. | 输出的行坐标 |
Column (output_control) | Column coordinate of the center point of the enclosing rectangle. | 输出的列坐标 |
Phi (output_control) | Orientation of the enclosing rectangle (arc measure). Assertion: ((- pi / 2) < Phi) && (Phi <= (pi / 2)) |
弧度 |
Length1 (output_control) | First radius (half length) of the enclosing rectangle. Assertion: Length1 >= 0.0 |
第一个边长 |
Length2 (output_control) | Second radius (half width) of the enclosing rectangle. Assertion: (Length2 >= 0.0) && (Length2 <= Length1) |
第二个边长 |
Rectangle (output_object) | Rectangle contour. | 输出的矩形轮廓 |
Row (input_control) | Row coordinate of the center of the rectangle. Default value: 300.0 |
行坐标 |
Column (input_control) | Column coordinate of the center of the rectangle. Default value: 200.0 |
列坐标 |
Phi (input_control) | Orientation of the main axis of the rectangle [rad]. Default value: 0.0 Restriction: ((- pi / 2) < Phi) && (Phi <= (pi / 2)) |
弧度 |
Length1 (input_control) | First radius (half length) of the rectangle. Default value: 100.5 |
第一个边长 |
Length2 (input_control) | Second radius (half width) of the rectangle. Default value: 20.5 |
第二个边长 |
Contours (input_object) | Contours to be segmented. | 要分割的轮廓 |
ContoursSplit (output_object) | Segmented contours. | 输出的分割轮廓 |
Mode (input_control) | Mode for the segmentation of the contours. Default value: 'lines_circles' List of values: 'lines', 'lines_circles', 'lines_ellipses' |
轮廓分割模式 |
SmoothCont (input_control) | Number of points used for smoothing the contours. Default value: 5 Suggested values: 0, 3, 5, 7, 9 Restriction: (SmoothCont == 0) || ((SmoothCont >= 3) && odd(SmoothCont)) |
用于平滑轮廓的点的数目 |
MaxLineDist1 (input_control) | Maximum distance between a contour and the approximating line (first iteration). Default value: 4.0 Suggested values: 1.0, 1.5, 2.0, 2.5, 3.0, 3.5 Restriction: MaxLineDist1 >= 0.0 |
第一次迭代时轮廓线与近似线之间的最大距离 |
MaxLineDist2 (input_control) | Maximum distance between a contour and the approximating line (second iteration). |
第二次迭代时轮廓线与近似线之间的最大距离 |
Contours (input_object) | Input XLD contours. | XLD轮廓 | ||||||||||||
SelectedContours (output_object) | Output XLD contours. | 输出的XDL轮廓 | ||||||||||||
Feature (input_control) | Feature to select contours with.
|
特征选择 | ||||||||||||
Min1 (input_control) | Lower threshold. Default value: 0.5 |
最小值1 | ||||||||||||
Max1 (input_control) | Upper threshold. Default value: 200.0 |
最大值1 | ||||||||||||
Min2 (input_control) | Lower threshold. Default value: -0.5 |
最小值2 | ||||||||||||
Max2 (input_control) | Upper threshold. Default value: 0.5 |
最大值2 |
Contours (input_object) | Contours to be sorted. | 要排序的轮廓 | ||||||||||
SortedContours (output_object) | Sorted contours. | 输出的排序轮廓 | ||||||||||
SortMode (input_control) | Kind of sorting.
|
排序种类 | ||||||||||
Order (input_control) | Increasing or decreasing sorting order. Default value: 'true' List of values: 'false', 'true' |
减或增序 | ||||||||||
RowOrCol (input_control) | Sorting first with respect to row, then to column. Default value: 'row' List of values: 'column', 'row' |
行或列 |
Contour (input_object) | Input XLD contour. | XLD轮廓 |
Name (input_control) | Name of the attribute. Default value: 'regr_norm_row' Suggested values: 'regr_norm_row', 'regr_norm_col', 'regr_mean_dist', 'regr_dev_dist', 'cont_approx', 'bright_dark', 'is_hole' |
属性名 |
Attrib (output_control) | Attribute values. | 属性值 |
Contours (input_object) | Input contours. | XLD轮廓 | ||||||||||
Algorithm (input_control) | Algorithm for the fitting of lines. Default value: 'tukey' List of values: 'drop', 'gauss', 'huber', 'regression', 'tukey'
|
直线拟合算法 | ||||||||||
MaxNumPoints (input_control) | Maximum number of contour points used for the computation (-1 for all points). |
用于计算的最大轮廓点数量(-1表示所有点) | ||||||||||
ClippingEndPoints (input_control) | Number of points at the beginning and at the end of the contours to be ignored for the fitting. Default value: 0 Restriction: ClippingEndPoints >= 0 |
拟合时忽略轮廓开始点和结束点的个数 | ||||||||||
Iterations (input_control) | Maximum number of iterations (unused for 'regression'). Default value: 5 Restriction: Iterations >= 0 |
最大迭代次数(regression不使用) | ||||||||||
ClippingFactor (input_control) | Clipping factor for the elimination of outliers (typical: 1.0 for 'huber' and 'drop' and 2.0 for 'tukey'). Default value: 2.0 List of values: 1.0, 1.5, 2.0, 2.5, 3.0 Restriction: ClippingFactor > 0 |
裁剪因子用于消除异常值(典型的:“huber”和“drop”时使用1,“tukey”时使用2) | ||||||||||
RowBegin (output_control) | Row coordinates of the starting points of the line segments. | 线段起始点的行坐标 | ||||||||||
ColBegin (output_control) | Column coordinates of the starting points of the line segments. | 线段起始点的列坐标 | ||||||||||
RowEnd (output_control) | Row coordinates of the end points of the line segments. | 线段结束点的行坐标 | ||||||||||
ColEnd (output_control) | Column coordinates of the end points of the line segments. | 线段结束点的列坐标 | ||||||||||
Nr (output_control) | Line parameter: Row coordinate of the normal vector. | 线参数:向量的行坐标 | ||||||||||
Nc (output_control) | Line parameter: Column coordinate of the normal vector. | 线参数:向量的列坐标 | ||||||||||
Dist (output_control) | Line parameter: Distance of the line from the origin. | 线参数:直线到原点的距离 |
Contour (output_object) | Resulting contour. | 输出的轮廓 |
Row (input_control) | Row coordinates of the polygon. Default value: [0,1,2,2,2] Suggested values: 0, 1, 2, 3, 4, 5, 10, 20, 50, 100, 200, 500 |
行坐标 |
Col (input_control) | Column coordinates of the polygon. Default value: [0,0,0,1,2] Suggested values: 0, 1, 2, 3, 4, 5, 10, 20, 50, 100, 200, 500 |
列坐标 |
read_image (Image, 'E:/照片/轮廓.png')
decompose3 (Image, Image1, Image2, Image3)
trans_from_rgb (Image1, Image2, Image3, ImageResult1, ImageResult2, ImageResult3, 'hsv')
auto_threshold (ImageResult3, Regions, 2)
area_center (Regions, Area, Row, Column)
connection (Regions, ConnectedRegions)
count_obj (ConnectedRegions, Number)
dev_set_draw ('margin')
for Index := 1 to Number by 1
select_obj (ConnectedRegions, ObjectSelected, Index)
area_center (ObjectSelected, Area1, Row1, Column1)
*提取感兴趣的特征
if (Area1 > 300 and Area1 < 500)
dev_clear_window()
dev_display (ObjectSelected)
boundary (ObjectSelected, RegionBorder, 'outer')
gen_contour_region_xld (RegionBorder, Contours, 'border')
*规则形状-矩形
smallest_rectangle2_xld (Contours, RowRec, ColumnRec, Phi1, LengthRec1, LengthRec2)
gen_rectangle2_contour_xld (Rectangle, RowRec, ColumnRec, Phi1, LengthRec1, LengthRec2)
*不规则形状-多边形
segment_contours_xld (Contours, ContoursSplit, 'lines', 0, 0, 0)
select_contours_xld (ContoursSplit, SelectedContours, 'contour_length', 0.5, 200, -0.5, 0.5)
sort_contours_xld (SelectedContours, SortedContours, 'upper_left', 'true', 'row')
count_obj (SortedContours, Number1)
gen_empty_obj (Lines)
for Index1 := 1 to Number1 by 1
select_obj (SortedContours, ObjectSelected1, Index1)
get_contour_global_attrib_xld (ObjectSelected1, 'cont_approx', Attrib)
*-1:线 0:椭圆 1:圆
if (Attrib == -1)
fit_line_contour_xld (ObjectSelected1, 'tukey', 2, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
gen_contour_polygon_xld (Polygon, [RowBegin,RowEnd], [ColBegin,ColEnd])
concat_obj (Lines, Polygon, Lines)
endif
endfor
break
endif
endfor
dev_clear_window ()
dev_display (Lines)
矩形
不规则