a skeleton extraction algorithm