use of net.imglib2.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class InvertAxisViewTest method defaultInvertAxisTest.
@Test
public void defaultInvertAxisTest() {
final Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
final MixedTransformView<DoubleType> il2 = Views.invertAxis((RandomAccessible<DoubleType>) img, 1);
final MixedTransformView<DoubleType> opr = ops.transform().invertAxisView(deinterval(img), 1);
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 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.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class PermuteViewTest method defaultPermuteTest.
@Test
public void defaultPermuteTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
MixedTransformView<DoubleType> il2 = Views.permute((RandomAccessible<DoubleType>) img, 1, 0);
MixedTransformView<DoubleType> opr = ops.transform().permuteView(deinterval(img), 1, 0);
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 RasterViewTest method defaultRasterTest.
@Test
public void defaultRasterTest() {
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());
}
RealRandomAccessible<DoubleType> realImg = Views.interpolate(img, new FloorInterpolatorFactory<DoubleType>());
RandomAccessibleOnRealRandomAccessible<DoubleType> il2 = Views.raster(realImg);
RandomAccessibleOnRealRandomAccessible<DoubleType> opr = ops.transform().rasterView(realImg);
Cursor<DoubleType> il2C = Views.interval(il2, img).localizingCursor();
RandomAccess<DoubleType> oprRA = Views.interval(opr, img).randomAccess();
while (il2C.hasNext()) {
il2C.next();
oprRA.setPosition(il2C);
assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
}
}
use of net.imglib2.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class RotateViewTest method testDefaultRotate.
@Test
public void testDefaultRotate() {
final Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 20, 10 }, new DoubleType());
final MixedTransformView<DoubleType> il2 = Views.rotate((RandomAccessible<DoubleType>) img, 1, 0);
final MixedTransformView<DoubleType> opr = ops.transform().rotateView(deinterval(img), 1, 0);
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);
}
}
}
Aggregations