code for skeleton extraction and Pin tracing