Zhang-Suen thinning steps:
- While points are deleted do
- For all pixels p(i,j) do
- if (a) 2 ≤ B(P1) ≤ 6
(b) A(P1) = 1
(c) Apply one of the following:
1. P2 x P4 x P6 = 0 in odd iterations
2. P2 x P4 x P8 = 0 in even iterations
(d) Apply one of the following:
1. P4 x P6 x P8 = 0 in odd iterations
2. P2 x P6 x P8 = 0 in even iterations
then
- Delete pixel p(i,j)
- end if
- end for
- end while
Where A(P1) is the number of 0 to 1 transitions in a clockwise direction from P9 back to itself, and B(P1) is the number of non-zero neighbors of P1.
我在国外上面的链接上找到了这个算法的opencv编程实现,效率很高。源代码和用法见文件内(thin.cpp):
http://pan.baidu.com/s/1yFzUe。