Search in sources :

Example 61 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 Random randomGenerator = new Random();
    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) Random(java.util.Random) DoubleType(net.imglib2.type.numeric.real.DoubleType) CreateImgFromDimsAndType(net.imagej.ops.create.img.CreateImgFromDimsAndType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 62 with DoubleType

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

the class CreateKernelDiffractionTest method testKernelDiffraction.

@Test
public void testKernelDiffraction() {
    final Dimensions dims = new FinalDimensions(10, 10);
    // numerical aperture
    final double NA = 1.4;
    // wavelength
    final double lambda = 610E-09;
    // specimen refractive index
    final double ns = 1.33;
    // immersion refractive index, experimental
    final double ni = 1.5;
    // lateral pixel size
    final double resLateral = 100E-9;
    // axial pixel size
    final double resAxial = 250E-9;
    // position of particle
    final double pZ = 2000E-9D;
    // pixel type of created kernel
    final DoubleType type = new DoubleType();
    final // 
    Img<DoubleType> kernel = ops.create().kernelDiffraction(dims, NA, lambda, ns, ni, resLateral, resAxial, pZ, type);
    final double[] expected = { 0.03298495871588273, 0.04246786111102021, 0.0543588031627261, 0.06650574371357207, 0.07370280610722534, 0.07370280610722534, 0.06650574371357207, 0.0543588031627261, 0.04246786111102021, 0.03298495871588273, 0.04246786111102021, 0.05962205221267819, 0.08320071670150801, 0.10800022978800021, 0.1247473245002288, 0.1247473245002288, 0.10800022978800021, 0.08320071670150801, 0.05962205221267819, 0.04246786111102021, 0.0543588031627261, 0.08320071670150801, 0.1247473245002288, 0.1971468112729564, 0.2691722397359577, 0.2691722397359577, 0.1971468112729564, 0.1247473245002288, 0.08320071670150801, 0.0543588031627261, 0.06650574371357207, 0.10800022978800021, 0.1971468112729564, 0.40090474481128285, 0.6227157103102976, 0.6227157103102976, 0.40090474481128285, 0.1971468112729564, 0.10800022978800021, 0.06650574371357207, 0.07370280610722534, 0.1247473245002288, 0.2691722397359577, 0.6227157103102976, 1.0, 1.0, 0.6227157103102976, 0.2691722397359577, 0.1247473245002288, 0.07370280610722534, 0.07370280610722534, 0.1247473245002288, 0.2691722397359577, 0.6227157103102976, 1.0, 1.0, 0.6227157103102976, 0.2691722397359577, 0.1247473245002288, 0.07370280610722534, 0.06650574371357207, 0.10800022978800021, 0.1971468112729564, 0.40090474481128285, 0.6227157103102976, 0.6227157103102976, 0.40090474481128285, 0.1971468112729564, 0.10800022978800021, 0.06650574371357207, 0.0543588031627261, 0.08320071670150801, 0.1247473245002288, 0.1971468112729564, 0.2691722397359577, 0.2691722397359577, 0.1971468112729564, 0.1247473245002288, 0.08320071670150801, 0.0543588031627261, 0.04246786111102021, 0.05962205221267819, 0.08320071670150801, 0.10800022978800021, 0.1247473245002288, 0.1247473245002288, 0.10800022978800021, 0.08320071670150801, 0.05962205221267819, 0.04246786111102021, 0.03298495871588273, 0.04246786111102021, 0.0543588031627261, 0.06650574371357207, 0.07370280610722534, 0.07370280610722534, 0.06650574371357207, 0.0543588031627261, 0.04246786111102021, 0.03298495871588273 };
    assertArrayEquals(expected, asArray(kernel), 0.0);
}
Also used : FinalDimensions(net.imglib2.FinalDimensions) DoubleType(net.imglib2.type.numeric.real.DoubleType) FinalDimensions(net.imglib2.FinalDimensions) Dimensions(net.imglib2.Dimensions) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 63 with DoubleType

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

the class CopyImgTest method createData.

@Before
public void createData() {
    input = new ArrayImgFactory<DoubleType>().create(new int[] { 120, 100 }, new DoubleType());
    final Random r = new Random(System.currentTimeMillis());
    final Cursor<DoubleType> inc = input.cursor();
    while (inc.hasNext()) {
        inc.next().set(r.nextDouble());
    }
}
Also used : Random(java.util.Random) DoubleType(net.imglib2.type.numeric.real.DoubleType) ArrayImgFactory(net.imglib2.img.array.ArrayImgFactory) Before(org.junit.Before)

Example 64 with DoubleType

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

the class CopyTypeTest method copyTypeWithOutputTest.

@Test
public void copyTypeWithOutputTest() {
    DoubleType out = new DoubleType();
    ops.run(CopyType.class, out, dt);
    assertEquals(dt.get(), out.get(), 0.0);
}
Also used : DoubleType(net.imglib2.type.numeric.real.DoubleType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 65 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)

Aggregations

DoubleType (net.imglib2.type.numeric.real.DoubleType)142 Test (org.junit.Test)114 AbstractOpTest (net.imagej.ops.AbstractOpTest)104 LongType (net.imglib2.type.numeric.integer.LongType)37 Random (java.util.Random)19 Img (net.imglib2.img.Img)9 FinalInterval (net.imglib2.FinalInterval)8 ArrayList (java.util.ArrayList)7 Ops (net.imagej.ops.Ops)7 BitType (net.imglib2.type.logic.BitType)7 UnaryComputerOp (net.imagej.ops.special.computer.UnaryComputerOp)6 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)6 RealLocalizable (net.imglib2.RealLocalizable)6 LocalThresholdMethod (net.imagej.ops.threshold.LocalThresholdMethod)5 FinalDimensions (net.imglib2.FinalDimensions)5 CreateImgFromImg (net.imagej.ops.create.img.CreateImgFromImg)4 Dimensions (net.imglib2.Dimensions)4 UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)4 Module (org.scijava.module.Module)4 CreateImgFromDimsAndType (net.imagej.ops.create.img.CreateImgFromDimsAndType)3