Commit 1e32e070 authored by rhaase's avatar rhaase
Browse files

added function for pruning trees

parent 24c1644f
......@@ -665,6 +665,44 @@ public class SkeletonAnalyser {
return -1;
}
public static SkeletonAnalyser cutLeafEdgesShorterThan(SkeletonAnalyser skeletonAnalyser, double lengthContraint)
{
SkeletonAnalyser skeletonAnalyserCopy = new SkeletonAnalyser(skeletonAnalyser);
skeletonAnalyserCopy.removeUnneededJunctions();
boolean somethingDeleted = true;
while (somethingDeleted) {
somethingDeleted = false;
// FOR TRACING
//ImagePlus target = NewImage.createByteImage("temp", 100, 100, 1, NewImage.FILL_BLACK);
//PathDrawer.drawAllPathsToLargestJunction(skeletonAnalyserCopy, target, Color.green);
//target.show();
//new WaitForUserDialog("blub").show();
for (Vertex leaf : skeletonAnalyserCopy.getLeafs()) {
Edge edge = skeletonAnalyserCopy.getEdgesStartingAtJunction(leaf).get(0);
if (SkeletonAnalyser.getLengthOfEdge(edge) < lengthContraint)
{
try {
skeletonAnalyserCopy.removeLeaf(leaf);
}
catch(Exception e)
{
System.out.println("Error: " + e.toString());
return null;
}
somethingDeleted = true;
break;
}
}
skeletonAnalyserCopy.removeUnneededJunctions();
}
return skeletonAnalyserCopy;
}
/**
* This function is intended for testing only
* @return List of all Edges
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment