基于形状的模板匹配的一个实例

按照上篇讲的套路,我们再来实现一个例子

这里有如下原图

找出所有的格子

一、选取区域

二、创建模板

创建后,模板的坐标为(0,0),即左上角

三、寻找模板

 

代码:

* Many dies are typically etched on a wafer. Before the single
* dies can be picked by a die bonder and placed onto a lead
* frame, they must be diced from the wafer. Mirror dies are
* used to determine the parameters of the dicing process.
* Here, the positions of the mirror dies are determined using
* shape-based matching.
* 
dev_update_off ()
dev_close_window ()
read_image (Image, 'wafer/wafer_mirror_dies_01')
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_line_width (3)
dev_display (Image)
disp_message (WindowHandle, 'Determine the position of mirror dies on the wafer', 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
* 
* Create a shape model of the mirror dies
gen_rectangle1 (Rectangle, 362, 212, 414, 262)
reduce_domain (Image, Rectangle, ImageReduced)
create_shape_model (ImageReduced, 'auto', rad(0), rad(1), 'auto', 'auto', 'use_polarity', 'auto', 'auto', ModelID)
get_shape_model_contours (ModelContours, ModelID, 1)
* 
* Read the images and process them
for Index := 1 to 4 by 1
    read_image (Image, 'wafer/wafer_mirror_dies_' + Index$'02')
    * 
    * Determine the position of the mirror dies and
    * calculate the runtime needed to find the positions
    count_seconds (S1)
    find_shape_model (Image, ModelID, rad(0), rad(1), 0.5, 0, 0.0, 'least_squares', 2, 0.5, Row, Column, Angle, Score)
    count_seconds (S2)
    Runtime := (S2 - S1) * 1000
    * 
    * Display the results
    gen_cross_contour_xld (Cross, Row, Column, 6, rad(45))
    dev_display (Image)
    dev_display_shape_matching_results (ModelID, 'lime green', Row, Column, Angle, 1, 1, 0)
    dev_set_color ('orange')
    dev_display (Cross)
    disp_message (WindowHandle, |Score| + ' mirror dies located in ' + Runtime$'.1f' + ' ms', 'window', 12, 12, 'black', 'true')
    if (Index != 4)
        disp_continue_message (WindowHandle, 'black', 'true')
        stop ()
    endif
endfor
* 
* Clear the model
clear_shape_model (ModelID)

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值