Created
April 29, 2013 18:44
-
-
Save bdezonia/5483745 to your computer and use it in GitHub Desktop.
Example copying Expressions style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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