use of net.imglib2.Cursor in project imagej-ops by imagej.
the class JoinTest method testJoinInplaceAndComputer.
@Test
public void testJoinInplaceAndComputer() {
final Op op = ops.op(DefaultJoinInplaceAndComputer.class, out, in, inplaceOp, computerOp);
op.run();
// test
final Cursor<ByteType> c = out.cursor();
while (c.hasNext()) {
assertEquals(2, c.next().get());
}
}
use of net.imglib2.Cursor in project imagej-ops by imagej.
the class JoinTest method testJoin2Inplaces.
@Test
public void testJoin2Inplaces() {
final Op op = ops.op(DefaultJoin2Inplaces.class, in, inplaceOp, inplaceOp);
op.run();
// test
final Cursor<ByteType> c = in.cursor();
while (c.hasNext()) {
assertEquals(2, c.next().get());
}
}
use of net.imglib2.Cursor in project imagej-ops by imagej.
the class MeanTest method testMean.
@Test
public void testMean() {
final Img<ByteType> image = generateByteArrayTestImg(true, 40, 50);
final DoubleType mean = new DoubleType();
ops.run(IterableMean.class, mean, image);
assertEquals(1.0 / 15.625, mean.get(), 0.0);
Cursor<ByteType> c = image.cursor();
// this time lets just make every value 100
while (c.hasNext()) {
c.fwd();
c.get().setReal(100.0);
}
ops.run(IterableMean.class, mean, image);
// the mean should be 100
assertEquals(100.0, mean.get(), 0.0);
}
use of net.imglib2.Cursor in project imagej-ops by imagej.
the class FlatIterableViewTest method defaultFlatIterableTest.
@Test
public void defaultFlatIterableTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
Cursor<DoubleType> il2 = Views.flatIterable(img).cursor();
Cursor<DoubleType> opr = ops.transform().flatIterableView(img).cursor();
while (il2.hasNext()) {
il2.next();
opr.next();
assertEquals(il2.getDoublePosition(0), opr.getDoublePosition(0), 1e-10);
assertEquals(il2.getDoublePosition(1), opr.getDoublePosition(1), 1e-10);
}
}
use of net.imglib2.Cursor in project imagej-ops by imagej.
the class IntervalViewTest method intervalMinMaxTest.
@Test
public void intervalMinMaxTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
Random r = new Random();
for (DoubleType d : img) {
d.set(r.nextDouble());
}
Cursor<DoubleType> il2 = Views.interval(img, new long[] { 1, 1 }, new long[] { 8, 9 }).localizingCursor();
RandomAccess<DoubleType> opr = ops.transform().intervalView(img, new long[] { 1, 1 }, new long[] { 8, 9 }).randomAccess();
while (il2.hasNext()) {
DoubleType e = il2.next();
opr.setPosition(il2);
assertEquals(e.get(), opr.get().get(), 1e-10);
}
}
Aggregations