Pruning on skeleton image in Julia

I’ve a thinned image from Images.jl thinning(). I’m trying to prune the small branches, I’m not sure how.
I’ve used harris point detector to get the points on branch ends and on branch-outs. How should the spurs be removed?

This seems like a job for Graphs.jl, but I don’t know that package very well. There’s also GitHub - seung-lab/RealNeuralNetworks.jl: A unified framework for skeletonization, morphological analysis, and connectivity analysis. which may have routines for handling skeletons.

From the thinned image, you could try to classify the junctions based on the number of 8-connected neighbors. Then figure out the length of each branch by computing the distance of the end points to the junction pixels.