1. Contour Tracing Algorithms
- Square Tracing Algorithm
- Moore-Neighbor Tracing
- Radial Sweep
- Theo Pavlidis’ Algorithm
2. Square Tracing Algorithm
- 扫描得到起始点
- 当前为黑色点,左转
- 当前点位白色点,右转
循环直到回到起始点
1
2
3
4
5
6
7
8
9
10
11
12
13
14注意:左转和右转是针对当前循环的位置
-------------
| | 1 | |
-------------
| 2 | x | 0 |
-------------
| | 3 | |
-------------
如果当前点位置为x,前向点位置为0时:
left = 3; right = 1
如果当前点位置为x,前向点位置为3时:
left = 2; right = 0无法追踪斜线,改进:终止条件改为访问起始点多次
- 通过4邻域而非8领域追踪边界
3. Moore-Neighbor Tracing
摩尔邻域
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17-------------
| 3 | 2 | 1 |
-------------
| 4 | x | 0 |
-------------
| 5 | 6 | 7 |
-------------
cur_id pre_id pre_id_next_loop
0 7 5
1 0 7
2 1 7
3 2 1
4 3 1
5 4 3
6 5 3
7 6 5顺时针扫描当前边界点,直到遇到黑色像素
- 退回白色像素,重复扫描操作
1 | vector<vtkSmartPointer<vtkPoints>> ContourTracing::GetContours() |