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));
}
}
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);
}
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());
}
}
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);
}
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()));
}
Aggregations