Search in sources :

Example 71 with DoubleType

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

the class IntegralImgTest method testIntegralImageSimilarity.

/**
 * @see DefaultIntegralImg
 * @see SquareIntegralImg
 */
@SuppressWarnings({ "unchecked" })
@Test
public void testIntegralImageSimilarity() {
    RandomAccessibleInterval<LongType> out1 = (RandomAccessibleInterval<LongType>) ops.run(DefaultIntegralImg.class, in);
    RandomAccessibleInterval<DoubleType> out2 = (RandomAccessibleInterval<DoubleType>) ops.run(WrappedIntegralImg.class, in);
    // Remove 0s from integralImg by shifting its interval by +1
    final long[] min = new long[out2.numDimensions()];
    final long[] max = new long[out2.numDimensions()];
    for (int d = 0; d < out2.numDimensions(); ++d) {
        min[d] = out2.min(d) + 1;
        max[d] = out2.max(d);
    }
    // Define the Interval on the infinite random accessibles
    final FinalInterval interval = new FinalInterval(min, max);
    LocalThresholdTest.testIterableIntervalSimilarity(Views.iterable(out1), Views.iterable(Views.offsetInterval(out2, interval)));
}
Also used : LongType(net.imglib2.type.numeric.integer.LongType) RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) DoubleType(net.imglib2.type.numeric.real.DoubleType) FinalInterval(net.imglib2.FinalInterval) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test) LocalThresholdTest(net.imagej.ops.threshold.apply.LocalThresholdTest)

Example 72 with DoubleType

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

the class InvertTest method testDoubleTypeInvert.

@Test
public void testDoubleTypeInvert() {
    final Img<DoubleType> inDoubleType = generateDoubleArrayTestImg(true, 5, 5);
    final Img<DoubleType> outDoubleType = inDoubleType.factory().create(inDoubleType, new DoubleType());
    assertDefaultInvert(inDoubleType, outDoubleType);
    assertDefaultInvertMinMaxProvided(inDoubleType, outDoubleType, new DoubleType(437d), new DoubleType(8008d));
    assertDefaultInvertMinMaxProvided(inDoubleType, outDoubleType, new DoubleType(5d), new DoubleType(Double.MAX_VALUE));
}
Also used : DoubleType(net.imglib2.type.numeric.real.DoubleType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 73 with DoubleType

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

the class UnaryRealTypeMathTest method testArccsch.

@Test
public void testArccsch() {
    final LongType in = new LongType(1234567890);
    final DoubleType out = new DoubleType();
    ops.run(Arccsch.class, out, in);
    final double delta = Math.sqrt(1 + 1 / (1234567890.0 * 1234567890.0));
    assertEquals(out.get(), Math.log(1 / 1234567890.0 + delta), 0.0);
}
Also used : LongType(net.imglib2.type.numeric.integer.LongType) DoubleType(net.imglib2.type.numeric.real.DoubleType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 74 with DoubleType

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

the class UnaryRealTypeMathTest method assertRandomGaussian.

private void assertRandomGaussian(final double i, final double o, final long seed) {
    final DoubleType in = new DoubleType(i);
    final DoubleType out = (DoubleType) ops.run(RandomGaussian.class, in.createVariable(), in, seed);
    assertEquals(o, out.get(), 0);
}
Also used : DoubleType(net.imglib2.type.numeric.real.DoubleType) RandomGaussian(net.imagej.ops.math.UnaryRealTypeMath.RandomGaussian)

Example 75 with DoubleType

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

the class UnaryRealTypeMathTest method testArcsech.

@Test
public void testArcsech() {
    final LongType in = new LongType(1234567890);
    final DoubleType out = new DoubleType();
    ops.run(Arcsech.class, out, in);
    final double numer = 1 + Math.sqrt(1 - 1234567890.0 * 1234567890.0);
    assertEquals(out.get(), Math.log(numer / 1234567890.0), 0.0);
}
Also used : LongType(net.imglib2.type.numeric.integer.LongType) DoubleType(net.imglib2.type.numeric.real.DoubleType) AbstractOpTest(net.imagej.ops.AbstractOpTest) 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