Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of getType() API #100

Merged
merged 5 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ Jean-Yves Tinevez and Michael Zinsmaier.</license.copyrightOwners>
<!-- NB: Deploy releases to the SciJava Maven repository. -->
<releaseProfiles>sign,deploy-to-scijava</releaseProfiles>

<net.imglib2.imglib2.version>6.4.0</net.imglib2.imglib2.version>
<imglib2.version>7.0.1</imglib2.version>
<imglib2-realtransform.version>4.0.3</imglib2-realtransform.version>
<imglib2-roi.version>0.15.0</imglib2-roi.version>
<imglib2-cache.version>1.0.0-beta-18</imglib2-cache.version>
</properties>

<repositories>
Expand All @@ -226,6 +229,10 @@ Jean-Yves Tinevez and Michael Zinsmaier.</license.copyrightOwners>
<groupId>net.imglib2</groupId>
<artifactId>imglib2-realtransform</artifactId>
</dependency>
<dependency>
<groupId>net.imglib2</groupId>
<artifactId>imglib2-cache</artifactId>
</dependency>

<!-- Third-party dependencies -->
<dependency>
Expand All @@ -240,10 +247,6 @@ Jean-Yves Tinevez and Michael Zinsmaier.</license.copyrightOwners>
<groupId>org.ojalgo</groupId>
<artifactId>ojalgo</artifactId>
</dependency>
<dependency>
<groupId>net.imglib2</groupId>
<artifactId>imglib2-cache</artifactId>
</dependency>

<!-- Test dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ public A update( final Object updater )
@Override public Cursor< T > localizingCursor() {throw new UnsupportedOperationException();}
@Override public Object iterationOrder() {throw new UnsupportedOperationException();}
@Override public RandomAccess< T > randomAccess() {throw new UnsupportedOperationException();}
@Override public ImgFactory< T > factory() {throw new UnsupportedOperationException();}@Override public Img< T > copy() {throw new UnsupportedOperationException();}
@Override public ImgFactory< T > factory() {throw new UnsupportedOperationException();}
@Override public Img< T > copy() {throw new UnsupportedOperationException();}
@Override public T getType() {throw new UnsupportedOperationException();}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ public T get()
return kernel.get();
}

@Override
public T getType()
{
return kernel.type();
}

@Override
public BSplineCoefficientsInterpolatorEven<T> copy()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ public T get()
{
return kernel.get();
}


@Override
public T getType()
{
return kernel.type();
}

@Override
public BSplineCoefficientsInterpolatorOdd<T> copy()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ public T get()
return randomAccess.get();
}

@Override
public T getType()
{
return processLine.getType();
}

@Override
public SamplingLineIterator< T > copy()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ public AbstractConvertedRandomAccess< T, T > randomAccess( final Interval interv
return randomAccess();
}

@Override
public T getType()
{
return source.getType();
}

public static class ScaledRandomAccess< T extends Type< T > & MulFloatingPoint > extends AbstractConvertedRandomAccess< T, T >
{

Expand All @@ -99,6 +105,12 @@ public T get()
return t;
}

@Override
public T getType()
{
return t;
}

@Override
public ScaledRandomAccess< T > copy()
{
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ public T get()
return value;
}

@Override
public T getType()
{
return value;
}

protected void fillWeights()
{
final Neighborhood< T > rect = target.get();
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/net/imglib2/algorithm/kdtree/VolumetricSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ public VolumetricSearch( final List< I > intervals )
final ArrayList< IntervalWrapper< I > > wrappers = new ArrayList< IntervalWrapper< I > >( intervals.size() );
for ( final I interval : intervals )
wrappers.add( new IntervalWrapper< I >( interval ) );
kdtree = new KDTree< IntervalWrapper< I > >( wrappers, wrappers );
kdtree = new KDTree<>( wrappers, wrappers );
}

@Override
public List< I > getType()
{
return new LinkedList<>();
}

private static class IntervalWrapper< I extends RealInterval > implements RealLocalizable
Expand Down Expand Up @@ -227,6 +233,12 @@ public List< I > get()
return find( this );
}

@Override
public List< I > getType()
{
return new LinkedList<>();
}

@Override
public VolumetricSearchRandomAccess copy()
{
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/net/imglib2/algorithm/math/Compute.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ public < O extends RealType< O >, C extends RealType< C > > RandomAccessibleInte
{
if ( null == inConverter )
inConverter = Util.genericRealTypeConverter();
final O outputType = target.randomAccess().get().createVariable();

final O outputType = target.randomAccess().get().createVariable();
final boolean are_same_type = computingType.getClass() == outputType.getClass();

if ( null == outConverter && !are_same_type )
Expand Down Expand Up @@ -372,6 +372,12 @@ public RandomAccess< O > randomAccess( final Interval interval )
{
return this.randomAccess();
}

@Override
public O getType()
{
return outputType;
}
}, interval );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ public FunctionCursor(
this.scrapO = outputType.createVariable();
this.reset();
}


@Override
public O getType()
{
return scrapO;
}

private final class FunctionSamplerConverter implements Sampler< O >
{
@Override
Expand All @@ -110,6 +116,12 @@ public final O get()

@Override
public final Sampler< O > copy() { return null; }

@Override
public O getType()
{
return scrapO;
}
}

private final class FunctionSamplerDirect implements Sampler< C >
Expand All @@ -122,6 +134,12 @@ public final C get()

@Override
public final Sampler< C > copy() { return null; }

@Override
public C getType()
{
return scrapC;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ public O get()
this.outConverter.convert( this.f.eval( this.point ), outputType );
return this.outputType;
}

@Override
public O getType()
{
return outputType;
}
}

private final class FunctionSamplerDirect implements Sampler< O >
Expand Down Expand Up @@ -171,6 +177,12 @@ public final O get()
{
return this.f.eval( this.point );
}

@Override
public O getType()
{
return outputType;
}
}

@Override
Expand All @@ -179,6 +191,12 @@ public O get()
return this.sampler.get();
}

@Override
public O getType()
{
return outputType;
}

@Override
public RandomAccess< O > copy()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ public final O get()
this.scrap.setReal( this.f.evalDouble( this.point ) );
return this.scrap;
}

@Override
public O getType()
{
return scrap;
}
}

@Override
Expand All @@ -95,6 +101,12 @@ public O get()
return this.sampler.get();
}

@Override
public O getType()
{
return this.sampler.getType();
}

@Override
public RandomAccess< O > copy()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,10 @@ public Cursor< O > localizingCursor()
{
return this.cursor();
}

@Override
public O getType()
{
return outputType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ public O get()
return this.outsideO;
}


@Override
public O getType()
{
return this.scrap;
}

@Override
public RandomAccess< O > copy()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ public T get()
return source.get();
}

@Override
public T getType()
{
return source.getType();
}

@Override
public void fwd()
{
Expand Down Expand Up @@ -435,4 +441,9 @@ public LocalCursor localizingCursor()
return cursor();
}

@Override
public T getType()
{
return sourceRandomAccess.getType();
}
}
Loading
Loading