ball_seq.hdev检测球形焊锡
* ball_seq.hdev: Inspection of Ball Bonding,检测球形焊锡
*
dev_update_off ()
ImageNames := 'die/' + ['die_02','die_03','die_04','die_07']
dev_set_colored (12)
read_image (Bond, ImageNames[0])
get_image_size (Bond, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_draw ('margin')
dev_set_line_width (3)
NumImages := |ImageNames|
for I := 0 to NumImages - 1 by 1
* 初始化
gen_empty_region (Forbidden)
read_image (Bond, ImageNames[I])
dev_display (Bond)
* 1、粗定位,使用白的区域和ROI在一起的特性
* 使用[最大灰度-80,255]来定位
min_max_gray (Bond, Bond, 0, Min, Max, Range)
threshold (Bond, Bright, Max - 80, 255)
shape_trans (Bright, Die, 'rectangle2')
dev_display (Die)
reduce_domain (Bond, Die, DieGrey)
min_max_gray (Die, Bond, 0, Min, Max, Range)
* 2、二次定位,使用[0,Min+ 30]来定位暗ROI
threshold (DieGrey, Wires, 0, Min + 30)
fill_up_shape (Wires, WiresFilled, 'area', 1, 100)
opening_circle (WiresFilled, Balls, 9.5)
connection (Balls, SingleBalls)
select_shape_std (SingleBalls, Rect, 'rectangle1', 90)
difference (SingleBalls, Rect, IntermediateBalls)
* 包含ROI区域附近和ROI灰度差不多的区域,以及进行填充区域之间的空白
* 比单纯膨胀获得的干扰少
expand_gray (IntermediateBalls, Bond, Forbidden, RegionExpand, 4, 'image', 6)
opening_circle (RegionExpand, RoundBalls, 15.5)
sort_region (RoundBalls, FinalBalls, 'first_point', 'true', 'column')
smallest_circle (FinalBalls, Row, Column, Radius)
NumBalls := |Radius|
Diameter := 2 * Radius
meanDiameter := sum(Diameter) / NumBalls
mimDiameter := min(Diameter)
dev_clear_window ()
dev_display (Bond)
dev_display (RoundBalls)
if (I != NumImages)
disp_continue_message (WindowHandle, 'black', 'true')
endif
* stop ()
endfor