Search in sources :

Example 41 with ByteType

use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.

the class MapTest method testIIAndIIInplaceParallel.

@Test
public void testIIAndIIInplaceParallel() {
    final Img<ByteType> first = generateByteArrayTestImg(true, 10, 10);
    final Img<ByteType> firstCopy = first.copy();
    final Img<ByteType> second = generateByteArrayTestImg(false, 10, 10);
    for (final ByteType px : second) px.set((byte) 1);
    final Img<ByteType> secondCopy = second.copy();
    final Img<ByteType> secondDiffDims = generateByteArrayTestImg(false, 10, 10, 2);
    sub = Inplaces.binary(ops, Ops.Math.Subtract.class, ByteType.class);
    final BinaryInplaceOp<? super Img<ByteType>, Img<ByteType>> map = Inplaces.binary(ops, MapIIAndIIInplaceParallel.class, firstCopy, second, sub);
    map.run(firstCopy, second, firstCopy);
    map.run(first, secondCopy, secondCopy);
    assertImgSubEquals(first, second, firstCopy);
    assertImgSubEquals(first, second, secondCopy);
    // Expect exception when in2 has different dimensions
    thrown.expect(IllegalArgumentException.class);
    ops.op(MapIIAndIIInplaceParallel.class, first, secondDiffDims, sub);
}
Also used : Img(net.imglib2.img.Img) Ops(net.imagej.ops.Ops) ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 42 with ByteType

use of net.imglib2.type.numeric.integer.ByteType 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 43 with ByteType

use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.

the class MeanTest method testMean.

@Test
public void testMean() {
    final Img<ByteType> image = generateByteArrayTestImg(true, 40, 50);
    final DoubleType mean = new DoubleType();
    ops.run(IterableMean.class, mean, image);
    assertEquals(1.0 / 15.625, mean.get(), 0.0);
    Cursor<ByteType> c = image.cursor();
    // this time lets just make every value 100
    while (c.hasNext()) {
        c.fwd();
        c.get().setReal(100.0);
    }
    ops.run(IterableMean.class, mean, image);
    // the mean should be 100
    assertEquals(100.0, mean.get(), 0.0);
}
Also used : DoubleType(net.imglib2.type.numeric.real.DoubleType) ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 44 with ByteType

use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.

the class ConcatenateViewTest method concatenateWithAccessModeTest.

@Test
public void concatenateWithAccessModeTest() {
    final List<RandomAccessibleInterval<ByteType>> intervals = createIntervals(img, divider, axis);
    for (final StackAccessMode mode : StackAccessMode.values()) {
        final RandomAccessibleInterval<ByteType> cat1 = Views.concatenate(axis, mode, intervals);
        final RandomAccessibleInterval<ByteType> cat2 = ops.transform().concatenateView(intervals, axis, mode);
        testEqual(cat1, cat2);
    }
}
Also used : StackAccessMode(net.imglib2.view.StackView.StackAccessMode) RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 45 with ByteType

use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.

the class NonLinearFiltersTest method testMeanFilter.

/**
 * @see MeanFilterOp
 * @see DefaultMeanFilter
 */
@Test
public void testMeanFilter() {
    ops.run(MeanFilterOp.class, out, in, shape, oobFactory);
    double sum = 0.0;
    NeighborhoodsIterableInterval<ByteType> neighborhoods = shape.neighborhoods(Views.interval(Views.extendMirrorSingle(in), in));
    for (ByteType t : neighborhoods.firstElement()) {
        sum += t.getRealDouble();
    }
    assertEquals(Util.round(sum / 9.0), out.firstElement().get());
}
Also used : ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Aggregations

ByteType (net.imglib2.type.numeric.integer.ByteType)83 Test (org.junit.Test)78 AbstractOpTest (net.imagej.ops.AbstractOpTest)76 RectangleShape (net.imglib2.algorithm.neighborhood.RectangleShape)55 Img (net.imglib2.img.Img)49 ArrayImg (net.imglib2.img.array.ArrayImg)33 Shape (net.imglib2.algorithm.neighborhood.Shape)18 DiamondShape (net.imglib2.algorithm.neighborhood.DiamondShape)17 HorizontalLineShape (net.imglib2.algorithm.neighborhood.HorizontalLineShape)16 ArrayList (java.util.ArrayList)9 Op (net.imagej.ops.Op)9 IterableInterval (net.imglib2.IterableInterval)9 BitType (net.imglib2.type.logic.BitType)6 UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)6 AbstractUnaryComputerOp (net.imagej.ops.special.computer.AbstractUnaryComputerOp)5 Ops (net.imagej.ops.Ops)4 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)4 IncompatibleTypeException (net.imglib2.exception.IncompatibleTypeException)4 CreateImgFromImg (net.imagej.ops.create.img.CreateImgFromImg)3 MapOp (net.imagej.ops.map.MapOp)3