use of net.imglib2.Cursor in project imagej-ops by imagej.
the class IntervalViewTest method defaultIntervalTest.
@Test
public void defaultIntervalTest() {
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, img).localizingCursor();
RandomAccess<DoubleType> opr = ops.transform().intervalView(img, img).randomAccess();
while (il2.hasNext()) {
DoubleType e = il2.next();
opr.setPosition(il2);
assertEquals(e.get(), opr.get().get(), 1e-10);
}
}
use of net.imglib2.Cursor in project imagej-ops by imagej.
the class PermuteViewTest method testIntervalPermuteCoordinates.
@Test
public void testIntervalPermuteCoordinates() {
Img<DoubleType> img = ArrayImgs.doubles(2, 2);
Cursor<DoubleType> c = img.cursor();
Random r = new Random();
while (c.hasNext()) {
c.next().set(r.nextDouble());
}
IntervalView<DoubleType> expected = Views.permuteCoordinates(img, new int[] { 0, 1 });
Cursor<DoubleType> e = expected.cursor();
RandomAccessibleInterval<DoubleType> actual = ops.transform().permuteCoordinatesView(img, new int[] { 0, 1 });
RandomAccess<DoubleType> actualRA = actual.randomAccess();
while (e.hasNext()) {
e.next();
actualRA.setPosition(e);
assertEquals(e.get().get(), actualRA.get().get(), 1e-10);
}
assertTrue(Intervals.equals(expected, actual));
}
use of net.imglib2.Cursor in project imagej-ops by imagej.
the class PermuteViewTest method testIntervalPermuteInverseDimensionCoordinates.
@Test
public void testIntervalPermuteInverseDimensionCoordinates() {
Img<DoubleType> img = ArrayImgs.doubles(2, 2);
Cursor<DoubleType> c = img.cursor();
Random r = new Random();
while (c.hasNext()) {
c.next().set(r.nextDouble());
}
IntervalView<DoubleType> expected = Views.permuteCoordinateInverse(img, new int[] { 0, 1 }, 1);
Cursor<DoubleType> e = expected.cursor();
RandomAccessibleInterval<DoubleType> actual = ops.transform().permuteCoordinatesInverseView(img, new int[] { 0, 1 }, 1);
RandomAccess<DoubleType> actualRA = actual.randomAccess();
while (e.hasNext()) {
e.next();
actualRA.setPosition(e);
assertEquals(e.get().get(), actualRA.get().get(), 1e-10);
}
assertTrue(Intervals.equals(expected, actual));
}
use of net.imglib2.Cursor in project imagej-ops by imagej.
the class PermuteViewTest method permuteCoordinatesInverseOfDimensionTest.
@Test
public void permuteCoordinatesInverseOfDimensionTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 2, 2 }, new DoubleType());
Cursor<DoubleType> c = img.cursor();
Random r = new Random();
while (c.hasNext()) {
c.next().set(r.nextDouble());
}
IntervalView<DoubleType> out = Views.permuteCoordinateInverse(img, new int[] { 0, 1 }, 1);
Cursor<DoubleType> il2 = out.cursor();
RandomAccess<DoubleType> opr = ops.transform().permuteCoordinatesInverseView(img, new int[] { 0, 1 }, 1).randomAccess();
while (il2.hasNext()) {
il2.next();
opr.setPosition(il2);
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
}
}
use of net.imglib2.Cursor in project imagej-ops by imagej.
the class PermuteViewTest method testIntervalPermuteDimensionCoordinates.
@Test
public void testIntervalPermuteDimensionCoordinates() {
Img<DoubleType> img = ArrayImgs.doubles(2, 2);
Cursor<DoubleType> c = img.cursor();
Random r = new Random();
while (c.hasNext()) {
c.next().set(r.nextDouble());
}
IntervalView<DoubleType> expected = Views.permuteCoordinates(img, new int[] { 0, 1 }, 1);
Cursor<DoubleType> e = expected.cursor();
RandomAccessibleInterval<DoubleType> actual = ops.transform().permuteCoordinatesView(img, new int[] { 0, 1 }, 1);
RandomAccess<DoubleType> actualRA = actual.randomAccess();
while (e.hasNext()) {
e.next();
actualRA.setPosition(e);
assertEquals(e.get().get(), actualRA.get().get(), 1e-10);
}
assertTrue(Intervals.equals(expected, actual));
}
Aggregations