use of net.imglib2.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class ExtendViewTest method defaultExtendTest.
@Test
public void defaultExtendTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
OutOfBounds<DoubleType> il2 = Views.extend(img, new OutOfBoundsBorderFactory<DoubleType, RandomAccessibleInterval<DoubleType>>()).randomAccess();
OutOfBounds<DoubleType> opr = ops.transform().extendView(img, new OutOfBoundsBorderFactory<DoubleType, RandomAccessibleInterval<DoubleType>>()).randomAccess();
il2.setPosition(new int[] { -1, -1 });
opr.setPosition(new int[] { -1, -1 });
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
il2.setPosition(new int[] { 11, 11 });
opr.setPosition(new int[] { 11, 11 });
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
}
use of net.imglib2.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class ExtendZeroViewTest method extendZeroTest.
@Test
public void extendZeroTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
OutOfBounds<DoubleType> il2 = Views.extendZero(img).randomAccess();
OutOfBounds<DoubleType> opr = ops.transform().extendZeroView(img).randomAccess();
il2.setPosition(new int[] { -1, -1 });
opr.setPosition(new int[] { -1, -1 });
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
il2.setPosition(new int[] { 11, 11 });
opr.setPosition(new int[] { 11, 11 });
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
}
use of net.imglib2.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class HyperSliceViewTest method IntervalHyperSliceTest.
@Test
public void IntervalHyperSliceTest() {
final Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10, 10 }, new DoubleType());
final IntervalView<DoubleType> il2 = Views.hyperSlice((RandomAccessibleInterval<DoubleType>) img, 1, 8);
final IntervalView<DoubleType> opr = ops.transform().hyperSliceView(img, 1, 8);
for (int i = 0; i < ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource().getMatrix().length; i++) {
for (int j = 0; j < ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource().getMatrix()[i].length; j++) {
assertEquals(((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource().getMatrix()[i][j], ((MixedTransformView<DoubleType>) opr.getSource()).getTransformToSource().getMatrix()[i][j], 1e-10);
}
}
assertEquals(img.numDimensions() - 1, opr.numDimensions());
}
use of net.imglib2.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class InterpolateViewTest method defaultInterpolateTest.
@Test
public void defaultInterpolateTest() {
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());
}
RealRandomAccess<DoubleType> il2 = Views.interpolate(img, new FloorInterpolatorFactory<DoubleType>()).realRandomAccess();
RealRandomAccess<DoubleType> opr = ops.transform().interpolateView(img, new FloorInterpolatorFactory<DoubleType>()).realRandomAccess();
il2.setPosition(new double[] { 1.75, 5.34 });
opr.setPosition(new double[] { 1.75, 5.34 });
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
il2.setPosition(new double[] { 3, 7 });
opr.setPosition(new double[] { 3, 7 });
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
il2.setPosition(new double[] { 8.37, 3.97 });
opr.setPosition(new double[] { 8.37, 3.97 });
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
}
use of net.imglib2.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class InvertAxisViewTest method intervalInvertAxisTest.
@Test
public void intervalInvertAxisTest() {
final Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
final IntervalView<DoubleType> il2 = Views.invertAxis(img, 1);
final IntervalView<DoubleType> opr = ops.transform().invertAxisView(img, 1);
for (int i = 0; i < ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource().getMatrix().length; i++) {
for (int j = 0; j < ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource().getMatrix()[i].length; j++) {
assertEquals(((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource().getMatrix()[i][j], ((MixedTransformView<DoubleType>) opr.getSource()).getTransformToSource().getMatrix()[i][j], 1e-10);
}
}
}
Aggregations