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