(1)中值滤波
(2)使用中值滤波做局部阈值
(3)dilation_circle 膨胀:配合union1可使断开的区域挨在一起
(4)skeleton:选择中心轴线
* Image Acquisition 01: Code generated by Image Acquisition 01
read_image (Image, 'C:/Users/Administrator/Desktop/aa.png')
*中值滤波
mean_image (Image, ImageMean, 6, 6)
*dyn_threshold:图像Image相对于图像ImageMean的灰度差进行阈值分割
*var_threshold:使用Mask对图像中指滤波后进行阈值分割
*选择Image中每点像素相对于滤波后图像ImageMean的灰度值加5后的dark部分的图像区域,以选择出深颜色划痕
dyn_threshold (Image, ImageMean, RegionDynThresh, 5, 'dark')
connection (RegionDynThresh, ConnectedRegions)
*去掉小的噪声干扰
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 12.2, 1000)
*扩张区域,使其断开的地方挨在一起
dilation_circle (SelectedRegions, RegionDilation, 2.5)
*连接上划痕
union1 (RegionDilation, RegionUnion)
connection (RegionUnion, ConnectedRegions1)
select_shape (ConnectedRegions1, SelectedRegions1, 'area', 'and', 408.26, 4022.94)
dilation_circle (SelectedRegions1, RegionDilation1, 5)
*选择中心轴线
skeleton (RegionDilation1, Skeleton)
素材图片: