文章目录
【纹理缺陷检测】
*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


被折叠的 条评论
为什么被折叠?



