Paste your text here.read_image (Image, 'CutImage.png')
rgb1_to_gray (Image, GrayImage)
get_image_size (GrayImage, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
dev_display (Image)
dev_set_draw ('margin')
*排除塗黑的區塊
mean_image (GrayImage, ImageMean, 50, 50)
threshold (ImageMean, RegionBlacked, 20, 255)
erosion_circle (RegionBlacked, RegionBlackedDilation, 20.5)
median_rect (GrayImage, ImageMedian, 1, 5)
*方法:提取線
lines_gauss (ImageMedian, Lines, 1, 2, 6, 'dark', 'true', 'bar-shaped', 'true')
union_collinear_contours_xld (Lines, UnionContours, 10, 1, 5, 0.4, 'attr_keep')
select_shape_xld (UnionContours, SelectedXLD, 'contlength', 'and', 40, 99999)
select_shape_xld (SelectedXLD, SelectedXLD1, 'anisometry_points', 'and', 10, 99999)
gen_region_contour_xld (SelectedXLD1, RegionLines, 'filled')
intersection (RegionLines, RegionBlackedDilation, RegionIntersection)
union1 (RegionIntersection, RegionUnion1)
closing_circle (RegionUnion1, RegionClosing, 3.5)
connection (RegionClosing, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegionsFinal, 'area', 'and', 75, 9999999)
union1 (SelectedRegionsFinal, RegionUnionFinal)
*方法:邊緣檢測後提取線
derivate_gauss (ImageMedian, DerivGauss, 1, 'gradient')
sobel_amp (ImageMedian, EdgeAmplitude, 'sum_abs', 5)
lines_gauss (EdgeAmplitude, Lines1, 1, 6, 15, 'light', 'true', 'bar-shaped', 'true')
union_collinear_contours_xld (Lines1, UnionContours1, 10, 1, 5, 0.4, 'attr_keep')
select_shape_xld (UnionContours1, SelectedXLD2, 'contlength', 'and', 40, 99999)
select_shape_xld (SelectedXLD2, SelectedXLD3, 'anisometry_points', 'and', 10, 99999)
gen_region_contour_xld (SelectedXLD3, RegionLines1, 'filled')
intersection (RegionLines1, RegionBlackedDilation, RegionIntersection1)
union1 (RegionIntersection1, RegionUnion2)
closing_circle (RegionUnion2, RegionClosing1, 3.5)
connection (RegionClosing1, ConnectedRegions1)
select_shape (ConnectedRegions1, SelectedRegionsFinal1, 'area', 'and', 75, 9999999)
union1 (SelectedRegionsFinal1, RegionUnionFinal1)
*結合兩種方法
union2 (RegionUnionFinal, RegionUnionFinal1, AllRegions)
dilation_circle (AllRegions, Defects, 6.5)
*可視化
dev_set_color ('red')
dev_display (Image)
dev_display (Defects)
文章標籤
全站熱搜
留言列表