use of net.imagej.types.UnboundedIntegerType in project imagej-ops by imagej.
the class InvertTest method testUnboundedIntegerTypeInvert.
@Test
public void testUnboundedIntegerTypeInvert() {
final Img<UnboundedIntegerType> inUnboundedIntegerType = generateUnboundedIntegerTypeListTestImg(true, 5, 5);
final Img<UnboundedIntegerType> outUnboundedIntegerType = inUnboundedIntegerType.factory().create(inUnboundedIntegerType, new UnboundedIntegerType());
assertIntegerInvert(inUnboundedIntegerType, outUnboundedIntegerType);
assertIntegerInvertMinMaxProvided(inUnboundedIntegerType, outUnboundedIntegerType, new UnboundedIntegerType(437), new UnboundedIntegerType(8008));
assertIntegerInvertMinMaxProvided(inUnboundedIntegerType, outUnboundedIntegerType, new UnboundedIntegerType(0), new UnboundedIntegerType(1));
}
use of net.imagej.types.UnboundedIntegerType in project imagej-ops by imagej.
the class InvertIIInteger method maxValue.
public static <T extends RealType<T>> T maxValue(T type) {
// TODO: Consider making maxValue an op.
final T max = type.createVariable();
if (max instanceof Unsigned128BitType) {
final Unsigned128BitType t = (Unsigned128BitType) max;
t.set(t.getMaxBigIntegerValue());
} else if (max instanceof UnsignedLongType) {
final UnsignedLongType t = (UnsignedLongType) max;
t.set(t.getMaxBigIntegerValue());
} else if (max instanceof UnboundedIntegerType) {
max.setReal(0);
} else {
max.setReal(type.getMaxValue());
}
return max;
}
use of net.imagej.types.UnboundedIntegerType in project imagej-ops by imagej.
the class AbstractOpTest method generateUnboundedIntegerTypeListTestImg.
public ListImg<UnboundedIntegerType> generateUnboundedIntegerTypeListTestImg(final boolean fill, final long... dims) {
final ListImg<UnboundedIntegerType> l = new ListImgFactory<UnboundedIntegerType>().create(dims, new UnboundedIntegerType());
final BigInteger[] array = new BigInteger[(int) Intervals.numElements(dims)];
RandomAccess<UnboundedIntegerType> ra = l.randomAccess();
if (fill) {
MersenneTwisterFast betterRNG = new MersenneTwisterFast(0xf1eece);
for (int i = 0; i < Intervals.numElements(dims); i++) {
BigInteger val = BigInteger.valueOf(betterRNG.nextLong());
ra.get().set(val);
ra.fwd(0);
}
}
return l;
}
Aggregations