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, rhaase@mpi-cbg.de
* Date: September 2016
*/
public class PruningTest {
SkeletonAnalyser skeletonAnalyser;
ImagePlus target;
@Before
public void initialize()
{
ImageJ.main( new String[1] );
target = IJ.openImage(
AnalyzeSkeleton_.class.getResource(
"/manyShortEdgesExample.tif" ).getFile() );
target.show();
AnalyzeSkeleton_ skel = new AnalyzeSkeleton_();
skel.setup("", target);
//skel.run( null );
SkeletonResult simpleSkeletonResult = skel.run(AnalyzeSkeleton_.SHORTEST_BRANCH, false, false, target, false, false);
// = skel.assembleResults();
skeletonAnalyser = new SkeletonAnalyser(simpleSkeletonResult);
}
@Test
public void testSimplePruning()
{
PathDrawer.drawAllPathsToLargestJunction(skeletonAnalyser, target, Color.green);
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, Color.red);
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