use of net.imagej.ops.Op in project imagej-ops by imagej.
the class MapTest method testII.
@Test
public void testII() {
final Img<ByteType> in = generateByteArrayTestImg(true, 10, 10);
final Op nullary = Computers.nullary(ops, Ops.Math.Zero.class, ByteType.class);
ops.run(MapNullaryII.class, in, nullary);
for (final ByteType ps : in) assertEquals(ps.get(), 0);
}
use of net.imagej.ops.Op in project imagej-ops by imagej.
the class MapTest method testIICellImg.
// -- Test with CellImg --
@Test
public void testIICellImg() {
final Img<ByteType> in = generateByteTestCellImg(true, 40, 20);
final Op nullary = Computers.nullary(ops, Ops.Math.Zero.class, ByteType.class);
ops.run(MapNullaryII.class, in, nullary);
for (final ByteType ps : in) assertEquals(ps.get(), 0);
}
use of net.imagej.ops.Op in project imagej-ops by imagej.
the class AddNumericTypeBinaryMathAddTest method testAdd.
@Test
public void testAdd() {
final ARGBDoubleType a = new ARGBDoubleType(255, 128, 128, 128);
final ARGBDoubleType b = new ARGBDoubleType(255, 75, 35, 45);
final Op op = ops.op(Ops.Math.Add.class, a, a, b);
assertSame(NumericTypeBinaryMath.Add.class, op.getClass());
op.run();
assertEquals(203.0, a.getR(), DELTA);
assertEquals(163.0, a.getG(), DELTA);
assertEquals(173.0, a.getB(), DELTA);
}
use of net.imagej.ops.Op in project imagej-ops by imagej.
the class ConvolveTest method testConvolveMethodSelection.
/**
* Tests that the correct convolver is selected when using a small kernel.
*/
@Test
public void testConvolveMethodSelection() {
final Img<ByteType> in = new ArrayImgFactory<ByteType>().create(new int[] { 20, 20 }, new ByteType());
// use a small kernel
int[] kernelSize = new int[] { 3, 3 };
Img<FloatType> kernel = new ArrayImgFactory<FloatType>().create(kernelSize, new FloatType());
Op op = ops.op(Ops.Filter.Convolve.class, in, kernel);
// we should get ConvolveNaive
assertSame(ConvolveNaiveF.class, op.getClass());
// make sure it runs
@SuppressWarnings("unchecked") final Img<FloatType> out1 = (Img<FloatType>) ops.run(ConvolveNaiveF.class, in, kernel);
assertEquals(out1.dimension(0), 20);
// use a bigger kernel
kernelSize = new int[] { 30, 30 };
kernel = new ArrayImgFactory<FloatType>().create(kernelSize, new FloatType());
op = ops.op(Ops.Filter.Convolve.class, in, kernel);
// this time we should get ConvolveFFT
assertSame(ConvolveFFTF.class, op.getClass());
// make sure it runs
@SuppressWarnings("unchecked") final Img<FloatType> out2 = (Img<FloatType>) ops.run(ConvolveFFTF.class, in, kernel);
assertEquals(out2.dimension(0), 20);
}
use of net.imagej.ops.Op in project imagej-ops by imagej.
the class InvertTest method assertDefaultInvertMinMaxProvided.
private <T extends RealType<T>> void assertDefaultInvertMinMaxProvided(final Img<T> in, final Img<T> out, final T min, final T max) {
final Op op = ops.op(Ops.Image.Invert.class, out, in, (min), (max));
assertSame(InvertII.class, op.getClass());
op.run();
defaultCompare(in, out, min, max);
}
Aggregations