在图像中显示文字,数字等文本。
* ball.hdev: Inspection of Ball Bonding
dev_update_window ('off')
dev_close_window ()
dev_open_window (0, 0, 728, 512, 'black', WindowID)
read_image (Bond, 'die/die_03')
dev_display (Bond)
set_display_font (WindowID, 14, 'mono', 'true', 'false')
disp_continue_message (WindowID, 'black', 'true')
stop ()
threshold (Bond, Bright, 100, 255)
shape_trans (Bright, Die, 'rectangle2')
dev_set_color ('green')
dev_set_line_width (3)
dev_set_draw ('margin')
dev_display (Die)
disp_continue_message (WindowID, 'black', 'true')
stop ()
reduce_domain (Bond, Die, DieGrey)
threshold (DieGrey, Wires, 0, 50)
fill_up_shape (Wires, WiresFilled, 'area', 1, 100)
dev_display (Bond)
dev_set_draw ('fill')
dev_set_color ('red')
dev_display (WiresFilled)
disp_continue_message (WindowID, 'black', 'true')
stop ()
opening_circle (WiresFilled, Balls, 15.5)
dev_set_color ('green')
dev_display (Balls)
disp_continue_message (WindowID, 'black', 'true')
stop ()
connection (Balls, SingleBalls)
select_shape (SingleBalls, IntermediateBalls, 'circularity', 'and', 0.85, 1.0)
sort_region (IntermediateBalls, FinalBalls, 'first_point', 'true', 'column')
dev_display (Bond)
dev_set_colored (12)
dev_display (FinalBalls)
disp_continue_message (WindowID, 'black', 'true')
stop ()
smallest_circle (FinalBalls, Row, Column, Radius)
NumBalls := |Radius|
Diameter := 2 * Radius
meanDiameter := sum(Diameter) / NumBalls
mimDiameter := min(Diameter)
dev_display (Bond)
disp_circle (WindowID, Row, Column, Radius)
dev_set_color ('white')
for i := 1 to NumBalls by 1
if (fmod(i,2) == 1)
disp_message (WindowID, 'D: ' + Diameter[i - 1], 'image', Row[i - 1] - 2.7 * Radius[i - 1], max([Column[i - 1] - 60,0]), 'white', 'false')
else
disp_message (WindowID, 'D: ' + Diameter[i - 1], 'image', Row[i - 1] + 1.2 * Radius[i - 1], max([Column[i - 1] - 60,0]), 'white', 'false')
endif
endfor
dev_set_color ('green')
dev_update_window ('on')
disp_continue_message (WindowID, 'black', 'true')
stop ()
dev_close_window ()
注释:
dev_update_window ('off')
和
dev_close_window ()
的区别
:
dev_update_window ('off'):
关闭图像窗口的内容,不关闭图形窗口
dev_close_window ():
关闭图形窗口
dev_open_window (0, 0, 728, 512, 'black', WindowID):
打开一个原点在(0,0)的,宽728,高512,背景为黑色的图形窗口
dev_display (Bond):
显示图像,和matlab的imshow一样。
set_display_font (WindowID, 14, 'mono', 'true', 'false'):
设置显示的字体
disp_continue_message (WindowID, 'black', 'true'):
显示“Press Run (F5) to continue”
dev_set_color ('green'):
设置显示的颜色
dev_set_line_width (3) :设置显示线条的宽度
dev_set_draw ('margin'):设置所画图形的形状
if (fmod(i,2) == 1):
判断i/2的余数是否为1
disp_message (WindowID, 'D: ' + Diameter[i - 1], 'image', Row[i - 1] - 2.7 * Radius[i - 1], max([Column[i - 1] - 60,0]), 'white', 'false'):
在图像的(
Row[i - 1] - 2.7 * Radius[i - 1], max([Column[i - 1] - 60,0])的这个位置显示“D:半径”