Skip to content

Instantly share code, notes, and snippets.

@bdezonia
Created April 29, 2013 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdezonia/5483745 to your computer and use it in GitHub Desktop.
Save bdezonia/5483745 to your computer and use it in GitHub Desktop.
Example copying Expressions style
public static void testPointSetsAndFunctions() {
final Img< FloatType > imgA = ArrayImgs.floats( 5000, 5000 );
final Img< FloatType > imgB = ArrayImgs.floats( 5000, 5000 );
final Img< FloatType > imgC = ArrayImgs.floats( 5000, 5000 );
int i = 0;
for ( final FloatType t : imgA )
t.set( i++ );
i = 0;
for ( final FloatType t : imgB )
t.set( i++ );
BenchmarkHelper.benchmarkAndPrint( 10, true, new Runnable()
{
@Override
public void run()
{
final RealImageFunction<FloatType,FloatType> imgAFunc = new RealImageFunction<FloatType, FloatType>(imgA, new FloatType());
final RealImageFunction<FloatType,FloatType> imgBFunc = new RealImageFunction<FloatType, FloatType>(imgB, new FloatType());
final GeneralBinaryFunction<long[], FloatType, FloatType, FloatType> binFunc = new GeneralBinaryFunction<long[], FloatType, FloatType, FloatType>(imgAFunc, imgBFunc, new RealAdd<FloatType, FloatType, FloatType>(), new FloatType());
final HyperVolumePointSet ps = new HyperVolumePointSet(new long[]{5000,5000});
final RandomAccess<FloatType> access = imgC.randomAccess();
final PointSetIterator iter = ps.iterator();
final FloatType output = new FloatType();
long[] pos;
while (iter.hasNext()) {
pos = iter.next();
binFunc.compute(pos, output);
access.get().set(output);
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment