net.imglib2.type.numeric.integer.LongType Java Examples

The following examples show how to use net.imglib2.type.numeric.integer.LongType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: N5TypesTest.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testType() {
	final Set<DataType> toBeTested = Stream.of(DataType.values()).collect(Collectors.toSet());
	final Set<DataType> wasTested = new HashSet<>();
	testAndLogNativeTypeForType(DataType.FLOAT32, FloatType.class, wasTested);
	testAndLogNativeTypeForType(DataType.FLOAT64, DoubleType.class, wasTested);
	testAndLogNativeTypeForType(DataType.INT8, ByteType.class, wasTested);
	testAndLogNativeTypeForType(DataType.INT16, ShortType.class, wasTested);
	testAndLogNativeTypeForType(DataType.INT32, IntType.class, wasTested);
	testAndLogNativeTypeForType(DataType.INT64, LongType.class, wasTested);
	testAndLogNativeTypeForType(DataType.UINT8, UnsignedByteType.class, wasTested);
	testAndLogNativeTypeForType(DataType.UINT16, UnsignedShortType.class, wasTested);
	testAndLogNativeTypeForType(DataType.UINT32, UnsignedIntType.class, wasTested);
	testAndLogNativeTypeForType(DataType.UINT64, UnsignedLongType.class, wasTested);
	Assert.assertEquals(toBeTested, wasTested);
}
 
Example #2
Source File: IntegralImgTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * @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)));
}
 
Example #3
Source File: AbstractIntegralImg.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void initialize() {
	if (in() != null) {
		slicewiseOps = new UnaryComputerOp[in().numDimensions()];

		for (int i = 0; i < in().numDimensions(); ++i) {
			slicewiseOps[i] = Computers.unary(ops(), Slice.class,
				RandomAccessibleInterval.class, RandomAccessibleInterval.class,
				getComputer(i), i);
		}
	}

	createLongRAI = Functions.unary(ops(), Ops.Create.Img.class,
		RandomAccessibleInterval.class, Dimensions.class, new LongType());
	createDoubleRAI = Functions.unary(ops(), Ops.Create.Img.class,
		RandomAccessibleInterval.class, Dimensions.class, new DoubleType());
}
 
Example #4
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testTanh() {
	final LongType in = new LongType(1234567890);
	final DoubleType out = new DoubleType();
	ops.run(Tanh.class, out, in);
	assertEquals(out.get(), Math.tanh(1234567890), 0.0);
}
 
Example #5
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testMax() {
	final LongType in = new LongType(LARGE_NUM);
	final LongType out = (LongType) ops.run(MaxConstant.class, in
		.createVariable(), in, LARGE_NUM + 1.0);
	assertEquals(out.get(), LARGE_NUM - 1);
}
 
Example #6
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testMin() {
	final LongType in = new LongType(LARGE_NUM);
	final LongType out = (LongType) ops.run(MinConstant.class, in
		.createVariable(), in, LARGE_NUM - 1.0);
	assertEquals(out.get(), LARGE_NUM - 1);
}
 
Example #7
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testNearestInt() {
	final LongType in = new LongType(LARGE_NUM);
	final LongType out = (LongType) ops.run(NearestInt.class, in
		.createVariable(), in);
	assertEquals(out.get(), LARGE_NUM - 1);
}
 
Example #8
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testNegate() {
	final LongType in = new LongType(-LARGE_NUM);
	final LongType out = (LongType) ops.run(Negate.class, in.createVariable(),
		in);
	assertEquals(out.get(), LARGE_NUM - 1);
}
 
Example #9
Source File: LBP2dFeatureTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testLbp2d() {
	@SuppressWarnings("unchecked")
	final ArrayList<LongType> hist = (ArrayList<LongType>) ops.run(
		DefaultLBP2D.class, random, 1, 4);

	// Test values proved by calculating small toy example by hand.
	assertEquals(Ops.LBP.LBP2D.NAME, 5412.0, hist.get(0).getRealDouble(), 1e-3);
	assertEquals(Ops.LBP.LBP2D.NAME, 0.0, hist.get(1).getRealDouble(), 1e-3);
	assertEquals(Ops.LBP.LBP2D.NAME, 4251.0, hist.get(2).getRealDouble(), 1e-3);
	assertEquals(Ops.LBP.LBP2D.NAME, 337.0, hist.get(3).getRealDouble(), 1e-3);
	
}
 
Example #10
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testSqrt() {
	final LongType in = new LongType(1234567890);
	final DoubleType out = new DoubleType();
	ops.run(Sqrt.class, out, in);
	assertEquals(out.get(), Math.sqrt(1234567890), 0.0);
}
 
Example #11
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testTan() {
	final LongType in = new LongType(1234567890);
	final DoubleType out = new DoubleType();
	ops.run(Tan.class, out, in);
	assertEquals(out.get(), Math.tan(1234567890), 0.0);
}
 
Example #12
Source File: AbstractOpTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ArrayImg<LongType, LongArray> generateLongArrayTestImg(
	final boolean fill, final long... dims)
{
	final long[] array = new long[(int) Intervals.numElements(new FinalInterval(
		dims))];

	if (fill) {
		seed = 17;
		for (int i = 0; i < array.length; i++) {
			array[i] = (long) (pseudoRandom() / Integer.MAX_VALUE);
		}
	}

	return ArrayImgs.longs(array, dims);
}
 
