Commit 0701bbb9 authored by rhaase's avatar rhaase
Browse files

added test and example image for a skeleton containing a loop

parent f797de31
package de.mpicbg.scf.skeletonanalysis;
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.*;
import java.awt.*;
import java.util.ArrayList;
import static org.junit.Assert.assertTrue;
/**
* Author: Robert Haase, Scientific Computing Facility, MPI-CBG Dresden, rhaase@mpi-cbg.de
* Date: September 2016
*/
public class LoopTest {
SkeletonAnalyser skeletonAnalyser;
ImagePlus target;
@Before
public void initialize() {
ImageJ.main(new String[1]);
target = IJ.openImage(
AnalyzeSkeleton_.class.getResource(
"/loopExample.tif").getFile());
target.show();
AnalyzeSkeleton_ skel = new AnalyzeSkeleton_();
skel.setup("", target);
//skel.run( null );
SkeletonResult simpleSkeletonResult = skel.run(AnalyzeSkeleton_.NONE, false, false, target, false, false);
// = skel.assembleResults();
skeletonAnalyser = new SkeletonAnalyser(simpleSkeletonResult);
}
@Test
public void testIfLoopsInSkeletonsAreAnalysable()
{
Vertex soma = skeletonAnalyser.getLargestJunction();
// ---------------------------------
// get all leafs
ArrayList<Vertex> leafs = skeletonAnalyser.getLeafs();
System.out.println("number of leafs: "+leafs.size());
PathDrawer pathDrawer = new PathDrawer(target);
for (Edge edge : skeletonAnalyser.getAllEdges())
{
pathDrawer.drawEdge(edge, Color. green);
}
// ---------------------------------
// get shortest paths from leafs to
// soma and analyse their straightness
for (Vertex leaf :leafs)
{
ArrayList<Edge> path = skeletonAnalyser.getShortestPath(leaf, soma);
// measure from junction center to junction center
double pathLength = SkeletonAnalyser.getLengthAlongPath(path);
System.out.println("path length " + pathLength);
}
PathDrawer.drawAllPathsToLargestJunction(skeletonAnalyser, target, Color.red);
new WaitForUserDialog("huh").show();
}
}
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