- * Image Acquisition 01: Code generated by Image Acquisition 01
- list_files ('C:/Users/Administrator/Desktop/线条分割', ['files','follow_links','recursive'], ImageFiles)
- tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles)
- for Index := 0 to |ImageFiles| - 1 by 1
- read_image (Image, ImageFiles[Index])
- * Image Acquisition 01: Do something
- edges_sub_pix (Image, Edges, 'canny', 3, 30, 60)
- gen_region_contour_xld (Edges, Region, 'filled')
- union1 (Region, RegionUnion)
- smallest_rectangle2 (RegionUnion, Row, Column, Phi, Length1, Length2)
- gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
- boundary (Rectangle, RegionBorder, 'inner')
- * distance_pp (970, 725, 857, 920, Distance)
- *不是严格等间距,所以有两个D
- D1:=226
- D2:=D1-24
-
- tuple_cos (Phi, Cos)
- tuple_sin (Phi, Sin)
-
- *左上
- LT_X := Column+(-Length1*Cos - Length2*Sin)
- LT_Y := Row-(-Length1*Sin + Length2*Cos)
-
- *左下
- LB_X := Column+(-Length1*Cos + Length2*Sin)
- LB_Y := Row-(-Length1*Sin - Length2*Cos)
-
- RB_X := Column+(Length1*Cos + Length2*Sin)
- RB_Y := Row-(Length1*Sin - Length2*Cos)
-
- RT_X := Column+(Length1*Cos - Length2*Sin)
- RT_Y := Row-(Length1*Sin + Length2*Cos)
-
- gen_cross_contour_xld (Cross, LT_Y, LT_X, 36, 0)
- gen_cross_contour_xld (Cross2, LB_Y, LB_X, 36, 0)
-
- gen_empty_obj (RegionLines1)
- gen_empty_obj (RegionLines2)
-
- for index := 1 to 7 by 1
- if(1==index)
- D:=D1
- else
- D:=D1+(index-1)*D2
- endif
- ColBegin:=LT_X+cos(-Phi)*D
- RowBegin:=LT_Y+sin(-Phi)*D
- ColEnd:=LT_X+cos(-Phi+rad(90))*D
- RowEnd:=LT_Y+sin(-Phi+rad(90))*D
- gen_region_line (RegionLines111, RowBegin, ColBegin, RowEnd, ColEnd)
- angle_lx (RowBegin, ColBegin, RowEnd, ColEnd, Angle)
- *延长直线起点和终点
- * k2:=tan(-Angle)
- ColBeginNew:=ColBegin-cos(-Angle)*300
- RowBeginNew:=RowBegin-sin(-Angle)*300
- ColEndNew:=ColEnd+cos(-Angle)*300
- RowEndNew:=RowEnd+sin(-Angle)*300
- gen_region_line (line, RowBeginNew, ColBeginNew, RowEndNew, ColEndNew)
- intersection (line, RegionBorder, RegionIntersection)
- connection (RegionIntersection, ConnectedRegions)
- area_center (ConnectedRegions, Area, Row1, Column1)
- gen_region_line (line2, Row1[0], Column1[0], Row1[1], Column1[1])
- concat_obj (RegionLines1, line2, RegionLines1)
- endfor
-
- for index := 1 to 7 by 1
- if(1==index)
- D:=D1
- else
- D:=D1+(index-1)*D2
- endif
- ColBegin:=RT_X+cos(-Phi+rad(180))*D
- RowBegin:=RT_Y+sin(-Phi+rad(180))*D
- ColEnd:=RT_X+cos(-Phi+rad(90))*D
- RowEnd:=RT_Y+sin(-Phi+rad(90))*D
- gen_region_line (RegionLines111, RowBegin, ColBegin, RowEnd, ColEnd)
- angle_lx (RowBegin, ColBegin, RowEnd, ColEnd, Angle)
- *延长直线起点和终点
- * k2:=tan(-Angle)
- ColBeginNew:=ColBegin-cos(-Angle)*300
- RowBeginNew:=RowBegin-sin(-Angle)*300
- ColEndNew:=ColEnd+cos(-Angle)*300
- RowEndNew:=RowEnd+sin(-Angle)*300
- gen_region_line (line, RowBeginNew, ColBeginNew, RowEndNew, ColEndNew)
- intersection (line, RegionBorder, RegionIntersection)
- connection (RegionIntersection, ConnectedRegions)
- area_center (ConnectedRegions, Area, Row1, Column1)
- gen_region_line (line2, Row1[0], Column1[0], Row1[1], Column1[1])
- concat_obj (RegionLines2, line2, RegionLines2)
- endfor
- dev_display (Image)
- dev_display (RegionLines1)
- dev_display (RegionLines2)
- stop ()
- endfor
复制代码
|