Commit 5ea89fa8 authored by rhaase's avatar rhaase
Browse files

added tests for pruning

parent 1e32e070
package de.mpicbg.scf.skeletonanalysis;
import de.mpicbg.scf.skeletonanalysis.SkeletonAnalyser;
import ij.IJ;
import ij.ImageJ;
import ij.ImagePlus;
import ij.gui.WaitForUserDialog;
import org.junit.Before;
import org.junit.Test;
import sc.fiji.analyzeSkeleton.AnalyzeSkeleton_;
import sc.fiji.analyzeSkeleton.SkeletonResult;
import sc.fiji.analyzeSkeleton.Edge;
import java.awt.*;
* Author: Robert Haase, Scientific Computing Facility, MPI-CBG Dresden,
* Date: September 2016
public class PruningTest {
SkeletonAnalyser skeletonAnalyser;
ImagePlus target;
public void initialize()
ImageJ.main( new String[1] );
target = IJ.openImage(
"/manyShortEdgesExample.tif" ).getFile() );;
AnalyzeSkeleton_ skel = new AnalyzeSkeleton_();
skel.setup("", target);
// null );
SkeletonResult simpleSkeletonResult =, false, false, target, false, false);
// = skel.assembleResults();
skeletonAnalyser = new SkeletonAnalyser(simpleSkeletonResult);
public void testSimplePruning()
PathDrawer.drawAllPathsToLargestJunction(skeletonAnalyser, target,;
System.out.println("Minimum Edge length: " + getMinimumEdgeLength(skeletonAnalyser));
  • @lombardo this is how you can remove edges starting at a leaf which are shorter than a given threshold

Please register or sign in to reply
SkeletonAnalyser skeletonAnalyser2 = SkeletonAnalyser.cutLeafEdgesShorterThan(skeletonAnalyser, 5);
Please register or sign in to reply
PathDrawer.drawAllPathsToLargestJunction(skeletonAnalyser2, target,;
System.out.println("Minimum Edge length: " + getMinimumEdgeLength(skeletonAnalyser2));
new WaitForUserDialog("Holla die Waldfee").show();
private double getMinimumEdgeLength(SkeletonAnalyser skeletonAnalyser)
// determine shortest Edge
double minmumLength = Double.POSITIVE_INFINITY;
for (Edge edge : skeletonAnalyser.getAllEdges())
double length = SkeletonAnalyser.getLengthOfEdge(edge);
if (length < minmumLength)
minmumLength = length;
return minmumLength;
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