1 | initial version |
Hint: the endpoints have only one neighbor, the points on the skeleton have two neighbors and the junction points have more than two neighbors (by neighbor I mean active point).
You can track the branches from the endpoints to the nearest junction, and count its length. If it's shorter than a given distance, just delete it.