Skip to content
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
6 changes: 4 additions & 2 deletions src/main/java/net/imglib2/algorithm/math/Add.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ public < O extends RealType< O > > Addition< O > reInit(
final O tmp,
final Map< String, O > bindings,
final Converter< RealType< ? >, O > converter,
Map< Variable< O >, OFunction< O > > imgSources )
final Map< Variable< O >, OFunction< O > > imgSources )
{
return new Addition< O >( tmp.copy(), this.a.reInit( tmp, bindings, converter, imgSources ), this.b.reInit( tmp, bindings, converter, imgSources ) );
return new Addition< O >( tmp.copy(),
this.a.reInit( tmp, bindings, converter, imgSources ),
this.b.reInit( tmp, bindings, converter, imgSources ) );
}
}
4 changes: 2 additions & 2 deletions src/main/java/net/imglib2/algorithm/math/Compute.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ public final void convert( final RealType< ? > input, final O output)
output.setReal( input.getRealDouble() );
}
};

// Recursive copy: initializes interval iterators and sets temporary computation holder
final OFunction< O > f = this.operation.reInit(
target.randomAccess().get().createVariable(),
new HashMap< String, O >(),
converter, null );

// Check compatible iteration order and dimensions
if ( compatible_iteration_order )
if ( this.compatible_iteration_order )
{
// Evaluate function for every pixel
for ( final O output : Views.iterable( target ) )
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/net/imglib2/algorithm/math/Div.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ public < O extends RealType< O > > Division< O > reInit(
final O tmp,
final Map< String, O > bindings,
final Converter< RealType< ? >, O > converter,
Map< Variable< O >, OFunction< O > > imgSources )
final Map< Variable< O >, OFunction< O > > imgSources )
{
return new Division< O >( tmp.copy(), this.a.reInit( tmp, bindings, converter, imgSources ), this.b.reInit( tmp, bindings, converter, imgSources ) );
return new Division< O >( tmp.copy(),
this.a.reInit( tmp, bindings, converter, imgSources ),
this.b.reInit( tmp, bindings, converter, imgSources ) );
}
}
4 changes: 3 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/Equal.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public < O extends RealType< O > > OFunction< O > reInit(
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
return new Equality< O >( tmp.copy(), this.a.reInit( tmp, bindings, converter, imgSources ), this.b.reInit( tmp, bindings, converter, imgSources ) );
return new Equality< O >( tmp.copy(),
this.a.reInit( tmp, bindings, converter, imgSources ),
this.b.reInit( tmp, bindings, converter, imgSources ) );
}
}
6 changes: 4 additions & 2 deletions src/main/java/net/imglib2/algorithm/math/GreaterThan.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ public < O extends RealType< O > > IsGreaterThan< O > reInit(
final O tmp,
final Map< String, O > bindings,
final Converter< RealType< ? >, O > converter,
Map< Variable< O >, OFunction< O > > imgSources )
final Map< Variable< O >, OFunction< O > > imgSources )
{
return new IsGreaterThan< O >( tmp.copy(), this.a.reInit( tmp, bindings, converter, imgSources ), this.b.reInit( tmp, bindings, converter, imgSources ) );
return new IsGreaterThan< O >( tmp.copy(),
this.a.reInit( tmp, bindings, converter, imgSources ),
this.b.reInit( tmp, bindings, converter, imgSources ) );
}
}
10 changes: 10 additions & 0 deletions src/main/java/net/imglib2/algorithm/math/ImgMath.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,14 @@ static public final Else ELSE( final Object o )
{
return new Else( o );
}

static public final < T extends RealType< T > > ImgSource< T > img( final RandomAccessibleInterval< T > rai )
{
return new ImgSource< T >( rai );
}

