[Halcon]


dev_close_window()
read_image(Bond, 'die_02')
get_image_size(Bond, Width, Height)
dev_open_window(0, 0, Width, Height, 'black', WindowHandle)
dev_set_draw('margin')
dev_set_line_width(3)


dev_display(Bond)
min_max_gray(Bond, Bond, 0, Min, Max, Range)
threshold(Bond, Bright, Max-80, 255)
shape_trans (Bright, Die, 'rectangle2')
dev_display(Bright)
dev_display(Die)
reduce_domain(Bond, Die, DieGray)
min_max_gray(Die, Bond, 0, Min, Max, Range)
threshold(DieGray, Wires, 0, Min+30)


fill_up_shape(Wires, WiresFillUp, 'area', 1, 100)
opening_circle(WiresFillUp, Balls, 9.5)
connection(Balls, SingleBalls)
select_shape_std (SingleBalls, Rect, 'rectangle1', 90)
difference(SingleBalls, Rect, InterBalls)
gen_empty_region(Forbidden)
expand_gray (SingleBalls, Bond, Forbidden, RegionExpand, 4, 'image', 6)


opening_circle(RegionExpand, RoundBalls, 15.5)
sort_region (RegionExpand, FinalBalls, 'first_point', 'true', 'column')
smallest_circle(FinalBalls, Row, Column, Radius)


NumBalls := |Radius|
Diameter := 2*Radius
meanDiameter := sum(Diameter)/NumBalls
mimDiameter  := min(Diameter)
dev_display(RoundBalls)


你可能感兴趣的:([Halcon])