Search in sources :

Example 46 with ArrayImgFactory

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

Example 47 with ArrayImgFactory

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

Example 48 with ArrayImgFactory

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

Example 49 with ArrayImgFactory

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

Example 50 with ArrayImgFactory

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

Aggregations

AbstractOpTest (net.imagej.ops.AbstractOpTest)52 Test (org.junit.Test)52 DoubleType (net.imglib2.type.numeric.real.DoubleType)47 Random (java.util.Random)14 Img (net.imglib2.img.Img)8 FinalInterval (net.imglib2.FinalInterval)7 ArrayImgFactory (net.imglib2.img.array.ArrayImgFactory)7 FloatType (net.imglib2.type.numeric.real.FloatType)6 FinalDimensions (net.imglib2.FinalDimensions)4 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)4 ArrayList (java.util.ArrayList)3 Dimensions (net.imglib2.Dimensions)3 Point (net.imglib2.Point)3 MixedTransformView (net.imglib2.view.MixedTransformView)3 Before (org.junit.Before)3 BinaryFunctionOp (net.imagej.ops.special.function.BinaryFunctionOp)2 UnaryFunctionOp (net.imagej.ops.special.function.UnaryFunctionOp)2 Interval (net.imglib2.Interval)2 ComplexFloatType (net.imglib2.type.numeric.complex.ComplexFloatType)2 ByteType (net.imglib2.type.numeric.integer.ByteType)2