Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tpietzsch committed Apr 22, 2024
1 parent eedbeee commit 8e3be12
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
26 changes: 24 additions & 2 deletions src/main/java/net/imglib2/algorithm/hough/HoughTransforms.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.algorithm.localextrema.LocalExtrema;
import net.imglib2.algorithm.localextrema.LocalExtrema.MaximumCheck;
import net.imglib2.type.Type;
import net.imglib2.type.numeric.IntegerType;
import net.imglib2.type.numeric.RealType;
import net.imglib2.util.Intervals;
Expand Down Expand Up @@ -233,7 +234,28 @@ public static < T extends Comparable< T >, U extends IntegerType< U > > void vot
final RandomAccessibleInterval< U > votespace,
final int nTheta )
{
voteLines( input, votespace, nTheta, defaultRho( input ), Util.getTypeFromInterval( input ) );
voteLines( input, votespace, nTheta, defaultRho( input ), getTypeFromInterval( input ) );
}

private static <T> T getTypeFromInterval( RandomAccessibleInterval< T > rai )
{
// final T val1 = rai.randomAccess().get();
// final T val2 = ( T ) ( ( Type ) rai.getType() ).createVariable();
// System.out.println( "val1 = " + val1 );
// System.out.println( "val2 = " + val2 );

// TODO: The voteLines() method above used Util.getTypeFromInterval to
// obtain a threshold value to call the voteLines() method below
// which has a threshold argument. With the recent addition of
// RandomAccessibleInterval.getType(), this breaks the tests/
// However, it seems that it is a bug in the above voteLines() to
// do it like this. Basically, it uses the value of the first
// pixel of the image as the threshold, which looks wrong, and
// depends on assumptions about how Util.getTypeFromInterval is
// implemented. I now just "fixed" the test by just taking the
// first pixel. But this is clearly wrong. I don't know how the
// code is supposed to work though.
return rai.randomAccess().get();
}

/**
Expand All @@ -257,7 +279,7 @@ public static < T extends Comparable< T >, U extends IntegerType< U > > void vot
final int nTheta,
final int nRho )
{
voteLines( input, votespace, nTheta, nRho, Util.getTypeFromInterval( input ) );
voteLines( input, votespace, nTheta, nRho, getTypeFromInterval( input ) );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ public BSplineCoefficientsInterpolator<S> create( RandomAccessible<T> f )
coefficients,
((OutOfBoundsFactory<S,RandomAccessibleInterval<S>>)oobFactory));

S type = Util.getTypeFromInterval( coefficients );
S type = coefficients.getType();
if( order % 2 == 0 )
return new BSplineCoefficientsInterpolatorEven<S>( order, coefExt, type.copy() );
return new BSplineCoefficientsInterpolatorEven<S>( order, coefExt, type.createVariable() );
else
return new BSplineCoefficientsInterpolatorOdd<S>( order, coefExt, type.copy() );
return new BSplineCoefficientsInterpolatorOdd<S>( order, coefExt, type.createVariable() );
}

@Override
Expand Down

0 comments on commit 8e3be12

Please sign in to comment.