Halcom ·¢±íÓÚ 2018-6-13 22:40:25

»®ºÛ¡¢¹ÎºÛȱÏݼì²â

»®ºÛ¡¢¹ÎºÛȱÏݼì²â£º
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)




Ò³: [1]
²é¿´ÍêÕû°æ±¾: »®ºÛ¡¢¹ÎºÛȱÏݼì²â