- * 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, 'courier', '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 smooths 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)
- tuple_find (sgn(Energy-0.05), -1, Indices)
- select_obj (Basins, Defects, Indices+1)
- *
- dev_display (Image)
- dev_display (Defects)
- count_obj (Defects, NDefects)
- disp_message (WindowHandle, NDefects+'\'mura\'defects detected', 'window', -1, -1, 'red', 'true')
- if (f < 2)
- disp_continue_message (WindowHandle, 'black', 'true')
- stop ()
- endif
- endfor
来源: http://www.bubuko.com/infodetail-3104163.html