|
距离矩阵法检测异常
- dev_close_window ()
- dev_open_window (0, 0, 400, 400, 'black', WindowHandle)
- * 产生一个400x400的图像region,用于模拟这种缺陷检测方法
- gen_region_polygon (Line1, [300,300,200,0], [0,200,300,300])
- gen_region_polygon (Line2, [350,350,250,0], [0,250,350,350])
- union2 (Line1, Line2, Lines)
- dilation_circle (Lines, ThickLines, 7.5)
- gen_circle (Error1, 120, 347, 7.5)
- gen_circle (Error2, 90, 287, 7.5)
- gen_circle (Error3, 302, 202, 7.5)
- gen_circle (Error4, 242, 337, 7.5)
- gen_circle (Error5, 346, 248, 7.5)
- gen_circle (Error6, 204, 312, 7.5)
- union2 (Error1, Error3, Errors1)
- union2 (Errors1, Error5, ErrorsAdd)
- union2 (Error2, Error4, Errors2)
- union2 (Errors2, Error6, ErrorsRem)
- union2 (ThickLines, ErrorsAdd, ThichLinesAdd)
- union2 (ThickLines, ErrorsAdd, ThichLinesAdd)
- difference (ThichLinesAdd, ErrorsRem, ThickLinesError)
- * 采用distance_transform计算region距离--无缺陷的图
- * the distance of the point to the border of the region
- * 'city-block'是点到边界的最短距离,只能水平、垂直移动
- * 'chessboard'是点到边界的最短距离,水平、垂直、斜对角 均可移动
- * 'octagonal'是点到边界的最短距离,水平、垂直、斜对角 均可移动,斜对角权重更大
- * 'chamfer-3-4'是点到边界的最短距离,水平、垂直的权重为3,斜对角权重为4
- * 'euclidean'欧氏距离图
- distance_transform (ThickLines, LinesDistance, 'chamfer-3-4', 'true', 400, 400)
- skeleton (ThickLines, Skeleton)
- reduce_domain (LinesDistance, Skeleton, LinesDistanceReduced)
- threshold (LinesDistanceReduced, NoErrors, [0,9], [6,20])
- dev_clear_window ()
- dev_set_draw ('fill')
- dev_set_color ('gray')
- dev_display (ThickLines)
- dev_set_draw ('margin')
- dev_set_color ('red')
- dev_display (Skeleton)
复制代码- * the distance of the point to the border of the region
- * 采用distance_transform计算region距离--有缺陷的图
- distance_transform (ThickLinesError, LinesDistanceError, 'chamfer-3-4', 'true', 400, 400)
- skeleton (ThickLinesError, SkeletonError)
- reduce_domain (LinesDistanceError, SkeletonError, LinesDistanceErrorReduced)
- threshold (LinesDistanceErrorReduced, Errors, [0,9], [6,20])
- *
- * 形态学操作缺陷region
- dilation_circle (Errors, ErrorsDilation, 5.5)
- connection (ErrorsDilation, ConnectedRegions)
- area_center (ConnectedRegions, Area, Row, Column)
- dev_clear_window ()
- dev_set_draw ('fill')
- dev_set_color ('gray')
- dev_display (ThickLinesError)
- dev_set_draw ('margin')
- dev_set_color ('red')
- dev_set_line_width (3)
- disp_circle (WindowHandle, Row, Column, gen_tuple_const(|Row|,25.5))
- dev_set_draw ('fill')
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|