Skip to content

Commit 0a9dbf3

Browse files
committed
fix tests
1 parent 37e4b24 commit 0a9dbf3

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

src/main/java/net/imglib2/algorithm/hough/HoughTransforms.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import net.imglib2.RandomAccessibleInterval;
4545
import net.imglib2.algorithm.localextrema.LocalExtrema;
4646
import net.imglib2.algorithm.localextrema.LocalExtrema.MaximumCheck;
47+
import net.imglib2.type.Type;
4748
import net.imglib2.type.numeric.IntegerType;
4849
import net.imglib2.type.numeric.RealType;
4950
import net.imglib2.util.Intervals;
@@ -233,7 +234,28 @@ public static < T extends Comparable< T >, U extends IntegerType< U > > void vot
233234
final RandomAccessibleInterval< U > votespace,
234235
final int nTheta )
235236
{
236-
voteLines( input, votespace, nTheta, defaultRho( input ), Util.getTypeFromInterval( input ) );
237+
voteLines( input, votespace, nTheta, defaultRho( input ), getTypeFromInterval( input ) );
238+
}
239+
240+
private static <T> T getTypeFromInterval( RandomAccessibleInterval< T > rai )
241+
{
242+
// final T val1 = rai.randomAccess().get();
243+
// final T val2 = ( T ) ( ( Type ) rai.getType() ).createVariable();
244+
// System.out.println( "val1 = " + val1 );
245+
// System.out.println( "val2 = " + val2 );
246+
247+
// TODO: The voteLines() method above used Util.getTypeFromInterval to
248+
// obtain a threshold value to call the voteLines() method below
249+
// which has a threshold argument. With the recent addition of
250+
// RandomAccessibleInterval.getType(), this breaks the tests/
251+
// However, it seems that it is a bug in the above voteLines() to
252+
// do it like this. Basically, it uses the value of the first
253+
// pixel of the image as the threshold, which looks wrong, and
254+
// depends on assumptions about how Util.getTypeFromInterval is
255+
// implemented. I now just "fixed" the test by just taking the
256+
// first pixel. But this is clearly wrong. I don't know how the
257+
// code is supposed to work though.
258+
return rai.randomAccess().get();
237259
}
238260

239261
/**
@@ -257,7 +279,7 @@ public static < T extends Comparable< T >, U extends IntegerType< U > > void vot
257279
final int nTheta,
258280
final int nRho )
259281
{
260-
voteLines( input, votespace, nTheta, nRho, Util.getTypeFromInterval( input ) );
282+
voteLines( input, votespace, nTheta, nRho, getTypeFromInterval( input ) );
261283
}
262284

263285
/**

src/main/java/net/imglib2/algorithm/interpolation/randomaccess/BSplineCoefficientsInterpolatorFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@ public BSplineCoefficientsInterpolator<S> create( RandomAccessible<T> f )
193193
coefficients,
194194
((OutOfBoundsFactory<S,RandomAccessibleInterval<S>>)oobFactory));
195195

196-
S type = Util.getTypeFromInterval( coefficients );
196+
S type = coefficients.getType();
197197
if( order % 2 == 0 )
198-
return new BSplineCoefficientsInterpolatorEven<S>( order, coefExt, type.copy() );
198+
return new BSplineCoefficientsInterpolatorEven<S>( order, coefExt, type.createVariable() );
199199
else
200-
return new BSplineCoefficientsInterpolatorOdd<S>( order, coefExt, type.copy() );
200+
return new BSplineCoefficientsInterpolatorOdd<S>( order, coefExt, type.createVariable() );
201201
}
202202

203203
@Override

0 commit comments

Comments
 (0)