设置首页收藏本站
12
返回列表 发新帖
开启左侧

这个划痕有什么方法提取出来吗

[复制链接]
wang675920736 发表于 2023-7-18 09:11:48 | 显示全部楼层
liangmu 发表于 2023-7-4 09:14
其余部分再处理吧

这种应该可以,就怕客户说这个能连城线的算缺陷,不在一条线上可以放。。
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
东风来喽 发表于 2023-7-28 10:30:08 | 显示全部楼层

可以用傅里叶变换

本帖最后由 东风来喽 于 2023-7-28 10:57 编辑


read_image (RoiTask020230626, 'G:/halcon缺陷检测/3. 频域+空间结合法/划痕检测/ROI_task_0_20230626.png')
dev_get_window (WindowHandle)
rgb1_to_gray (RoiTask020230626, GrayImage)
get_image_size (GrayImage, Width, Height)

threshold (GrayImage, Region, 150, 255)
closing_rectangle1 (Region, RegionClosing, 10, 10)
connection (RegionClosing, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'height', 'and', 200, 99999)
union1 (SelectedRegions, RegionUnion)
dilation_rectangle1 (RegionUnion, RegionDilation, 11, 11)
reduce_domain (GrayImage, RegionDilation, ImageReduced)

fft_generic (ImageReduced, ImageFFT, 'to_freq', -1, 'none', 'dc_center', 'complex')


gen_rectangle1 (ROI_0, 203.324, 147.168, 250.621, 158.319)
gen_rectangle1 (TMP_Region, 202.793, 453.022, 251.152, 464.173)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 199.592, 755.68, 255.922, 766.83)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 205.969, 878.871, 253.796, 891.084)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 203.843, 1181.01, 254.859, 1194.28)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 211.283, 1060.47, 247.419, 1072.15)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 191.606, 1486.55, 264.411, 1500.36)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 160.784, 1789.22, 298.953, 1803.56)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 200.109, 1637.35, 262.816, 1651.16)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 207.549, 1332.56, 251.125, 1347.43)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 135.529, 1940.94, 318.776, 1958.95)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, -2.65751, 2089.57, 451.705, 2112.09)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, -2.65751, 2244.96, 456.211, 2265.22)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, -7.16358, 2395.84, 459.215, 2416.86)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 119.923, 2547.66, 319.737, 2565.19)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 137.991, 2697.94, 312.829, 2717.58)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 190.071, 2857.77, 263.938, 2866.26)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 179.442, 3004.85, 283.601, 3019.19)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 195.795, 3313.3, 257.322, 3322.33)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 208.057, 3436.04, 245.612, 3442.42)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 209.122, 3617.33, 243.215, 3625.84)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 211.049, 3739.66, 245.675, 3749.23)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 204.07, 4044.99, 254.456, 4051.76)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 196.615, 4349.28, 259.079, 4356.05)
union2 (ROI_0, TMP_Region, ROI_0)
gen_rectangle1 (TMP_Region, 207.272, 3161.38, 242.064, 3170.7)
union2 (ROI_0, TMP_Region, ROI_0)
paint_region (ROI_0, ImageFFT, ImageResult, 0, 'fill')

* gen_gauss_filter (Filter, 20, 20, 0, 'none', 'dc_center', Width, Height)
* convol_fft (ImageFFT, Filter, ImageResult)

fft_generic (ImageResult, ImageFFT1, 'from_freq', 1, 'n', 'dc_center', 'real')

scale_image_max (ImageFFT1, ImageScaleMax)

gen_rectangle1 (ROI_0, 60, 1.00033, 276, 4069.9)
reduce_domain (ImageScaleMax, ROI_0, ImageReduced1)

* 方式1:效果不行
* texture_laws (ImageReduced1, ImageTexture, 'el', 2, 5)

* 方式2:效果可以
calculate_lines_gauss_parameters (2, 15, Sigma, Low, High)
lines_gauss (ImageReduced1, Lines, Sigma, Low, High, 'dark', 'true', 'bar-shaped', 'true')
select_contours_xld (Lines, SelectedContours1, 'contour_length', 10, 30, -0.5, 0.5)
select_shape_xld (SelectedContours1, SelectedXLD, 'width', 'and', 5, 99999)

* 方式3:效果可以
mean_image (ImageReduced1, ImageMean, 9, 29)
dyn_threshold (ImageReduced1, ImageMean, RegionDynThresh, 11, 'dark')

connection (RegionDynThresh, ConnectedRegions1)
select_shape (ConnectedRegions1, SelectedRegions1, 'area', 'and', 5, 150)
dilation_rectangle1 (SelectedRegions1, RegionDilation1, 3, 3)
union1 (RegionDilation1, RegionUnion1)
connection (RegionUnion1, ConnectedRegions2)

select_shape (ConnectedRegions2, SelectedRegions2, ['width', 'height'], 'and', [10, 14], [30, 50])

奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
25岁三个老婆 发表于 2023-7-31 14:24:31 | 显示全部楼层
学习学习,这种划痕难度还是挺大的
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表