static public final NumberSource number( final Number number )
{
return new NumberSource( number );
}
}
4 changes: 3 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/ImgSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public < O extends RealType< O > > OFunction< O > reInit(
final Map< Variable< O >, OFunction< O > > imgSources )
{
// Optimization: if input image type is the same or a subclass of
// the output image type (represented here by tmp), then avoid the converter.
// the output image type (represented here by tmp), then avoid the converter
// but only if the targetImg is different than this.rai: otherwise, an intermediate
// computation result holder must be used (the scrap).
final OFunction< O > s;
if ( tmp.getClass().isAssignableFrom( this.rai.randomAccess().get().getClass() ) )
s = new ImgSourceIterableDirect< O >( ( RandomAccessibleInterval< O > )this.rai );
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/LessThan.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public < O extends RealType< O > > IsLessThan< O > reInit(
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
return new IsLessThan< O >( tmp.copy(), this.a.reInit( tmp, bindings, converter, imgSources ), this.b.reInit( tmp, bindings, converter, imgSources ) );
return new IsLessThan< O >( tmp.copy(),
this.a.reInit( tmp, bindings, converter, imgSources ),
this.b.reInit( tmp, bindings, converter, imgSources ) );
}
}
4 changes: 3 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/Let.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public < O extends RealType< O > > LetBinding< O > reInit(
final O scrap = tmp.copy();
final Map< String, O > rebind = new HashMap<>( bindings );
rebind.put( this.varName, scrap );
return new LetBinding< O >( scrap, this.varName, this.varValue.reInit( tmp, rebind, converter, imgSources ), this.body.reInit( tmp, rebind, converter, imgSources ) );
return new LetBinding< O >( scrap, this.varName,
this.varValue.reInit( tmp, rebind, converter, imgSources ),
this.body.reInit( tmp, rebind, converter, imgSources ) );
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/Max.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public < O extends RealType< O > > Maximum< O > reInit(
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
return new Maximum< O >( this.a.reInit( tmp, bindings, converter, imgSources ), this.b.reInit( tmp, bindings, converter, imgSources ) );
return new Maximum< O >(
this.a.reInit( tmp, bindings, converter, imgSources ),
this.b.reInit( tmp, bindings, converter, imgSources ) );
}
}
4 changes: 3 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/Min.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public < O extends RealType< O > > Minimum< O > reInit(
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
return new Minimum< O >( this.a.reInit(tmp, bindings, converter, imgSources), this.b.reInit(tmp, bindings, converter, imgSources) );
return new Minimum< O >(
this.a.reInit( tmp, bindings, converter, imgSources ),
this.b.reInit( tmp, bindings, converter, imgSources ) );
}
}
4 changes: 3 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/Mul.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public < O extends RealType< O > > Multiplication< O > reInit(
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
return new Multiplication< O >( tmp.copy(), this.a.reInit( tmp, bindings, converter, imgSources ), this.b.reInit( tmp, bindings, converter, imgSources ) );
return new Multiplication< O >( tmp.copy(),
this.a.reInit( tmp, bindings, converter, imgSources ),
this.b.reInit( tmp, bindings, converter, imgSources ) );
}
}
4 changes: 3 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/NotEqual.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public < O extends RealType< O > > NotEquality< O > reInit(
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
return new NotEquality< O >( tmp.copy(), this.a.reInit( tmp, bindings, converter, imgSources ), this.b.reInit( tmp, bindings, converter, imgSources ) );
return new NotEquality< O >( tmp.copy(),
this.a.reInit( tmp, bindings, converter, imgSources ),
this.b.reInit( tmp, bindings, converter, imgSources ) );
}
}
4 changes: 3 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/Sub.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public < O extends RealType< O > > Subtraction< O > reInit(
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
return new Subtraction< O >( tmp.copy(), this.a.reInit( tmp, bindings, converter, imgSources ), this.b.reInit( tmp, bindings, converter, imgSources ) );
return new Subtraction< O >( tmp.copy(),
this.a.reInit( tmp, bindings, converter, imgSources ),
this.b.reInit( tmp, bindings, converter, imgSources ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.imglib2.type.numeric.RealType;

abstract public class AUnaryFunction extends VarargsFunction implements IUnaryFunction
abstract public class AUnaryFunction implements IUnaryFunction
{
protected final IFunction a;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
abstract public class VarargsFunction
{
final public IFunction[] wrapMap( final Object[] obs )
{
{
try {
if ( 2 == obs.length )
return new IFunction[]{ Util.wrap( obs[ 0 ] ), Util.wrap( obs[ 1 ]) };

final Constructor< ? > constructor = this.getClass().getConstructor( new Class[]{ Object.class, Object.class } );
ABinaryFunction a = ( ABinaryFunction )constructor.newInstance( obs[0], obs[1] );
ABinaryFunction b;
Expand Down