自己做了一个图,这个图放在资源里了
结果图是这样(这里只结算了窄区)
代码和备注如下
read_image (Image11, 'C:/Users/Administrator/Desktop/分享/15/11.png')
rgb1_to_gray (Image11, GrayImage)
invert_image (GrayImage, ImageInvert)
threshold (ImageInvert, Region, 128, 255)
dilation_circle (Region, RegionDilation, 5)
reduce_domain (ImageInvert, RegionDilation, ImageReduced)
***线宽大概是10
calculate_lines_gauss_parameters (12,240, Sigma, Low, High)
lines_gauss (ImageReduced, Lines,Sigma, Low, High, 'light', 'true', 'bar-shaped', 'true')
clip_end_points_contours_xld (Lines, Lines, 'num_points', 10)
get_contour_xld (Lines, Row, Col)
get_contour_attrib_xld (Lines, 'width_right', r_width)
get_contour_attrib_xld (Lines, 'width_left', l_width)
widths:=(r_width+l_width)/2***看看跟邻居的比例情况
mean_width :=sort(widths)[round(|widths|*0.5)]
low_width:=mean_width*0.8
high_width:=mean_width*1.1tuple_less_elem (widths, low_width, Less)
tuple_find (Less, 1, Indices)rows:=Row[Indices]
colums:=Col[Indices]
gen_circle (Circle, rows, colums, 2)union1 (Circle, RegionUnion)
connection (RegionUnion, ConnectedRegions)
area_center (ConnectedRegions, Area, Row1, Column)
gen_circle (Circle2, Row1, Column,20)
dev_display (Image11)
dev_display (Circle2)