Search in sources :

Example 11 with Op

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);
}
Also used : Op(net.imagej.ops.Op) BinaryInplaceOp(net.imagej.ops.special.inplace.BinaryInplaceOp) ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 12 with Op

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);
}
Also used : Op(net.imagej.ops.Op) BinaryInplaceOp(net.imagej.ops.special.inplace.BinaryInplaceOp) ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 13 with Op

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);
}
Also used : Op(net.imagej.ops.Op) ARGBDoubleType(net.imglib2.type.numeric.ARGBDoubleType) NumericTypeBinaryMath(net.imagej.ops.math.NumericTypeBinaryMath) NumericTypeBinaryMath(net.imagej.ops.math.NumericTypeBinaryMath) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 14 with Op

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);
}
Also used : Op(net.imagej.ops.Op) BinaryFunctionOp(net.imagej.ops.special.function.BinaryFunctionOp) UnaryFunctionOp(net.imagej.ops.special.function.UnaryFunctionOp) Img(net.imglib2.img.Img) ByteType(net.imglib2.type.numeric.integer.ByteType) ArrayImgFactory(net.imglib2.img.array.ArrayImgFactory) FloatType(net.imglib2.type.numeric.real.FloatType) ComplexFloatType(net.imglib2.type.numeric.complex.ComplexFloatType) Ops(net.imagej.ops.Ops) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 15 with Op

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);
}
Also used : Op(net.imagej.ops.Op)

Aggregations

Op (net.imagej.ops.Op)18 AbstractOpTest (net.imagej.ops.AbstractOpTest)11 Test (org.junit.Test)11 ByteType (net.imglib2.type.numeric.integer.ByteType)9 AbstractUnaryComputerOp (net.imagej.ops.special.computer.AbstractUnaryComputerOp)6 UnaryComputerOp (net.imagej.ops.special.computer.UnaryComputerOp)4 Ops (net.imagej.ops.Ops)3 MapOp (net.imagej.ops.map.MapOp)3 AbstractUnaryInplaceOp (net.imagej.ops.special.inplace.AbstractUnaryInplaceOp)3 BinaryInplaceOp (net.imagej.ops.special.inplace.BinaryInplaceOp)3 UnaryInplaceOp (net.imagej.ops.special.inplace.UnaryInplaceOp)3 RectangleShape (net.imglib2.algorithm.neighborhood.RectangleShape)3 AbstractOp (net.imagej.ops.AbstractOp)2 UnaryFunctionOp (net.imagej.ops.special.function.UnaryFunctionOp)2 FloatType (net.imglib2.type.numeric.real.FloatType)2 Type (java.lang.reflect.Type)1 NumericTypeBinaryMath (net.imagej.ops.math.NumericTypeBinaryMath)1 BinaryFunctionOp (net.imagej.ops.special.function.BinaryFunctionOp)1 UnaryHybridCF (net.imagej.ops.special.hybrid.UnaryHybridCF)1 IncompatibleTypeException (net.imglib2.exception.IncompatibleTypeException)1