11package net .imagej .ops .segment .hough ;
22
33import net .imglib2 .RealLocalizable ;
4- import net .imglib2 .RealPoint ;
5- import net .imglib2 .roi .util .Contains ;
4+ import net .imglib2 .roi .geom .real .AbstractSphere ;
65
76/**
87 * Representation of a circle segmented via Hough circle transformation.
1312 * can be used to sort a list of circles.
1413 *
1514 * @author Jean-Yves Tinevez.
15+ * @author Gabe Selzer.
1616 *
1717 */
18- public class HoughCircle extends RealPoint implements Comparable < HoughCircle >, Contains < RealLocalizable >
18+ public class HoughCircle extends AbstractSphere implements Comparable < HoughCircle >
1919{
2020
21- private final double radius ;
22-
2321 private final double sensitivity ;
2422
2523 public HoughCircle ( final RealLocalizable pos , final double radius , final double sensitivity )
2624 {
27- super ( pos );
25+ super ( getCenter ( pos ) , radius );
2826 this .radius = radius ;
2927 this .sensitivity = sensitivity ;
3028 }
29+
30+ private static double [] getCenter (RealLocalizable l ) {
31+ double [] center = new double [l .numDimensions ()];
32+ l .localize (center );
33+ return center ;
34+ }
3135
3236 @ Override
3337 public String toString ()
@@ -37,7 +41,7 @@ public String toString()
3741 for ( int i = 0 ; i < numDimensions (); i ++ )
3842 {
3943 sb .append ( c );
40- sb .append ( String .format ( "%.1f" , position [ i ] ) );
44+ sb .append ( String .format ( "%.1f" , center [ i ] ) );
4145 c = ',' ;
4246 }
4347 sb .append ( ")" );
@@ -61,10 +65,10 @@ public int compareTo( final HoughCircle o )
6165 }
6266
6367 @ Override
64- public boolean contains ( final RealLocalizable point )
68+ public boolean test ( final RealLocalizable point )
6569 {
66- final double dx = getDoublePosition ( 0 ) - point .getDoublePosition ( 0 );
67- final double dy = getDoublePosition ( 1 ) - point .getDoublePosition ( 1 );
70+ final double dx = center [ 0 ] - point .getDoublePosition ( 0 );
71+ final double dy = center [ 1 ] - point .getDoublePosition ( 1 );
6872 final double dr2 = dx * dx + dy * dy ;
6973
7074 if ( dr2 < radius * radius )
@@ -73,9 +77,4 @@ public boolean contains( final RealLocalizable point )
7377 return true ;
7478 }
7579
76- @ Override
77- public HoughCircle copyContains ()
78- {
79- return new HoughCircle ( this , radius , sensitivity );
80- }
8180}
0 commit comments