赞
踩
- *获取图像大小
- get_image_size (Image, Width, Height)
- *将图像转化为频域图像
- rft_generic (Image, ImageFFT, 'to_freq', 'none', 'complex', Width)
- *生成一个高斯滤波核
- gen_gauss_filter (ImageGauss, 50, 50, 0, 'n', 'rft', Width, Height)
- *将频域图像核高斯滤波核进行卷积运算
- convol_fft (ImageFFT, ImageGauss, ImageConvol)
- *将卷积后的图像转换为空间域图像
- rft_generic (ImageConvol, IlluminationImage, 'from_freq', 'none', 'byte', Width)
- return ()
-
-
-
-
- * select_mask_obj selects one or more single elements of the object array
- * Objects and returns them in SelectedObjects.
- * The elements of Mask determine if the corresponding elements of Objects are selected.
- * If the value is greater than 0, the corresponding element is selected.
- *
- * Check number of elements
- count_obj (Objects, Number)
- if (Number != |Mask|)
- throw ('Number of elements in Objects and Mask do not match.')
- endif
- *
- * Check type of mask elements
- AllNumbers := sum(is_real_elem(Mask)) + sum(is_int_elem(Mask)) == |Mask|
- if (not AllNumbers and Mask != [])
- throw ('Invalid type: Elements of Mask must be integer or real numbers.')
- endif
- *
- * Use select_mask for tuples to generate a list of object indices.
- Indices := select_mask([1:|Mask|],Mask)
- select_obj (Objects, SelectedObjects, Indices)
- return ()
- * 关闭窗口
- 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)
-
- *设置字体信息:字体大小为16,字体为mono,粗体,斜体
- 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')
-
- *获取彩色图像的三个通道,R,G,B
- decompose3 (Image, R, G, B)
-
- *缺陷是暗斑。 因此,通过原始图像减去背景照明,从而使缺陷变得更加明显。
- estimate_background_illumination (B, ImageFFT1)
-
- *用缺陷图减去背景图
- sub_image (B, ImageFFT1, ImageSub, 2, 100)
-
- *中值滤波
- median_image (ImageSub, ImageMedian, 'circle', 9, 'mirrored')
-
- *提取分水岭盆地
- watersheds_threshold (ImageMedian, Basins, 20)
-
- *计算灰度共生矩阵的灰度值特性,暗斑的能量非常低
- cooc_feature_image (Basins, ImageMedian, 6, 0, Energy, Correlation, Homogeneity, Contrast)
- *Energy小于0.05,Mask为1,否则为0
- Mask := Energy [<=] 0.05
- select_mask_obj (Basins, Defects, Mask)
-
- * 显示图像
- dev_display (Image)
-
- * 显示缺陷
- dev_display (Defects)
-
- stop()
-
- endfor
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。