尺寸测量

 

效果

 

思路: 圆心到缺少物件的距离,先计算圆心的坐标生成一个区域,然后找到缺少物件的区域,从圆心生成一个区域与 缺少物件的区域交集从而获取交集区域  2个区域获取最小的距离

read_image (Image, '1')
get_image_size (Image, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width/4, Height/4, 'black', WindowHandle)
dev_display (Image)
dev_set_draw ('fill')
rgb1_to_gray (Image, GrayImage)
threshold (GrayImage, Region, 162, 255)
connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 574053, 719933)
** 一定要将黑色的孔洞填满
closing_circle (SelectedRegions, RegionClosing, 150)
reduce_domain (GrayImage, RegionClosing, ImageReduced)

binary_threshold (ImageReduced, Region1, 'max_separability', 'dark', UsedThreshold)
connection (Region1, ConnectedRegions1)
select_shape (ConnectedRegions1, SelectedRegions1, 'area', 'and', 50056.1, 65190.6)
smallest_circle (SelectedRegions1, Row, Column, Radius)
gen_cross_contour_xld (Cross, Row, Column, 100, 0)
**点生成区域
gen_region_points (Region2, Row, Column)
dev_display (GrayImage)
dev_display (Cross)

select_shape (ConnectedRegions1, SelectedRegions2, 'area', 'and', 25392.4, 29652.5)
opening_rectangle1 (SelectedRegions2, RegionOpening, 28, 28)
boundary (RegionOpening, RegionBorder, 'inner')
smallest_rectangle2 (RegionBorder, Row1, Column1, Phi, Length1, Length2)
gen_rectangle2 (Rectangle, Row, Column, Phi, Radius/2, Length2+800)

intersection (Rectangle, RegionBorder, RegionIntersection)
distance_rr_min (RegionIntersection, Region2, MinDistance, Row11, Column11,\
Row2, Column2)
gen_region_line (RegionLines, Row11, Column11,Row2, Column2)

posted @ 2024-07-11 14:37  陌念  阅读(27)  评论(0)    收藏  举报