Search in sources :

Example 41 with ArrayImgFactory

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

Example 42 with ArrayImgFactory

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

Example 43 with ArrayImgFactory

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

Example 44 with ArrayImgFactory

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

Example 45 with ArrayImgFactory

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);
        }
    }
}
Also used : DoubleType(net.imglib2.type.numeric.real.DoubleType) MixedTransformView(net.imglib2.view.MixedTransformView) 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