|
划痕、刮痕缺陷检测:
halcon12 + win32
- dev_update_off ()
- read_image (Image, 'surface_scratch')
- invert_image (Image, ImageInverted)
- get_image_size (Image, Width, Height)
- *
- optimize_rft_speed (Width, Height, 'standard')
- * Enhance the scratches by filtering in the frequency domain
- gen_sin_bandpass (ImageBandpass, 0.4, 'none', 'rft', Width, Height)
- rft_generic (ImageInverted, ImageFFT, 'to_freq', 'none', 'complex', Width)
- convol_fft (ImageFFT, ImageBandpass, ImageConvol)
- rft_generic (ImageConvol, Lines, 'from_freq', 'n', 'byte', Width)
- *
- * Segment the scratches by using morphology
- threshold (Lines, Region, 5, 255)
- connection (Region, ConnectedRegions)
- select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 5, 5000)
- dilation_circle (SelectedRegions, RegionDilation, 5.5)
- union1 (RegionDilation, RegionUnion)
- reduce_domain (Image, RegionUnion, ImageReduced)
- * line_gauss线检测
- lines_gauss (ImageReduced, LinesXLD, 0.8, 3, 5, 'dark', 'false', 'bar-shaped', 'false')
- union_collinear_contours_xld (LinesXLD, UnionContours, 40, 3, 3, 0.2, 'attr_keep')
- select_shape_xld (UnionContours, SelectedXLD, 'contlength', 'and', 15, 1000)
- gen_region_contour_xld (SelectedXLD, RegionXLD, 'filled')
- union1 (RegionXLD, RegionUnion)
- dilation_circle (RegionUnion, RegionScratches, 10.5)
- *
- * Display the results
- dev_set_draw ('margin')
- dev_display (Image)
- dev_display (RegionScratches)
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|