Commit e4af02a0 authored by lombardo's avatar lombardo
Browse files

Correct issue in getPointDistance() and add corresponding test

parent f1338f16
......@@ -237,9 +237,9 @@ public class SkeletonAnalyser {
*/
public double getPointDistance(Point a, Point b) {
return Math.sqrt(
Math.pow(a.x - b.x, 2) * voxelSize[0] +
Math.pow(a.y - b.y, 2) * voxelSize[1] +
Math.pow(a.z - b.z, 2) * voxelSize[2]
Math.pow( (a.x - b.x) * voxelSize[0], 2) +
Math.pow( (a.y - b.y) * voxelSize[1], 2) +
Math.pow( (a.z - b.z) * voxelSize[2], 2)
);
}
......
......@@ -5,8 +5,10 @@ import ij.ImageJ;
import ij.ImagePlus;
import ij.gui.Overlay;
import ij.gui.PointRoi;
import org.junit.Before;
import org.junit.Test;
import sc.fiji.analyzeSkeleton.*;
import java.util.ArrayList;
......@@ -277,4 +279,28 @@ public class SkeletonAnalyserTest {
assertTrue(SkeletonAnalyser.junctionsEqual(vCenter, soma));
}
@Test
public void testIfVoxelSizeWork()
{
ArrayList<Edge> edges = skeletonAnalyser.getAllEdges();
double[] size1 = new double[] {1,1,1};
double[] size2 = new double[] {0.1,0.1,0.1};
for(Edge edge : edges )
{
skeletonAnalyser.setVoxelSize(size1);
double length1 = skeletonAnalyser.getLengthOfEdge(edge);
skeletonAnalyser.setVoxelSize(size2);
double length2 = skeletonAnalyser.getLengthOfEdge(edge);
System.out.println( "length1 : " + length1 + " ; length2 : " + length2 );
assertTrue(Math.abs( length1-10*length2 ) < 0.5 );
}
skeletonAnalyser.setVoxelSize(size1);
}
}
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