Skip to content

Commit

Permalink
Merge pull request #87 from imglib/io-package
Browse files Browse the repository at this point in the history
ImgMath updates
  • Loading branch information
ctrueden committed Aug 6, 2020
2 parents 1096528 + cc919c6 commit e2fa1fe
Show file tree
Hide file tree
Showing 53 changed files with 1,284 additions and 47 deletions.
2 changes: 2 additions & 0 deletions pom.xml
Expand Up @@ -200,6 +200,8 @@ Jean-Yves Tinevez and Michael Zinsmaier.</license.copyrightOwners>

<!-- NB: Deploy releases to the SciJava Maven repository. -->
<releaseProfiles>deploy-to-scijava</releaseProfiles>

<imglib2.version>5.10.0</imglib2.version>
</properties>

<repositories>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/Add.java
Expand Up @@ -5,6 +5,7 @@
import net.imglib2.algorithm.math.abstractions.ABinaryFunction;
import net.imglib2.algorithm.math.abstractions.OFunction;
import net.imglib2.algorithm.math.execution.Addition;
import net.imglib2.algorithm.math.execution.LetBinding;
import net.imglib2.algorithm.math.execution.Variable;
import net.imglib2.converter.Converter;
import net.imglib2.type.numeric.RealType;
Expand All @@ -24,7 +25,7 @@ public Add( final Object... obs )
@Override
public < O extends RealType< O > > Addition< O > reInit(
final O tmp,
final Map< String, O > bindings,
final Map< String, LetBinding< O > > bindings,
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
Expand Down
415 changes: 401 additions & 14 deletions src/main/java/net/imglib2/algorithm/math/Compute.java

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/Div.java
Expand Up @@ -5,6 +5,7 @@
import net.imglib2.algorithm.math.abstractions.ABinaryFunction;
import net.imglib2.algorithm.math.abstractions.OFunction;
import net.imglib2.algorithm.math.execution.Division;
import net.imglib2.algorithm.math.execution.LetBinding;
import net.imglib2.algorithm.math.execution.Variable;
import net.imglib2.converter.Converter;
import net.imglib2.type.numeric.RealType;
Expand All @@ -25,7 +26,7 @@ public Div( final Object... obs )
@Override
public < O extends RealType< O > > Division< O > reInit(
final O tmp,
final Map< String, O > bindings,
final Map< String, LetBinding< O > > bindings,
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/Equal.java
Expand Up @@ -5,6 +5,7 @@
import net.imglib2.algorithm.math.abstractions.Compare;
import net.imglib2.algorithm.math.abstractions.OFunction;
import net.imglib2.algorithm.math.execution.Equality;
import net.imglib2.algorithm.math.execution.LetBinding;
import net.imglib2.algorithm.math.execution.Variable;
import net.imglib2.converter.Converter;
import net.imglib2.type.numeric.RealType;
Expand All @@ -19,7 +20,7 @@ public Equal( final Object o1, final Object o2 )
@Override
public < O extends RealType< O > > OFunction< O > reInit(
final O tmp,
final Map< String, O > bindings,
final Map< String, LetBinding< O > > bindings,
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/net/imglib2/algorithm/math/Exp.java
@@ -0,0 +1,30 @@
package net.imglib2.algorithm.math;

import java.util.Map;

import net.imglib2.algorithm.math.abstractions.AUnaryFunction;
import net.imglib2.algorithm.math.abstractions.OFunction;
import net.imglib2.algorithm.math.execution.Exponential;
import net.imglib2.algorithm.math.execution.LetBinding;
import net.imglib2.algorithm.math.execution.Variable;
import net.imglib2.converter.Converter;
import net.imglib2.type.numeric.RealType;

public final class Exp extends AUnaryFunction
{
public Exp( final Object o1 )
{
super( o1 );
}

@Override
public < O extends RealType< O > > Exponential< O > reInit(
final O tmp,
final Map< String, LetBinding< O > > bindings,
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
return new Exponential< O >( tmp.copy(),
this.a.reInit( tmp, bindings, converter, imgSources ) );
}
}
3 changes: 2 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/GreaterThan.java
Expand Up @@ -5,6 +5,7 @@
import net.imglib2.algorithm.math.abstractions.Compare;
import net.imglib2.algorithm.math.abstractions.OFunction;
import net.imglib2.algorithm.math.execution.IsGreaterThan;
import net.imglib2.algorithm.math.execution.LetBinding;
import net.imglib2.algorithm.math.execution.Variable;
import net.imglib2.converter.Converter;
import net.imglib2.type.numeric.RealType;
Expand All @@ -19,7 +20,7 @@ public GreaterThan( final Object o1, final Object o2 )
@Override
public < O extends RealType< O > > IsGreaterThan< O > reInit(
final O tmp,
final Map< String, O > bindings,
final Map< String, LetBinding< O > > bindings,
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/imglib2/algorithm/math/If.java
Expand Up @@ -24,7 +24,7 @@ public If( final Object o1, final Object o2, final Object o3 )
@Override
public < O extends RealType< O > > OFunction< O > reInit(
final O tmp,
final Map< String, O > bindings,
final Map< String, LetBinding< O > > bindings,
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
Expand Down
66 changes: 66 additions & 0 deletions src/main/java/net/imglib2/algorithm/math/ImgMath.java
Expand Up @@ -5,6 +5,7 @@
import net.imglib2.algorithm.math.abstractions.Util;
import net.imglib2.converter.Converter;
import net.imglib2.img.array.ArrayImgFactory;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;
import net.imglib2.type.numeric.real.FloatType;

Expand Down Expand Up @@ -98,6 +99,16 @@ static public final < O extends RealType< O > > RandomAccessibleInterval< O > co
return new Compute( operation ).into( target, converter );
}

static public final < O extends NativeType< O > & RealType< O > > RandomAccessibleInterval< O > computeIntoImg( final IFunction operation )
{
return compute( operation ).intoImg();
}

static public final < O extends NativeType< O > & RealType< O > > RandomAccessibleInterval< O > computeIntoArrayImg( final IFunction operation )
{
return compute( operation ).intoArrayImg();
}

static public final Add add( final Object o1, final Object o2 )
{
return new Add( o1, o2 );
Expand Down Expand Up @@ -138,6 +149,26 @@ static public final Div div( final Object... obs )
return new Div( obs );
}

static public final Pow pow( final Object o1, final Object o2 )
{
return new Pow( o1, o2 );
}

static public final Pow power( final Object... obs )
{
return new Pow( obs );
}

static public final Pow power( final Object o1, final Object o2 )
{
return new Pow( o1, o2 );
}

static public final Pow pow( final Object... obs )
{
return new Pow( obs );
}

static public final Max max( final Object o1, final Object o2 )
{
return new Max( o1, o2 );
Expand Down Expand Up @@ -178,6 +209,21 @@ static public final Min minimum( final Object... obs )
return new Min( obs );
}

static public final Log log( final Object o1 )
{
return new Log( o1 );
}

static public final Log logarithm( final Object o1 )
{
return new Log( o1 );
}

static public final Exp exp( final Object o1 )
{
return new Exp( o1 );
}

static public final Let let( final String varName, final Object varValue, final Object body )
{
return new Let( varName, varValue, body );
Expand All @@ -203,21 +249,41 @@ static public final Equal EQ( final Object o1, final Object o2 )
return new Equal( o1, o2 );
}

static public final Equal equal( final Object o1, final Object o2 )
{
return new Equal( o1, o2 );
}

static public final NotEqual NEQ( final Object o1, final Object o2 )
{
return new NotEqual( o1, o2 );
}

static public final NotEqual notEqual( final Object o1, final Object o2 )
{
return new NotEqual( o1, o2 );
}

static public final LessThan LT( final Object o1, final Object o2 )
{
return new LessThan( o1, o2 );
}

static public final LessThan lessThan( final Object o1, final Object o2 )
{
return new LessThan( o1, o2 );
}

static public final GreaterThan GT( final Object o1, final Object o2 )
{
return new GreaterThan( o1, o2 );
}

static public final GreaterThan greaterThan( final Object o1, final Object o2 )
{
return new GreaterThan( o1, o2 );
}

static public final If IF( final Object o1, final Object o2, final Object o3 )
{
return new If( o1, o2, o3 );
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/ImgSource.java
Expand Up @@ -8,6 +8,7 @@
import net.imglib2.algorithm.math.abstractions.ViewableFunction;
import net.imglib2.algorithm.math.execution.ImgSourceIterable;
import net.imglib2.algorithm.math.execution.ImgSourceIterableDirect;
import net.imglib2.algorithm.math.execution.LetBinding;
import net.imglib2.algorithm.math.execution.Variable;
import net.imglib2.converter.Converter;
import net.imglib2.type.numeric.RealType;
Expand All @@ -25,7 +26,7 @@ public ImgSource( final RandomAccessibleInterval< I > rai )
@Override
public < O extends RealType< O > > OFunction< O > reInit(
final O tmp,
final Map< String, O > bindings,
final Map< String, LetBinding< O > > bindings,
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/LessThan.java
Expand Up @@ -5,6 +5,7 @@
import net.imglib2.algorithm.math.abstractions.Compare;
import net.imglib2.algorithm.math.abstractions.OFunction;
import net.imglib2.algorithm.math.execution.IsLessThan;
import net.imglib2.algorithm.math.execution.LetBinding;
import net.imglib2.algorithm.math.execution.Variable;
import net.imglib2.converter.Converter;
import net.imglib2.type.numeric.RealType;
Expand All @@ -19,7 +20,7 @@ public LessThan( final Object o1, final Object o2 )
@Override
public < O extends RealType< O > > IsLessThan< O > reInit(
final O tmp,
final Map< String, O > bindings,
final Map< String, LetBinding< O > > bindings,
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/net/imglib2/algorithm/math/Let.java
Expand Up @@ -62,16 +62,18 @@ static private final Object[] fixAndValidate( final Object[] obs )
@Override
public < O extends RealType< O > > LetBinding< O > reInit(
final O tmp,
final Map< String, O > bindings,
final Map< String, LetBinding< O > > bindings,
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
final O scrap = tmp.copy();
final Map< String, O > rebind = new HashMap<>( bindings );
rebind.put( this.varName, scrap );
final Map< String, LetBinding< O > > rebind = new HashMap<>( bindings );
// The LetBinding constructor will add itself to the rebind prior to reInit the two IFunction varValue and body.
return new LetBinding< O >( scrap, this.varName,
this.varValue.reInit( tmp, rebind, converter, imgSources ),
this.body.reInit( tmp, rebind, converter, imgSources ) );
rebind,
this.varValue, //this.varValue.reInit( tmp, rebind, converter, imgSources ),
this.body, //this.body.reInit( tmp, rebind, converter, imgSources ) );
converter, imgSources );
}

@Override
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/net/imglib2/algorithm/math/Log.java
@@ -0,0 +1,30 @@
package net.imglib2.algorithm.math;

import java.util.Map;

import net.imglib2.algorithm.math.abstractions.AUnaryFunction;
import net.imglib2.algorithm.math.abstractions.OFunction;
import net.imglib2.algorithm.math.execution.Logarithm;
import net.imglib2.algorithm.math.execution.LetBinding;
import net.imglib2.algorithm.math.execution.Variable;
import net.imglib2.converter.Converter;
import net.imglib2.type.numeric.RealType;

public final class Log extends AUnaryFunction
{
public Log( final Object o1 )
{
super( o1 );
}

@Override
public < O extends RealType< O > > Logarithm< O > reInit(
final O tmp,
final Map< String, LetBinding< O > > bindings,
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
return new Logarithm< O >( tmp.copy(),
this.a.reInit( tmp, bindings, converter, imgSources ) );
}
}
3 changes: 2 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/Max.java
Expand Up @@ -4,6 +4,7 @@

import net.imglib2.algorithm.math.abstractions.ABinaryFunction;
import net.imglib2.algorithm.math.abstractions.OFunction;
import net.imglib2.algorithm.math.execution.LetBinding;
import net.imglib2.algorithm.math.execution.Maximum;
import net.imglib2.algorithm.math.execution.Variable;
import net.imglib2.converter.Converter;
Expand All @@ -24,7 +25,7 @@ public Max( final Object... obs )
@Override
public < O extends RealType< O > > Maximum< O > reInit(
final O tmp,
final Map< String, O > bindings,
final Map< String, LetBinding< O > > bindings,
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/Min.java
Expand Up @@ -4,6 +4,7 @@

import net.imglib2.algorithm.math.abstractions.ABinaryFunction;
import net.imglib2.algorithm.math.abstractions.OFunction;
import net.imglib2.algorithm.math.execution.LetBinding;
import net.imglib2.algorithm.math.execution.Minimum;
import net.imglib2.algorithm.math.execution.Variable;
import net.imglib2.converter.Converter;
Expand All @@ -24,7 +25,7 @@ public Min( final Object... obs )
@Override
public < O extends RealType< O > > Minimum< O > reInit(
final O tmp,
final Map< String, O > bindings,
final Map< String, LetBinding< O > > bindings,
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/Mul.java
Expand Up @@ -4,6 +4,7 @@

import net.imglib2.algorithm.math.abstractions.ABinaryFunction;
import net.imglib2.algorithm.math.abstractions.OFunction;
import net.imglib2.algorithm.math.execution.LetBinding;
import net.imglib2.algorithm.math.execution.Multiplication;
import net.imglib2.algorithm.math.execution.Variable;
import net.imglib2.converter.Converter;
Expand All @@ -24,7 +25,7 @@ public Mul( final Object... obs )
@Override
public < O extends RealType< O > > Multiplication< O > reInit(
final O tmp,
final Map< String, O > bindings,
final Map< String, LetBinding< O > > bindings,
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/imglib2/algorithm/math/NotEqual.java
Expand Up @@ -4,6 +4,7 @@

import net.imglib2.algorithm.math.abstractions.Compare;
import net.imglib2.algorithm.math.abstractions.OFunction;
import net.imglib2.algorithm.math.execution.LetBinding;
import net.imglib2.algorithm.math.execution.NotEquality;
import net.imglib2.algorithm.math.execution.Variable;
import net.imglib2.converter.Converter;
Expand All @@ -18,7 +19,7 @@ public NotEqual( final Object o1, final Object o2) {
@Override
public < O extends RealType< O > > NotEquality< O > reInit(
final O tmp,
final Map< String, O > bindings,
final Map< String, LetBinding< O > > bindings,
final Converter< RealType< ? >, O > converter,
final Map< Variable< O >, OFunction< O > > imgSources )
{
Expand Down

0 comments on commit e2fa1fe

Please sign in to comment.