Halcon1D灰度测量

本文介绍了使用Halcon进行1D灰度测量的两个实际案例:check_smd_tilt用于检测SMD元件的倾斜,count_fish_sticks则应用于计数鱼棒的数量,展示其在精度和效率上的优势。
摘要由CSDN通过智能技术生成

(1)1D灰度测量案例check_smd_tilt

* This program checks if SMDs are nearly horizontal or if they
* are tilted with respect to the camera.
* The images were taken with a small depth of field, therefore
* tilted SMDs are partly blurred.
* First, the SMDs are segmented from the image. Then, the
* amplitudes of the edges (first derivatives of the gray values)
* are computed. The edge amplitude is weak in blurred regions.
* Therefore, tilted SMDs can be detected by comparing the edge
* amplitudes in the left and right parts of the SMDs.
* 
dev_update_off ()
dev_close_window ()
dev_open_window (0, 0, 640 * .7, 512 * .7, 'black', WindowHandle)
dev_set_draw ('margin')
dev_set_line_width (3)
dev_open_window (0, 640 * .7 + 12, 640 * .7, 512 * .7, 'black', GrayProfileWindow)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
set_display_font (GrayProfileWindow, 16, 'mono', 'true', 'false')
* 
NumImages := 10
for Index := 1 to NumImages by 1
    read_image (Image, 'smd/smd_tilted_' + Index$'02')
    * 
    * Segment the SMD
    var_threshold (Image, Region, 20, 20, 0.1, 2, 'dark')
    connection (Region, ConnectedRegions)
    select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 15000, 99999999)
    shape_trans (SelectedRegions, RegionTrans, 'convex')
    reduce_domain (Image, RegionTrans, ImageReduced)
    * 
    * Check if the SMD is tilted
    *找出边缘,测量边缘图像的灰度
    sobel_amp (ImageReduced, EdgeAmplitude, 'sum_abs', 3)
    *根据条件找出最小内接矩形
    smallest_rectangle2 (RegionTrans, Row, Column, Phi, Length1, Length2)
    gen_rectangle2 (Rectangle, Row, Column, Phi, Length1 - 3, 20)
    gen_measure_rectangle2 (Row, Column, Phi, Length1 - 3, 20, 640, 512, 'nearest_neighbor
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

stephon_100

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值