Commit f1338f16 authored by lombardo's avatar lombardo
Browse files

update the pruning strategy (i.e. in cutLeafEdgesShorterThan()).

Test that slabs contains pixel in getDistanceBetweenStartingPointAndJunctionCenter()
parent f9660d29
......@@ -178,7 +178,12 @@ public class SkeletonAnalyser {
public double getDistanceBetweenStartingPointAndJunctionCenter(Edge edge)
{
Point a = getCenterOfJunction(edge.getV1());
Point b = edge.getSlabs().get(0);
Point b = null;
if ( edge.getSlabs().size()>0 )
b = edge.getSlabs().get(0);
else
b = getCenterOfJunction(edge.getV2());
return getPointDistance(a, b);
}
......@@ -703,8 +708,8 @@ public class SkeletonAnalyser {
for (Vertex leaf : leafs) {
ArrayList<Edge> leafEdges = getEdgesStartingAtJunction(leaf);
if (leafEdges != null && leafEdges.size() > 0) {
Edge edge = leafEdges.get(0);
if (getLengthOfEdge(edge) < lengthConstraint) {
Edge edge = flipEdge( leafEdges.get(0) );
if (( getLengthOfEdge(edge) - getDistanceBetweenStartingPointAndJunctionCenter(edge)) < lengthConstraint) {
try {
removeLeaf(leaf);
} catch (Exception e) {
......
......@@ -5,13 +5,16 @@ 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.*;
import java.util.ArrayList;
import static junit.framework.TestCase.assertTrue;
......@@ -42,19 +45,26 @@ public class PruningTest {
@Test
public void testSimplePruning()
{
PathDrawer.drawAllPathsToLargestJunction(skeletonAnalyser, target, Color.green);
System.out.println("Minimum Edge length: " + getMinimumEdgeLength(skeletonAnalyser));
//PathDrawer.drawAllPathsToLargestJunction(skeletonAnalyser, target, Color.green);
//System.out.println("Minimum Edge length: " + getMinimumEdgeLength(skeletonAnalyser));
double minimumLengthConstraint = 5;
SkeletonAnalyser skeletonAnalyser2 = new SkeletonAnalyser(skeletonAnalyser);
skeletonAnalyser2.cutLeafEdgesShorterThan(minimumLengthConstraint);
PathDrawer.drawAllPathsToLargestJunction(skeletonAnalyser2, target, Color.red);
double newMinmumLength = getMinimumEdgeLength(skeletonAnalyser2);
System.out.println("Minimum Edge length: " + newMinmumLength);
assertTrue(newMinmumLength <= minimumLengthConstraint);
ArrayList<Edge> removedEdges = skeletonAnalyser2.cutLeafEdgesShorterThan(minimumLengthConstraint);
boolean removedEgesAreShort = true;
for (Edge edge : removedEdges )
{
double length = skeletonAnalyser.getLengthOfEdge(edge) - skeletonAnalyser.getDistanceBetweenStartingPointAndJunctionCenter(edge);
if ( length >= minimumLengthConstraint )
removedEgesAreShort = false;
}
//PathDrawer.drawAllPathsToLargestJunction(skeletonAnalyser2, target, Color.red);
//double newMinmumLength = getMinimumEdgeLength(skeletonAnalyser2);
//System.out.println("Minimum Edge length: " + newMinmumLength);
assertTrue(removedEgesAreShort);
//new WaitForUserDialog("Holla die Waldfee").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