@@ -50,6 +50,13 @@ public class Detection {
5050 public final int nodeIndex ;
5151 /** Distance from the path skeleton at the detection point (physical units) */
5252 public final double distanceFromSkeleton ;
53+ /**
54+ * Label value from a segmentation/label image associated with this
55+ * detection, or {@code -1} if not applicable. Set by
56+ * {@link LabelProximityDetector} to identify which label surface
57+ * produced the contact.
58+ */
59+ public final int labelValue ;
5360
5461 /**
5562 * Creates a new detection.
@@ -65,13 +72,33 @@ public class Detection {
6572 public Detection (final double x , final double y , final double z ,
6673 final double intensity , final Path path , final int nodeIndex ,
6774 final double distanceFromSkeleton ) {
75+ this (x , y , z , intensity , path , nodeIndex , distanceFromSkeleton , -1 );
76+ }
77+
78+ /**
79+ * Creates a new detection with an associated label value.
80+ *
81+ * @param x X-coordinate in real-world units
82+ * @param y Y-coordinate in real-world units
83+ * @param z Z-coordinate in real-world units
84+ * @param intensity intensity at the detection site
85+ * @param path associated path
86+ * @param nodeIndex index of the nearest node on the path
87+ * @param distanceFromSkeleton distance from the skeleton (physical units)
88+ * @param labelValue label-image value associated with this
89+ * detection, or {@code -1} if not applicable
90+ */
91+ public Detection (final double x , final double y , final double z ,
92+ final double intensity , final Path path , final int nodeIndex ,
93+ final double distanceFromSkeleton , final int labelValue ) {
6894 this .x = x ;
6995 this .y = y ;
7096 this .z = z ;
7197 this .intensity = intensity ;
7298 this .path = path ;
7399 this .nodeIndex = nodeIndex ;
74100 this .distanceFromSkeleton = distanceFromSkeleton ;
101+ this .labelValue = labelValue ;
75102 }
76103
77104 /**
@@ -105,9 +132,12 @@ public double[] xyzct() {
105132
106133 @ Override
107134 public String toString () {
108- return String .format (
109- "Detection[x=%.3f,y=%.3f,z=%.3f; I=%.1f; dist=%.3f; path=%s; node=%d] " ,
135+ final String base = String .format (
136+ "Detection[x=%.3f,y=%.3f,z=%.3f; I=%.1f; dist=%.3f; path=%s; node=%d" ,
110137 x , y , z , intensity , distanceFromSkeleton ,
111138 path != null ? path .getName () : "null" , nodeIndex );
139+ return (labelValue >= 0 )
140+ ? base + "; label=" + labelValue + "]"
141+ : base + "]" ;
112142 }
113143}
0 commit comments