形态学
1. 腐蚀和膨胀
1.1 定义
腐蚀的作用是消除物体边界点,膨胀是把图像周围的北京店合并到物体中。
对于二值图像来说:
- 膨胀:增加元素
- 腐蚀:减少元素
- 闭运算:先膨胀后腐蚀
- 开运算:先腐蚀后膨胀
- 减少或断开像素:用腐蚀或开运算
- 增加或连接像素:用膨胀或闭运算
1.2 算子
腐蚀
erosion1(Region, StructElement : RegionErosion : Iterations : )
Erode a region.
erosion2(Region, StructElement : RegionErosion : Row, Column, Iterations : )
Erode a region (using a reference point). 用参考点
erosion_circle(Region : RegionErosion : Radius : )
Erode a region with a circular structuring element.
erosion_rectangle1(Region : RegionErosion : Width, Height : )
Erode a region with a rectangular structuring element.
膨胀
dilation1(Region, StructElement : RegionDilation : Iterations : )
Dilate a region.
dilation2(Region, StructElement : RegionDilation : Row, Column, Iterations : )
Dilate a region (using a reference point).
dilation_circle(Region : RegionDilation : Radius : )
Dilate a region with a circular structuring element.
dilation_rectangle1(Region : RegionDilation : Width, Height : )
Dilate a region with a rectangular structuring element.
2. 开运算和闭运算
opening(Region, StructElement : RegionOpening : : )
opening_circle(Region : RegionOpening : Radius : )
opening_rectangle1(Region : RegionOpening : Width, Height : )
closing(Region, StructElement : RegionClosing : : )
closing_circle(Region : RegionClosing : Radius : )
closing_rectangle1(Region : RegionClosing : Width, Height : )
3. 骨架
骨架是指图像中央的骨骼部分,是描述图像几何拓扑性质的重要特征。
3.1 junctions_skeleton / split_skeleton_lines
junctions_skeleton(Region : EndPoints, JuncPoints : : )
Find junctions and end points in a skeleton. 连接点和终点
split_skeleton_lines(SkeletonRegion : : MaxDistance : BeginRow, BeginCol, EndRow, EndCol)
Split lines represented by one pixel wide, non-branching lines.
read_image (Image, 'clip')
threshold (Image, Region, 0, 80)
connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'rect2_len1', 'and', 67.4, 128.66)
*计算骨骼
skeleton (SelectedRegions, Skeleton)
*计算骨骼的端点和关节点
junctions_skeleton (Skeleton, EndPoints, JuncPoints)
*从骨骼中去除关节点,把骨骼分割成单像素宽度、无分支区域
difference (Skeleton, JuncPoints, RegionDifference)
connection (RegionDifference, ConnectedRegions1)
select_shape (ConnectedRegions1, SelectedRegions1, 'area', 'and', 10, 99999)
*把区域分割成直线段区域,输出近似直线的起点和终点坐标
split_skeleton_lines (SelectedRegions1, 5, BeginRow, BeginCol, EndRow, EndCol)
dev_display (Image)
dev_set_colored (6)
split_skeleton_region (SelectedRegions1, RegionLines, 3)
3.2 split_skeleton_region
split_skeleton_region(SkeletonRegion : RegionLines : MaxDistance : )
Split lines represented by one pixel wide, non-branching regions.
功能:把骨骼分割为多条宽度为一个像素、无分支的直线
read_image(Image,'clip')
threshold (Image, Region, 0, 80)
connection (Region, ConnectedRegions)
skeleton (ConnectedRegions, Skeleton)
junctions_skeleton (Skeleton, EndPoints, JuncPoints)
difference (Skeleton, JuncPoints, RegionDifference)
connection (RegionDifference, ConnectedRegions1)
select_shape (ConnectedRegions1, SelectedRegions, 'area', 'and', 10, 99999)
split_skeleton_lines (SelectedRegions, 3, BeginRow, BeginCol, EndRow, EndCol)
dev_display (Image)
dev_set_colored (6)
split_skeleton_region (SelectedRegions, RegionLines, 3)
3.3 gen_contours_skeleton_xld
gen_contours_skeleton_xld(Skeleton : Contours : Length, Mode : )
Convert a skeleton into XLD contours.