use of net.imglib2.Cursor in project imagej-ops by imagej.
the class NormalizeTest method testNormalize.
@Test
public void testNormalize() {
Img<ByteType> in = generateByteArrayTestImg(true, 5, 5);
Img<ByteType> out = in.factory().create(in, new ByteType());
ops.run(NormalizeIIComputer.class, out, in);
final Pair<ByteType, ByteType> minMax2 = ops.stats().minMax(out);
assertEquals(minMax2.getA().get(), Byte.MIN_VALUE);
assertEquals(minMax2.getB().get(), Byte.MAX_VALUE);
final IterableInterval<ByteType> lazyOut = ops.image().normalize(in);
final IterableInterval<ByteType> notLazyOut = ops.image().normalize(in, null, null, null, null, false);
final Cursor<ByteType> outCursor = out.cursor();
final Cursor<ByteType> lazyCursor = lazyOut.cursor();
final Cursor<ByteType> notLazyCursor = notLazyOut.cursor();
while (outCursor.hasNext()) {
assertEquals(outCursor.next().get(), lazyCursor.next().get());
assertEquals(outCursor.get().get(), notLazyCursor.next().get());
}
}
use of net.imglib2.Cursor in project imagej-ops by imagej.
the class DilationTest method testListDilateFull.
@Test
public void testListDilateFull() {
final List<Shape> shapes = new ArrayList<>();
shapes.add(new DiamondShape(1));
shapes.add(new DiamondShape(1));
shapes.add(new RectangleShape(1, false));
shapes.add(new HorizontalLineShape(2, 1, false));
@SuppressWarnings("unchecked") final IterableInterval<ByteType> out1 = (IterableInterval<ByteType>) ops.run(ListDilate.class, IterableInterval.class, in, shapes, true);
final Img<ByteType> out2 = Dilation.dilateFull(in, shapes, 1);
final Cursor<ByteType> c1 = out1.cursor();
final Cursor<ByteType> c2 = out2.cursor();
while (c1.hasNext()) assertEquals(c1.next().get(), c2.next().get());
}
use of net.imglib2.Cursor in project imagej-ops by imagej.
the class DilationTest method testSingleDilate.
@Test
public void testSingleDilate() {
final Shape shape = new DiamondShape(1);
@SuppressWarnings("unchecked") final Img<ByteType> out1 = (Img<ByteType>) ops.run(DefaultDilate.class, Img.class, in, shape, false);
final Img<ByteType> out2 = Dilation.dilate(in, shape, 1);
final Cursor<ByteType> c1 = out1.cursor();
final Cursor<ByteType> c2 = out2.cursor();
while (c1.hasNext()) assertEquals(c1.next().get(), c2.next().get());
}
use of net.imglib2.Cursor in project imagej-ops by imagej.
the class DilationTest method testSingleDilateFull.
@Test
public void testSingleDilateFull() {
final Shape shape = new DiamondShape(1);
@SuppressWarnings("unchecked") final Img<ByteType> out1 = (Img<ByteType>) ops.run(DefaultDilate.class, Img.class, in, shape, true);
final Img<ByteType> out2 = Dilation.dilateFull(in, shape, 1);
final Cursor<ByteType> c1 = out1.cursor();
final Cursor<ByteType> c2 = out2.cursor();
while (c1.hasNext()) assertEquals(c1.next().get(), c2.next().get());
}
use of net.imglib2.Cursor in project imagej-ops by imagej.
the class ImageMomentsTest method createImg.
@BeforeClass
public static void createImg() {
Img<UnsignedByteType> tmp = ArrayImgs.unsignedBytes(new long[] { 100, 100 });
Random rand = new Random(1234567890L);
final Cursor<UnsignedByteType> cursor = tmp.cursor();
while (cursor.hasNext()) {
cursor.next().set(rand.nextInt((int) tmp.firstElement().getMaxValue()));
}
img = tmp;
}
Aggregations