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