目录
获取边缘轮廓将轮廓拟合为直线将直线生成新有清晰角的三角形
获取边缘轮廓
read_image
(Image1234
, 'F:/Desktop/1234.png')
edges_sub_pix
(Image1234
, Edges
, 'canny', 1, 20, 40)
select_contours_xld
(Edges
, SelectedContours
, 'contour_length', 600,1200, -0.5, 0.5)
segment_contours_xld
(SelectedContours
, ContoursSplit
, 'lines_circles', 10, 9, 2)
select_contours_xld
(ContoursSplit
, SelectedContours1
, 'contour_length', 20, 600, -0.5, 0.5)
fit_line_contour_xld
(SelectedContours1
, 'tukey', -1, 0, 5, 2, RowBegin1
, ColBegin1
, RowEnd1
, ColEnd1
, Nr
, Nc
, Dist
)
将轮廓拟合为直线
上步获取到三边的的参数Begain与End点的信息 这步使用一次函数的方法获得直线的延长线 一次函数为:y = kx+b 已知直线的Begain与End点的信息 r:= RowBegin - RowEnd n:= ColBegin- ColEnd k:= r/n 由此得出直线的斜率k b:=RowBegin - kColBegin 获得直线的位移b 最后获取直线的延长线 横坐标开始点设置为接近0点的5,终点设置为大于图像范围的值2500(视情况选择) row1:=k5+b row2:=k2500+b disp_line (3600, row1,5 , row2, 2500)
r
:= RowBegin1
[0] - RowEnd1
[0]
n
:= ColBegin1
[0] - ColEnd1
[0]
disp_line
(3600, 0,ColEnd1
[0] , 100, ColEnd1
[0])
r
:= RowBegin1
[1] - RowEnd1
[1]
n
:= ColBegin1
[1] - ColEnd1
[1]
k1
:= r
/n
b1
:=RowBegin1
[1] - k1
*ColBegin1
[1]
row2
:=k1
*5+b1
row22
:=k1
*2500+b1
disp_line
(3600, row2
,5 , row22
, 2500)
r
:= RowBegin1
[2] - RowEnd1
[2]
n
:= ColBegin1
[2] - ColEnd1
[2]
k1
:= r
/n
b1
:=RowBegin1
[2] - k1
*ColBegin1
[2]
row3
:=k1
*5+b1
row32
:=k1
*2500+b1
disp_line
(3600, row3
,5 , row32
, 2500)
将直线生成新有清晰角的三角形
intersection_lines
(0,ColEnd1
[0] , 100, ColEnd1
[0], row2
,5 , row22
, 2500, RowA
, ColumnA
, IsOverlapping
)
intersection_lines
(0,ColEnd1
[0] , 100, ColEnd1
[0], row3
,5 , row32
, 2500, RowB
, ColumnB
, IsOverlapping
)
intersection_lines
(row2
,5 , row22
, 2500, row3
,5 , row32
, 2500, RowC
, ColumnC
, IsOverlapping
)
Rows
:=[RowA,RowB
,RowC
,RowA
]
Cols
:=[ColumnA,ColumnB
,ColumnC
, ColumnA
]
gen_contour_polygon_xld
(Contour
, Rows
, Cols
)