read_image (Image, '221')
decompose3 (Image, Image1, Image2, Image3)
trans_from_rgb (Image1, Image2, Image3, ImageResult1, ImageResult2, ImageResult3, 'hsv')
scale_image (ImageResult3, ImageScaled, 2.55, 0)
binary_threshold (ImageScaled, Region, 'max_separability', 'light', UsedThreshold)
opening_rectangle1 (Region, RegionOpening, 20, 20)
dilation_circle (RegionOpening, RegionDilation, 5)
difference (Region, RegionDilation, RegionDifference)
connection (RegionDifference, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, ['width','height'], 'and', [30,400], [300,1000])
mean_image (Image5, ImageMean2, 1, 150)
mean_image (ImageMean2, ImageMean3, 4, 11)
threshold (ImageMean3, Region2, 150, 255)
erosion_rectangle1 (Region2, RegionErosion, 11, 11)
dyn_threshold (ImageMean2, ImageMean3, RegionDynThresh1, 5, 'dark')
intersection (RegionDynThresh1, RegionErosion, RegionIntersection2)
dilation_rectangle1 (RegionIntersection2, RegionDilation1, 2, 15)
erosion_rectangle1 (RegionDilation1, Regionstrach2, 1, 20)
threshold (Image, Regions, 21, 255)
erosion_circle (Regions, RegionErosion, 5)
fill_up_shape (RegionErosion, RegionFillUp, 'area', 1, 3000)
reduce_domain (Image, RegionFillUp, ImageReduced)
derivate_gauss (ImageReduced, DerivGauss, 3, 'xx')
mean_image (DerivGauss, ImageMean, 1, 40)
threshold (ImageMean, Regions1, 0.7, 5)
connection (Regions1, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 250, 1500)
mean_image
通过均值平滑一个图像。
算子mean_image使用所有输入图像(Image)的灰度值执行线性平滑。
分水岭算法是根据分水岭的构成来考虑图像的分割, 它是—种基于拓扑理论的数学形态学的分割方法。 首先, 把一幅图像看作起伏的地形, 图像的每像素灰度值作为这个地形的高度, 极小值是盆地, 极大值为山脊
分水岭算法学习代码如下:
**预处理
read_image (Image, 'C:/Users//分水岭算法/1.bmp')
get_image_size (Image, Width, Height)
rgb1_to_gray (Image, GrayImage)
scale_image_max (GrayImage, ImageScaleMax)
threshold (ImageScaleMax, Region, 128, 255)
erosion_rectangle1 (Region, RegionErosion, 3, 7)
fill_up (RegionErosion, RegionFillUp)
dilation_rectangle1 (RegionFillUp, RegionDilation, 7, 5)
connection (RegionDilation, ConnectedRegions)
**分水岭算子
distance_transform (ConnectedRegions, DistanceImage, 'octagonal', 'true', Width, Height)
convert_image_type (DistanceImage, ImageConverted, 'byte')
invert_image (ImageConverted, ImageInvert)
scale_image_max (ImageInvert, ImageScaleMax1)
watersheds_threshold (ImageScaleMax1, Basins, 10)
dev_set_colored (12)
intersection (Basins, ConnectedRegions, RegionIntersection)
area_center (RegionIntersection, Area, Row, Column)
tuple_int (Row, Row)
tuple_int (Column, Column)
dev_display (Image)
dev_display (RegionIntersection)
for i:=0 to 25 by 1
disp_message (3600, '+', 'window', Row, Column, 'green', 'false')
endfor