use of net.imglib2.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class OffsetViewTest method defaultOffsetTest.
@Test
public void defaultOffsetTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
MixedTransformView<DoubleType> il2 = Views.offset((RandomAccessible<DoubleType>) img, new long[] { 2, 2 });
MixedTransformView<DoubleType> opr = ops.transform().offsetView((RandomAccessible<DoubleType>) img, new long[] { 2, 2 });
for (int i = 0; i < il2.getTransformToSource().getMatrix().length; i++) {
for (int j = 0; j < il2.getTransformToSource().getMatrix()[i].length; j++) {
assertEquals(il2.getTransformToSource().getMatrix()[i][j], opr.getTransformToSource().getMatrix()[i][j], 1e-10);
}
}
}
use of net.imglib2.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class OffsetViewTest method defaultOffsetStartEndTest.
@Test
public void defaultOffsetStartEndTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
IntervalView<DoubleType> il2 = Views.offsetInterval(img, new long[] { 2, 2 }, new long[] { 9, 9 });
IntervalView<DoubleType> opr = ops.transform().offsetView(img, new long[] { 2, 2 }, new long[] { 9, 9 });
assertEquals(il2.realMax(0), opr.realMax(0), 1e-10);
assertEquals(il2.realMin(0), opr.realMin(0), 1e-10);
assertEquals(il2.realMax(1), opr.realMax(1), 1e-10);
assertEquals(il2.realMin(1), opr.realMin(1), 1e-10);
}
use of net.imglib2.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class OffsetViewTest method defaultOffsetIntervalTest.
@Test
public void defaultOffsetIntervalTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
IntervalView<DoubleType> il2 = Views.offsetInterval(img, new FinalInterval(new long[] { 2, 2 }, new long[] { 9, 9 }));
IntervalView<DoubleType> opr = ops.transform().offsetView(img, new FinalInterval(new long[] { 2, 2 }, new long[] { 9, 9 }));
assertEquals(il2.realMax(0), opr.realMax(0), 1e-10);
assertEquals(il2.realMin(0), opr.realMin(0), 1e-10);
assertEquals(il2.realMax(1), opr.realMax(1), 1e-10);
assertEquals(il2.realMin(1), opr.realMin(1), 1e-10);
}
use of net.imglib2.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class PermuteViewTest method permuteCoordinatesOfDimensionTest.
@Test
public void permuteCoordinatesOfDimensionTest() {
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());
}
Cursor<DoubleType> il2 = Views.permuteCoordinates(img, new int[] { 0, 1 }, 1).cursor();
RandomAccess<DoubleType> opr = ops.transform().permuteCoordinatesView(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.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class PermuteViewTest method defaultPermuteCoordinatesTest.
@Test
public void defaultPermuteCoordinatesTest() {
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());
}
Cursor<DoubleType> il2 = Views.permuteCoordinates(img, new int[] { 0, 1 }).cursor();
RandomAccess<DoubleType> opr = ops.transform().permuteCoordinatesView(img, new int[] { 0, 1 }).randomAccess();
while (il2.hasNext()) {
il2.next();
opr.setPosition(il2);
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
}
}
Aggregations