【纹理缺陷检测】

文章目录


【纹理缺陷检测】

*translate by zyn. tel&wx:13129980844
*本示例展示了如何检测mura缺陷(* 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

【网络星空】

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

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

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

打赏作者

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

抵扣说明:

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

余额充值