Search in sources :

Example 1 with UnaryHybridCF

use of net.imagej.ops.special.hybrid.UnaryHybridCF in project imagej-ops by imagej.

the class CachedOpEnvironment method op.

@Override
public Op op(final OpRef ref) {
    final Op op = super.op(ref);
    for (final Class<?> ignored : ignoredOps) {
        for (final Type t : ref.getTypes()) {
            // FIXME: Use generic assignability test, once it exists.
            final Class<?> raw = GenericUtils.getClass(t);
            if (ignored.isAssignableFrom(raw)) {
                return op;
            }
        }
    }
    final Op cachedOp;
    if (op instanceof UnaryHybridCF) {
        cachedOp = wrapUnaryHybrid((UnaryHybridCF<?, ?>) op);
    } else if (op instanceof UnaryFunctionOp) {
        cachedOp = wrapUnaryFunction((UnaryFunctionOp<?, ?>) op);
    } else
        return op;
    getContext().inject(cachedOp);
    return cachedOp;
}
Also used : Op(net.imagej.ops.Op) AbstractOp(net.imagej.ops.AbstractOp) UnaryFunctionOp(net.imagej.ops.special.function.UnaryFunctionOp) Type(java.lang.reflect.Type) UnaryHybridCF(net.imagej.ops.special.hybrid.UnaryHybridCF) UnaryFunctionOp(net.imagej.ops.special.function.UnaryFunctionOp)

Example 2 with UnaryHybridCF

use of net.imagej.ops.special.hybrid.UnaryHybridCF in project imagej-ops by imagej.

the class CopyRAITest method copyRAIDifferentSizeTest.

@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void copyRAIDifferentSizeTest() {
    // create a copy op
    final UnaryHybridCF<IntervalView<UnsignedByteType>, RandomAccessibleInterval<UnsignedByteType>> copy = (UnaryHybridCF) Hybrids.unaryCF(ops, CopyRAI.class, RandomAccessibleInterval.class, IntervalView.class);
    assertNotNull(copy);
    final Img<UnsignedByteType> out = ops.create().img(new FinalDimensions(size2), new UnsignedByteType());
    // copy view to output and assert that is equal to the mean of the view
    copy.compute(view, out);
    assertEquals(ops.stats().mean(out).getRealDouble(), 100.0, delta);
    // also try with a planar image
    final Img<UnsignedByteType> outFromPlanar = ops.create().img(new FinalDimensions(size2), new UnsignedByteType());
    copy.compute(viewPlanar, outFromPlanar);
    assertEquals(ops.stats().mean(outFromPlanar).getRealDouble(), 100.0, delta);
}
Also used : FinalDimensions(net.imglib2.FinalDimensions) IntervalView(net.imglib2.view.IntervalView) RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) UnsignedByteType(net.imglib2.type.numeric.integer.UnsignedByteType) UnaryHybridCF(net.imagej.ops.special.hybrid.UnaryHybridCF) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Aggregations

UnaryHybridCF (net.imagej.ops.special.hybrid.UnaryHybridCF)2 Type (java.lang.reflect.Type)1 AbstractOp (net.imagej.ops.AbstractOp)1 AbstractOpTest (net.imagej.ops.AbstractOpTest)1 Op (net.imagej.ops.Op)1 UnaryFunctionOp (net.imagej.ops.special.function.UnaryFunctionOp)1 FinalDimensions (net.imglib2.FinalDimensions)1 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)1 UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)1 IntervalView (net.imglib2.view.IntervalView)1 Test (org.junit.Test)1