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;
}
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);
}
Aggregations