Search in sources :

Example 16 with DoubleType

use of net.imglib2.type.numeric.real.DoubleType in project imagej-ops by imagej.

the class UnshearViewTest method UnshearIntervalTest.

@Test
public void UnshearIntervalTest() {
    Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 2, 2 }, new DoubleType());
    Cursor<DoubleType> imgC = img.cursor();
    while (imgC.hasNext()) {
        imgC.next().set(1);
    }
    Cursor<DoubleType> il2 = Views.unshear(Views.shear(Views.extendZero(img), 0, 1), new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 }), 0, 1).cursor();
    RandomAccess<DoubleType> opr = ops.transform().unshearView(Views.shear(Views.extendZero(img), 0, 1), new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 }), 0, 1).randomAccess();
    while (il2.hasNext()) {
        il2.next();
        opr.setPosition(il2);
        assertEquals(il2.get().get(), opr.get().get(), 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 17 with DoubleType

use of net.imglib2.type.numeric.real.DoubleType in project imagej-ops by imagej.

the class UnshearViewTest method defaultUnshearTest.

@Test
public void defaultUnshearTest() {
    Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 2, 2 }, new DoubleType());
    Cursor<DoubleType> imgC = img.cursor();
    while (imgC.hasNext()) {
        imgC.next().set(1);
    }
    TransformView<DoubleType> il2 = Views.unshear(Views.shear(Views.extendZero(img), 0, 1), 0, 1);
    TransformView<DoubleType> opr = ops.transform().unshearView(Views.shear(Views.extendZero(img), 0, 1), 0, 1);
    Cursor<DoubleType> il2C = Views.interval(il2, new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 })).cursor();
    RandomAccess<DoubleType> oprRA = Views.interval(opr, new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 })).randomAccess();
    while (il2C.hasNext()) {
        il2C.next();
        oprRA.setPosition(il2C);
        assertEquals(il2C.get().get(), oprRA.get().get(), 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 18 with DoubleType

use of net.imglib2.type.numeric.real.DoubleType in project imagej-ops by imagej.

the class OpServiceTest method testOpByName.

/**
 * Tests {@link OpService#op(String, Object...)}.
 */
@Test
public void testOpByName() {
    final DoubleType value = new DoubleType(123.456);
    final Op op = ops.op("test.infinity", value);
    assertSame(InfinityOp.class, op.getClass());
    assertFalse(Double.isInfinite(value.get()));
    op.run();
    assertTrue(Double.isInfinite(value.get()));
}
Also used : DoubleType(net.imglib2.type.numeric.real.DoubleType) Test(org.junit.Test)

Example 19 with DoubleType

use of net.imglib2.type.numeric.real.DoubleType in project imagej-ops by imagej.

the class OpServiceTest method testRunByType.

/**
 * Tests {@link OpService#run(Class, Object...)}.
 */
@Test
public void testRunByType() {
    final DoubleType value = new DoubleType(123.456);
    assertFalse(Double.isInfinite(value.get()));
    final Object result = ops.run(InfinityOp.class, value);
    assertSame(value, result);
    assertTrue(Double.isInfinite(value.get()));
}
Also used : DoubleType(net.imglib2.type.numeric.real.DoubleType) Test(org.junit.Test)

Example 20 with DoubleType

use of net.imglib2.type.numeric.real.DoubleType in project imagej-ops by imagej.

the class OpServiceTest method testOpByType.

/**
 * Tests {@link OpService#op(Class, Object...)}.
 */
@Test
public void testOpByType() {
    final DoubleType value = new DoubleType(123.456);
    final Op op = ops.op(InfinityOp.class, value);
    assertSame(InfinityOp.class, op.getClass());
    assertFalse(Double.isInfinite(value.get()));
    op.run();
    assertTrue(Double.isInfinite(value.get()));
}
Also used : DoubleType(net.imglib2.type.numeric.real.DoubleType) Test(org.junit.Test)

Aggregations

DoubleType (net.imglib2.type.numeric.real.DoubleType)185 Test (org.junit.Test)123 AbstractOpTest (net.imagej.ops.AbstractOpTest)111 LongType (net.imglib2.type.numeric.integer.LongType)37 MersenneTwisterFast (org.scijava.util.MersenneTwisterFast)19 ArrayList (java.util.ArrayList)14 Dataset (net.imagej.Dataset)14 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)13 Img (net.imglib2.img.Img)10 PointSet (net.imglib2.ops.pointset.PointSet)10 Ops (net.imagej.ops.Ops)9 HyperVolumePointSet (net.imglib2.ops.pointset.HyperVolumePointSet)9 Overlay (net.imagej.overlay.Overlay)8 FinalDimensions (net.imglib2.FinalDimensions)8 FinalInterval (net.imglib2.FinalInterval)8 BitType (net.imglib2.type.logic.BitType)8 DatasetView (net.imagej.display.DatasetView)7 Dimensions (net.imglib2.Dimensions)7 UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)7 RealLocalizable (net.imglib2.RealLocalizable)6