Search in sources :

Example 26 with LongType

use of net.imglib2.type.numeric.integer.LongType in project imagej-ops by imagej.

the class BoxCount method countTranslatedGrids.

/**
 * Count foreground sections in all grids created from the translations
 *
 * @param input N-dimensional binary interval
 * @param translations Stream of translation coordinates in n-dimensions
 * @param sizes Sizes of the interval's dimensions in pixels
 * @param sectionSize Size of a section in the grids
 * @return Foreground sections counted in each grid
 */
private static <B extends BooleanType<B>> LongStream countTranslatedGrids(final RandomAccessibleInterval<B> input, final Stream<long[]> translations, final long[] sizes, final long sectionSize) {
    final int lastDimension = sizes.length - 1;
    final LongType foreground = new LongType();
    final long[] sectionPosition = new long[sizes.length];
    return translations.mapToLong(gridOffset -> {
        foreground.setZero();
        Arrays.fill(sectionPosition, 0);
        countGrid(input, lastDimension, sizes, gridOffset, sectionPosition, sectionSize, foreground);
        return foreground.get();
    });
}
Also used : LongType(net.imglib2.type.numeric.integer.LongType)

Example 27 with LongType

use of net.imglib2.type.numeric.integer.LongType 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 28 with LongType

use of net.imglib2.type.numeric.integer.LongType 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 29 with LongType

use of net.imglib2.type.numeric.integer.LongType 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)

Example 30 with LongType

use of net.imglib2.type.numeric.integer.LongType in project imagej-ops by imagej.

the class UnaryRealTypeMathTest method testSignum.

@Test
public void testSignum() {
    final LongType in = new LongType(1234567890);
    final DoubleType out = new DoubleType();
    ops.run(Signum.class, out, in);
    assertEquals(out.get(), 1.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

LongType (net.imglib2.type.numeric.integer.LongType)50 AbstractOpTest (net.imagej.ops.AbstractOpTest)48 Test (org.junit.Test)48 DoubleType (net.imglib2.type.numeric.real.DoubleType)37 ArrayList (java.util.ArrayList)1 Abs (net.imagej.ops.math.UnaryRealTypeMath.Abs)1 Ceil (net.imagej.ops.math.UnaryRealTypeMath.Ceil)1 Floor (net.imagej.ops.math.UnaryRealTypeMath.Floor)1 Invert (net.imagej.ops.math.UnaryRealTypeMath.Invert)1 MaxConstant (net.imagej.ops.math.UnaryRealTypeMath.MaxConstant)1 MinConstant (net.imagej.ops.math.UnaryRealTypeMath.MinConstant)1 NearestInt (net.imagej.ops.math.UnaryRealTypeMath.NearestInt)1 Negate (net.imagej.ops.math.UnaryRealTypeMath.Negate)1 Round (net.imagej.ops.math.UnaryRealTypeMath.Round)1 Sqr (net.imagej.ops.math.UnaryRealTypeMath.Sqr)1 LocalThresholdTest (net.imagej.ops.threshold.apply.LocalThresholdTest)1 FinalInterval (net.imglib2.FinalInterval)1 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)1 UnsignedLongType (net.imglib2.type.numeric.integer.UnsignedLongType)1