Search in sources :

Example 6 with MixedTransformView

use of net.imglib2.view.MixedTransformView 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());
}
Also used : DoubleType(net.imglib2.type.numeric.real.DoubleType) MixedTransformView(net.imglib2.view.MixedTransformView) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 7 with MixedTransformView

use of net.imglib2.view.MixedTransformView 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);
        }
    }
}
Also used : DoubleType(net.imglib2.type.numeric.real.DoubleType) MixedTransformView(net.imglib2.view.MixedTransformView) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 8 with MixedTransformView

use of net.imglib2.view.MixedTransformView 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);
        }
    }
}
Also used : DoubleType(net.imglib2.type.numeric.real.DoubleType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 9 with MixedTransformView

use of net.imglib2.view.MixedTransformView in project imagej-ops by imagej.

the class PermuteViewTest method testIntervalPermute.

@Test
public void testIntervalPermute() {
    Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
    IntervalView<DoubleType> expected = Views.permute((RandomAccessibleInterval<DoubleType>) img, 1, 0);
    IntervalView<DoubleType> actual = ops.transform().permuteView((RandomAccessibleInterval<DoubleType>) img, 1, 0);
    for (int i = 0; i < ((MixedTransformView<DoubleType>) expected.getSource()).getTransformToSource().getMatrix().length; i++) {
        for (int j = 0; j < ((MixedTransformView<DoubleType>) expected.getSource()).getTransformToSource().getMatrix()[i].length; j++) {
            assertEquals(((MixedTransformView<DoubleType>) expected.getSource()).getTransformToSource().getMatrix()[i][j], ((MixedTransformView<DoubleType>) actual.getSource()).getTransformToSource().getMatrix()[i][j], 1e-10);
        }
    }
}
Also used : DoubleType(net.imglib2.type.numeric.real.DoubleType) MixedTransformView(net.imglib2.view.MixedTransformView) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 10 with MixedTransformView

use of net.imglib2.view.MixedTransformView in project imagej-ops by imagej.

the class TranslateViewTest method defaultTranslateTest.

@Test
public void defaultTranslateTest() {
    Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
    MixedTransformView<DoubleType> il2 = Views.translate(deinterval(img), 2, 5);
    MixedTransformView<DoubleType> opr = ops.transform().translateView(deinterval(img), 2, 5);
    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);
        }
    }
}
Also used : DoubleType(net.imglib2.type.numeric.real.DoubleType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Aggregations

AbstractOpTest (net.imagej.ops.AbstractOpTest)10 DoubleType (net.imglib2.type.numeric.real.DoubleType)10 Test (org.junit.Test)10 MixedTransformView (net.imglib2.view.MixedTransformView)3