1.不带角度的两区域的最小距离
read_image (Image151325S132787556058004751, 'C:/Users/Administrator/Desktop/测试.png')
draw_rectangle2_mod (3600, 308, 413, 1.54, 165, 75, Row1, Column1, Phi1, Length11, Length21)
gen_rectangle2 (Rectangle, Row1, Column1, Phi1, Length11, Length21)
reduce_domain (Image151325S132787556058004751, Rectangle, ImageReduced)
dev_close_window ()
dev_open_window (Row1, Column1, 512, 512, 'black', WindowHandle)
dev_display (ImageReduced)
*二值化处理
threshold (ImageReduced, Region, 0, 100)
*分割
connection (Region, ConnectedRegions)
select_obj (ConnectedRegions, ObjectSelected1, 1)
select_obj (ConnectedRegions, ObjectSelected2, 2)
*求两个区域的最短距离
distance_rr_min (ObjectSelected1, ObjectSelected2, MinDistance, Row11, Column11, Row2, Column2)
dev_set_color ('black')
gen_cross_contour_xld (Cross1, Row11, Column11, 20, 0)
gen_cross_contour_xld (Cross2, Row2, Column2, 20, 0)
gen_contour_polygon_xld (Contour, [Row11,Row2], [Column11,Column2])
2.带角度的两区域最小距离
read_image (Image151325S132787556058004751, 'C:/Users/Administrator/Desktop/测试.png')
draw_rectangle2_mod (3600, 308, 413, 1.54, 165, 75, Row1, Column1, Phi1, Length11, Length21)
gen_rectangle2 (Rectangle, Row1, Column1, Phi1, Length11, Length21)
reduce_domain (Image151325S132787556058004751, Rectangle, ImageReduced)
dev_close_window ()
dev_open_window (Row1, Column1, 512, 512, 'black', WindowHandle)
dev_display (ImageReduced)
*二值化处理
threshold (ImageReduced, Region, 0, 100)
*分割
connection (Region, ConnectedRegions)
select_obj (ConnectedRegions, ObjectSelected1, 1)
select_obj (ConnectedRegions, ObjectSelected2, 2)
*求两个区域的最短距离
distance_rr_min (ObjectSelected1, ObjectSelected2, MinDistance, Row11, Column11, Row2, Column2)
dev_set_color ('black')
gen_cross_contour_xld (Cross1, Row11, Column11, 20, 0)
gen_cross_contour_xld (Cross2, Row2, Column2, 20, 0)
gen_contour_polygon_xld (Contour, [Row11,Row2], [Column11,Column2])
*带有角度的最小距离
angle := 20
angle := (angle * 3.14) /360
Row12 := Row11 - 100*sin(angle)
Col12 := Column11 + 100*cos(angle)
gen_contour_polygon_xld (Contour, [Row11,Row12], [Column11,Col12])
distance_pl (Row2, Column2,Row11, Column11, Row12, Col12, Distance)