Search in sources :

Example 21 with DoubleType

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

the class OpServiceTest method testAliases.

/**
 * Tests {@link OpService#run(String, Object...)} with op aliases.
 */
@Test
public void testAliases() {
    final DoubleType value = new DoubleType(123.456);
    assertFalse(Double.isInfinite(value.get()));
    final Object result = ops.run("infin", value);
    assertSame(value, result);
    assertTrue(Double.isInfinite(value.get()));
    value.set(0.0);
    assertFalse(Double.isInfinite(value.get()));
    final Object result2 = ops.run("inf", value);
    assertSame(value, result2);
    assertTrue(Double.isInfinite(value.get()));
    value.set(0.0);
    boolean noSuchAlias = false;
    try {
        ops.run("infini", value);
    } catch (final IllegalArgumentException exc) {
        noSuchAlias = true;
    }
    assertTrue(noSuchAlias);
}
Also used : DoubleType(net.imglib2.type.numeric.real.DoubleType) Test(org.junit.Test)

Example 22 with DoubleType

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

the class CachedOpEnvironmentTest method testOptionalParameter.

@Test
public void testOptionalParameter() {
    UnaryFunctionOp<DoubleType, Object> f = Functions.unary(env, OptionalParameterOp.class, Object.class, DoubleType.class);
    Object result = f.calculate(new DoubleType());
    UnaryFunctionOp<DoubleType, Object> f2 = Functions.unary(env, OptionalParameterOp.class, Object.class, DoubleType.class);
    Object sameResult = f2.calculate(new DoubleType());
    assertSame(result, sameResult);
}
Also used : DoubleType(net.imglib2.type.numeric.real.DoubleType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 23 with DoubleType

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

the class CreateImgTest method testImageDimensions.

@Test
public void testImageDimensions() {
    final MersenneTwisterFast randomGenerator = new MersenneTwisterFast(SEED);
    for (int i = 0; i < TEST_SIZE; i++) {
        // between 2 and 5 dimensions
        final long[] dim = new long[randomGenerator.nextInt(4) + 2];
        // between 2 and 10 pixels per dimensions
        for (int j = 0; j < dim.length; j++) {
            dim[j] = randomGenerator.nextInt(9) + 2;
        }
        // create img
        @SuppressWarnings("unchecked") final Img<DoubleType> img = (Img<DoubleType>) ops.run(CreateImgFromDimsAndType.class, dim, new DoubleType());
        assertArrayEquals("Image Dimensions:", dim, Intervals.dimensionsAsLongArray(img));
    }
}
Also used : CreateImgFromImg(net.imagej.ops.create.img.CreateImgFromImg) Img(net.imglib2.img.Img) MersenneTwisterFast(org.scijava.util.MersenneTwisterFast) DoubleType(net.imglib2.type.numeric.real.DoubleType) CreateImgFromDimsAndType(net.imagej.ops.create.img.CreateImgFromDimsAndType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 24 with DoubleType

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

the class CreateImgTest method testImageFactory.

@Test
public void testImageFactory() {
    final Dimensions dim = new FinalDimensions(10, 10, 10);
    @SuppressWarnings("unchecked") final Img<DoubleType> arrayImg = (Img<DoubleType>) ops.run(CreateImgFromDimsAndType.class, dim, new DoubleType(), new ArrayImgFactory<DoubleType>());
    final Class<?> arrayFactoryClass = arrayImg.factory().getClass();
    assertEquals("Image Factory: ", ArrayImgFactory.class, arrayFactoryClass);
    @SuppressWarnings("unchecked") final Img<DoubleType> cellImg = (Img<DoubleType>) ops.run(CreateImgFromDimsAndType.class, dim, new DoubleType(), new CellImgFactory<DoubleType>());
    final Class<?> cellFactoryClass = cellImg.factory().getClass();
    assertEquals("Image Factory: ", CellImgFactory.class, cellFactoryClass);
}
Also used : FinalDimensions(net.imglib2.FinalDimensions) CreateImgFromImg(net.imagej.ops.create.img.CreateImgFromImg) Img(net.imglib2.img.Img) CellImgFactory(net.imglib2.img.cell.CellImgFactory) DoubleType(net.imglib2.type.numeric.real.DoubleType) CreateImgFromDimsAndType(net.imagej.ops.create.img.CreateImgFromDimsAndType) FinalDimensions(net.imglib2.FinalDimensions) Dimensions(net.imglib2.Dimensions) ArrayImgFactory(net.imglib2.img.array.ArrayImgFactory) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 25 with DoubleType

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

the class MTKTTest method testMTKTpValueAll.

// Second, we test fully correlated datasets (identical).
@Test
public void testMTKTpValueAll() {
    double[][] values = new double[10][2];
    double[] values1 = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };
    double[] values2 = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };
    for (int i = 0; i < 4; i++) {
        values[i][0] = values1[i];
        values[i][1] = values2[i];
    }
    Img<DoubleType> vImage1 = ArrayImgs.doubles(values1, values1.length);
    Img<DoubleType> vImage2 = ArrayImgs.doubles(values2, values2.length);
    BinaryFunctionOp<RandomAccessibleInterval<DoubleType>, RandomAccessibleInterval<DoubleType>, Double> op = Functions.binary(ops, MTKT.class, Double.class, vImage1, vImage2);
    PValueResult value = (PValueResult) ops.run(Ops.Coloc.PValue.class, new PValueResult(), vImage1, vImage2, op, 5);
    assertEquals(0.0, value.getPValue(), 0.0);
}
Also used : PValueResult(net.imagej.ops.coloc.pValue.PValueResult) Ops(net.imagej.ops.Ops) RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) DoubleType(net.imglib2.type.numeric.real.DoubleType) Test(org.junit.Test) ColocalisationTest(net.imagej.ops.coloc.ColocalisationTest)

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