Search in sources :

Example 1 with AbstractUnaryComputerOp

use of net.imagej.ops.special.computer.AbstractUnaryComputerOp in project imagej-ops by imagej.

the class InvertIIInteger method compute.

@Override
public void compute(final IterableInterval<T> input, final IterableInterval<T> output) {
    if (mapper == null) {
        final BigInteger minValue = min == null ? (minValue(input.firstElement())).getBigInteger() : min.getBigInteger();
        final BigInteger maxValue = max == null ? (maxValue(input.firstElement())).getBigInteger() : max.getBigInteger();
        final BigInteger minMax = minValue.add(maxValue);
        mapper = Computers.unary(ops(), Ops.Map.class, output, input, new AbstractUnaryComputerOp<T, T>() {

            @Override
            public void compute(T in, T out) {
                BigInteger inverted = minMax.subtract(in.getBigInteger());
                if (inverted.compareTo(minValue(out).getBigInteger()) <= 0)
                    out.set(minValue(out));
                else if (inverted.compareTo(maxValue(out).getBigInteger()) >= 0)
                    out.set(maxValue(out));
                else
                    out.setBigInteger(inverted);
            }
        });
    }
    mapper.compute(input, output);
}
Also used : AbstractUnaryComputerOp(net.imagej.ops.special.computer.AbstractUnaryComputerOp) BigInteger(java.math.BigInteger)

Aggregations

BigInteger (java.math.BigInteger)1 AbstractUnaryComputerOp (net.imagej.ops.special.computer.AbstractUnaryComputerOp)1