Example #13
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testUlp() {
	final LongType in = new LongType(LARGE_NUM);
	final DoubleType out = new DoubleType();
	ops.run(Ulp.class, out, in);
	assertEquals(out.get(), 2.0, 0.0);
}
 
Example #14
Source File: SquareIntegralImgTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * @see SquareIntegralImg
 */
@SuppressWarnings({ "unchecked" })
@Test
public void testSquareIntegralImageCorrectness() {
	RandomAccessibleInterval<LongType> out1 =
		(RandomAccessibleInterval<LongType>) ops.run(SquareIntegralImg.class,
			generateKnownByteArrayTestImg());

	Img<ByteType> bytes = generateKnownSquareIntegralImage();

	LocalThresholdTest.testIterableIntervalSimilarity(Views.iterable(bytes),
		Views.iterable(out1));
}
 
Example #15
Source File: InvertTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testLongTypeInvert() {
	final Img<LongType> inLongType = generateLongArrayTestImg(true, 5, 5);
	final Img<LongType> outLongType = inLongType.factory().create(inLongType,
		new LongType());
	assertIntegerInvert(inLongType, outLongType);
	assertIntegerInvertMinMaxProvided(inLongType, outLongType, new LongType(
		3025), new LongType(3846));
}
 
Example #16
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testSqr() {
	final LongType in = new LongType(94906267L);
	final LongType out = (LongType) ops.run(Sqr.class, in.createVariable(), in);
	// NB: for any odd number greater than LARGE_NUM - 1, its double
	// representation is not exact.
	assertEquals(out.get(), 94906267L * 94906267L - 1);
}
 
Example #17
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testReciprocal() {
	final LongType in = new LongType(1234567890);
	final DoubleType out = new DoubleType();
	ops.run(Reciprocal.class, out, in, 0.0);
	assertEquals(out.get(), 1.0 / 1234567890, 0.0);
}
 
Example #18
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testLogOnePlusX() {
	final LongType in = new LongType(1234567890);
	final DoubleType out = new DoubleType();
	ops.run(LogOnePlusX.class, out, in);
	assertEquals(out.get(), Math.log1p(1234567890), 0.0);
}
 
Example #19
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testLog2() {
	final LongType in = new LongType(1234567890);
	final DoubleType out = new DoubleType();
	ops.run(Log2.class, out, in);
	assertEquals(out.get(), Math.log(1234567890) / Math.log(2), 0.0);
}
 
Example #20
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testLog10() {
	final LongType in = new LongType(1234567890);
	final DoubleType out = new DoubleType();
	ops.run(Log10.class, out, in);
	assertEquals(out.get(), Math.log10(1234567890), 0.0);
}
 
Example #21
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testLog() {
	final LongType in = new LongType(1234567890);
	final DoubleType out = new DoubleType();
	ops.run(Log.class, out, in);
	assertEquals(out.get(), Math.log(1234567890), 0.0);
}
 
Example #22
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testInvert() {
	final LongType in = new LongType(LARGE_NUM);
	final LongType out = (LongType) ops.run(Invert.class, in.createVariable(),
		in, 9007199254740992.0, 9007199254740994.0);
	assertEquals(out.get(), LARGE_NUM + 1);
}
 
Example #23
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testFloor() {
	final LongType in = new LongType(LARGE_NUM);
	final LongType out = (LongType) ops.run(Floor.class, in.createVariable(),
		in);
	assertEquals(out.get(), LARGE_NUM - 1);
}
 
Example #24
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testExpMinusOne() {
	final LongType in = new LongType(1234567890);
	final DoubleType out = new DoubleType();
	ops.run(ExpMinusOne.class, out, in);
	assertEquals(out.get(), Math.exp(1234567890) - 1, 0.0);
}
 
Example #25
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testExp() {
	final LongType in = new LongType(1234567890);
	final DoubleType out = new DoubleType();
	ops.run(Exp.class, out, in);
	assertEquals(out.get(), Math.exp(1234567890), 0.0);
}
 
Example #26
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testCubeRoot() {
	final LongType in = new LongType(1234567890);
	final DoubleType out = new DoubleType();
	ops.run(CubeRoot.class, out, in);
	assertEquals(out.get(), Math.cbrt(1234567890), 0.0);
}
 
Example #27
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testCsch() {
	final LongType in = new LongType(1234567890);
	final DoubleType out = new DoubleType();
	ops.run(Csch.class, out, in);
	assertEquals(out.get(), 1 / Math.sinh(1234567890), 0.0);
}
 
Example #28
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testCsc() {
	final LongType in = new LongType(1234567890);
	final DoubleType out = new DoubleType();
	ops.run(Csc.class, out, in);
	assertEquals(out.get(), 1 / Math.sin(1234567890), 0.0);
}
 
Example #29
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testCoth() {
	final LongType in = new LongType(1234567890);
	final DoubleType out = new DoubleType();
	ops.run(Coth.class, out, in);
	assertEquals(out.get(), 1 / Math.tanh(1234567890), 0.0);
}
 
Example #30
Source File: UnaryRealTypeMathTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testCot() {
	final LongType in = new LongType(1234567890);
	final DoubleType out = new DoubleType();
	ops.run(Cot.class, out, in);
	assertEquals(out.get(), 1 / Math.tan(1234567890), 0.0);
}