Skip to content

Commit 3fbf315

Browse files
committed
ImgMath: convenient static methods in ImgMath for invoking compute/into:
RandomAccessibleInterval< FloatType> ImgMath.computeIntoFloat( IFunction ) RandomAccessibleInterval< O > ImgMath.computeInto( IFunction, RandomAccessibleInterval< O > ) RandomAccessibleInterval< O > ImgMath.computeInto( IFunction, RandomAccessibleInterval< O >, Converter< RealType< ? >, O > )
1 parent bdc8f78 commit 3fbf315

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/main/java/net/imglib2/algorithm/math/ImgMath.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
import net.imglib2.RandomAccessibleInterval;
44
import net.imglib2.algorithm.math.abstractions.IFunction;
5+
import net.imglib2.algorithm.math.abstractions.Util;
6+
import net.imglib2.converter.Converter;
7+
import net.imglib2.img.array.ArrayImgFactory;
8+
import net.imglib2.type.numeric.RealType;
9+
import net.imglib2.type.numeric.real.FloatType;
510

611
/**
712
* An easy yet high performance way to perform pixel-wise math
@@ -73,6 +78,26 @@ static public final Compute compute( final IFunction operation )
7378
return new Compute( operation );
7479
}
7580

81+
static public final RandomAccessibleInterval< FloatType > computeIntoFloat( final IFunction operation )
82+
{
83+
return new Compute( operation ).into( new ArrayImgFactory< FloatType >( new FloatType() ).create( Util.findImg( operation ).iterator().next() ) );
84+
}
85+
86+
static public final < O extends RealType< O > > RandomAccessibleInterval< O > computeInto(
87+
final IFunction operation,
88+
final RandomAccessibleInterval< O > target )
89+
{
90+
return new Compute( operation ).into( target );
91+
}
92+
93+
static public final < O extends RealType< O > > RandomAccessibleInterval< O > computeInto(
94+
final IFunction operation,
95+
final RandomAccessibleInterval< O > target,
96+
final Converter< RealType< ? >, O > converter )
97+
{
98+
return new Compute( operation ).into( target, converter );
99+
}
100+
76101
static public final Add add( final Object o1, final Object o2 )
77102
{
78103
return new Add( o1, o2 );

0 commit comments

Comments
 (0)