美文网首页
纹理表面缺陷检测

纹理表面缺陷检测

作者: 卡拉肖克_潘 | 来源:发表于2020-07-16 14:57 被阅读0次

今天看到一个缺陷检测很有启发的halcon例子。
启动halcon软件,ctrl+E弹出例程,选择表面检测中的detect_mura_defects_texture 。这个是液晶面板上的mura 损伤检测。

比较有启发的地方是:
1、在频域中高斯滤波后返变换回空域,用于估计背景灰度。
2、分水岭算法分割出若干子区域后,提取各个区域的灰度共生矩阵的特征用于区分缺陷。

原图
背景分割后的效果图
分水岭
结果
* This example shows how to detect mura defects
* in highly textured images
* 
dev_close_window ()
dev_update_off ()
Path := 'lcd/mura_defects_texture_'
read_image (Image, Path + '01')
get_image_size (Image, Width, Height)
dev_open_window (0, 0, 640, 480, 'black', WindowHandle)
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
dev_set_draw ('margin')
dev_set_line_width (3)
dev_set_color ('red')
for F := 1 to 2 by 1
    read_image (Image, Path + F$'.2i')
    decompose3 (Image, R, G, B)
    * Defects are characterized by dark patches. Hence, by substracting the
    * estimated background illumination from the original image the
    * defects become more apparent.
    estimate_background_illumination (B, ImageFFT1)
    sub_image (B, ImageFFT1, ImageSub, 2, 100)
    * Median filter smoothes out the fine texture, simplifying the following
    * segmentation and final detection of defects.
    median_image (ImageSub, ImageMedian, 'circle', 9, 'mirrored')
    watersheds_threshold (ImageMedian, Basins, 20)
    * Dark patches corresponding to defects have a very low energy.
    cooc_feature_image (Basins, ImageMedian, 6, 0, Energy, Correlation, Homogeneity, Contrast)
    Mask := Energy [<=] 0.05
    select_mask_obj (Basins, Defects, Mask)
    * 
    dev_display (Image)
    dev_display (Defects)
    count_obj (Defects, NDefects)
    disp_message (WindowHandle, NDefects + ' \'mura\' defects detected', 'window', 12, 12, 'red', 'true')
    if (F < 2)
        disp_continue_message (WindowHandle, 'black', 'true')
        stop ()
    endif
endfor

相关文章

网友评论

      本文标题:纹理表面缺陷检测

      本文链接:https://www.haomeiwen.com/subject/jfvphktx.html