Commit f38c31ec authored by rhaase's avatar rhaase
Browse files

changed interface so that distance measurements in physical units are possible

parent 915107a6
......@@ -10,7 +10,7 @@
</parent>
<artifactId>SkeletonAnalysis_</artifactId>
<version>1.0.1</version>
<version>1.1.0</version>
<name>plugins/SkeletonAnalysis_.jar</name>
<description />
......
......@@ -14,6 +14,8 @@ public class SkeletonAnalyser {
private ArrayList<Vertex> allVertices = null;
private ArrayList<Edge> allEdges = null;
double[] voxelSize = {1, 1, 1};
/**
* Create an instance holding all edges and vertices from a list of Graph objects
* @param graphs Array of Graphs
......@@ -51,6 +53,22 @@ public class SkeletonAnalyser {
this.allEdges.addAll(skeletonAnalyser.allEdges);
this.allVertices = new ArrayList<Vertex>();
this.allVertices.addAll(skeletonAnalyser.allVertices);
for (int i = 0; i < voxelSize.length; i++) {
this.voxelSize[i] = skeletonAnalyser.voxelSize[i];
}
}
/**
* Adapt voxel size for distance measurements. Per default this is {1,1,1}
*
* @param voxelSize array with three elements (x,y and z compartement)
*/
public void setVoxelSize(double[] voxelSize)
{
for (int i = 0; i < voxelSize.length && i < this.voxelSize.length; i++)
{
this.voxelSize[i] = voxelSize[i];
}
}
......@@ -142,7 +160,7 @@ public class SkeletonAnalyser {
* @param edge Edge to be measured
* @return length in pixels/voxels
*/
public static double getLengthOfEdge(Edge edge) {
public double getLengthOfEdge(Edge edge) {
ArrayList<Point> polygon = new ArrayList<Point>();
polygon.add(getCenterOfJunction(edge.getV1()));
......@@ -157,7 +175,7 @@ public class SkeletonAnalyser {
* @param edge Edge to be measured
* @return length in pixels/voxels
*/
public static double getDistanceBetweenStartingPointAndJunctionCenter(Edge edge)
public double getDistanceBetweenStartingPointAndJunctionCenter(Edge edge)
{
Point a = getCenterOfJunction(edge.getV1());
Point b = edge.getSlabs().get(0);
......@@ -169,7 +187,7 @@ public class SkeletonAnalyser {
* @param path Path to be analysed
* @return value larger than 0 and smaller or equal than 1
*/
public static double getStraightness(ArrayList<Edge> path)
public double getStraightness(ArrayList<Edge> path)
{
double length = 0;
for (Edge edge : path)
......@@ -191,7 +209,7 @@ public class SkeletonAnalyser {
* @param points points of the given polyline to measure
* @return length in pixels/voxels
*/
public static double getLengthAlongPolyline(ArrayList<Point> points) {
public double getLengthAlongPolyline(ArrayList<Point> points) {
double length = 0;
Point point = null;
for (Point otherPoint : points)
......@@ -212,11 +230,11 @@ public class SkeletonAnalyser {
* @param b second of the given polyline to measure
* @return length in pixels/voxels
*/
public static double getPointDistance(Point a, Point b) {
public double getPointDistance(Point a, Point b) {
return Math.sqrt(
Math.pow(a.x - b.x, 2) +
Math.pow(a.y - b.y, 2) +
Math.pow(a.z - b.z, 2)
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]
);
}
......@@ -296,7 +314,7 @@ public class SkeletonAnalyser {
* @param path Path to be measured
* @return length in pixels/voxels
*/
public static double getLengthAlongPath(ArrayList<Edge> path)
public double getLengthAlongPath(ArrayList<Edge> path)
{
return getLengthAlongPolyline(getPointsAlongPath(path));
}
......@@ -665,9 +683,9 @@ public class SkeletonAnalyser {
return -1;
}
public static SkeletonAnalyser cutLeafEdgesShorterThan(SkeletonAnalyser skeletonAnalyser, double lengthContraint)
public SkeletonAnalyser cutLeafEdgesShorterThan(double lengthConstraint)
{
SkeletonAnalyser skeletonAnalyserCopy = new SkeletonAnalyser(skeletonAnalyser);
SkeletonAnalyser skeletonAnalyserCopy = new SkeletonAnalyser(this);
skeletonAnalyserCopy.removeUnneededJunctions();
ArrayList<Vertex> leafs = skeletonAnalyserCopy.getLeafs();
......@@ -686,7 +704,7 @@ public class SkeletonAnalyser {
ArrayList<Edge> leafEdges = skeletonAnalyserCopy.getEdgesStartingAtJunction(leaf);
if (leafEdges != null && leafEdges.size() > 0) {
Edge edge = leafEdges.get(0);
if (SkeletonAnalyser.getLengthOfEdge(edge) < lengthContraint) {
if (skeletonAnalyserCopy.getLengthOfEdge(edge) < lengthConstraint) {
try {
skeletonAnalyserCopy.removeLeaf(leaf);
} catch (Exception e) {
......
  • @lombardo with this commit, the interface changes as follows: All static functions, which have something todo with length measurements, are no longer static. You need an instance of a SkeletonAnalyser which holds the information about the voxel size. Per default it is {1,1,1}

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