Search in sources :

Example 1 with UnboundedIntegerType

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));
}
Also used : UnboundedIntegerType(net.imagej.types.UnboundedIntegerType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 2 with UnboundedIntegerType

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;
}
Also used : UnboundedIntegerType(net.imagej.types.UnboundedIntegerType) UnsignedLongType(net.imglib2.type.numeric.integer.UnsignedLongType) Unsigned128BitType(net.imglib2.type.numeric.integer.Unsigned128BitType)

Example 3 with UnboundedIntegerType

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;
}
Also used : UnboundedIntegerType(net.imagej.types.UnboundedIntegerType) MersenneTwisterFast(org.scijava.util.MersenneTwisterFast) BigInteger(java.math.BigInteger)

Aggregations

UnboundedIntegerType (net.imagej.types.UnboundedIntegerType)3 BigInteger (java.math.BigInteger)1 AbstractOpTest (net.imagej.ops.AbstractOpTest)1 Unsigned128BitType (net.imglib2.type.numeric.integer.Unsigned128BitType)1 UnsignedLongType (net.imglib2.type.numeric.integer.UnsignedLongType)1 Test (org.junit.Test)1 MersenneTwisterFast (org.scijava.util.MersenneTwisterFast)1