Search in sources :

Example 1 with ByteType

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

the class DefaultCoarsenessFeature method mean.

/**
 * Apply mean filter with given size of reactangle shape
 *
 * @param input
 *            Input image
 * @param i
 *            Size of rectangle shape
 * @return Filered mean image
 */
@SuppressWarnings("unchecked")
private Img<I> mean(final RandomAccessibleInterval<I> input, final int i) {
    long[] dims = new long[input.numDimensions()];
    input.dimensions(dims);
    final byte[] array = new byte[(int) Intervals.numElements(new FinalInterval(dims))];
    Img<I> meanImg = (Img<I>) ArrayImgs.unsignedBytes(array, dims);
    OutOfBoundsMirrorFactory<ByteType, Img<ByteType>> oobFactory = new OutOfBoundsMirrorFactory<>(Boundary.SINGLE);
    ops().run(MeanFilterOp.class, meanImg, input, new RectangleShape(i, true), oobFactory);
    return meanImg;
}
Also used : Img(net.imglib2.img.Img) RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) FinalInterval(net.imglib2.FinalInterval) ByteType(net.imglib2.type.numeric.integer.ByteType) OutOfBoundsMirrorFactory(net.imglib2.outofbounds.OutOfBoundsMirrorFactory)

Example 2 with ByteType

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

the class InvertTest method testByteTypeInvert.

@Test
public void testByteTypeInvert() {
    final Img<ByteType> inByteType = generateByteArrayTestImg(true, 5, 5);
    final Img<ByteType> outByteType = inByteType.factory().create(inByteType, new ByteType());
    assertDefaultInvert(inByteType, outByteType);
    assertDefaultInvertMinMaxProvided(inByteType, outByteType, new ByteType((byte) 0), new ByteType((byte) 0));
    assertDefaultInvertMinMaxProvided(inByteType, outByteType, new ByteType((byte) 20), new ByteType((byte) 10));
    assertDefaultInvertMinMaxProvided(inByteType, outByteType, new ByteType((byte) 256), new ByteType((byte) 256));
}
Also used : UnsignedByteType(net.imglib2.type.numeric.integer.UnsignedByteType) ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 3 with ByteType

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

the class NormalizeTest method testNormalize.

@Test
public void testNormalize() {
    Img<ByteType> in = generateByteArrayTestImg(true, 5, 5);
    Img<ByteType> out = in.factory().create(in, new ByteType());
    ops.run(NormalizeIIComputer.class, out, in);
    final Pair<ByteType, ByteType> minMax2 = ops.stats().minMax(out);
    assertEquals(minMax2.getA().get(), Byte.MIN_VALUE);
    assertEquals(minMax2.getB().get(), Byte.MAX_VALUE);
    final IterableInterval<ByteType> lazyOut = ops.image().normalize(in);
    final IterableInterval<ByteType> notLazyOut = ops.image().normalize(in, null, null, null, null, false);
    final Cursor<ByteType> outCursor = out.cursor();
    final Cursor<ByteType> lazyCursor = lazyOut.cursor();
    final Cursor<ByteType> notLazyCursor = notLazyOut.cursor();
    while (outCursor.hasNext()) {
        assertEquals(outCursor.next().get(), lazyCursor.next().get());
        assertEquals(outCursor.get().get(), notLazyCursor.next().get());
    }
}
Also used : ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 4 with ByteType

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

the class MapNeighborhoodTest method testMapNeighborhoodsAccess.

/**
 * Test if every neighborhood pixel of the image was really accessed during
 * the map operation.
 *
 * @see DefaultMapNeighborhood
 */
@Test
public void testMapNeighborhoodsAccess() {
    final Op mapOp = ops.op(DefaultMapNeighborhood.class, out, in, new RectangleShape(1, false), new CountNeighbors());
    mapOp.run();
    for (final ByteType t : out) {
        assertEquals(9, t.get());
    }
}
Also used : AbstractUnaryComputerOp(net.imagej.ops.special.computer.AbstractUnaryComputerOp) Op(net.imagej.ops.Op) RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 5 with ByteType

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

the class MapNeighborhoodTest method testMapNeighborhoodsWithCenterAccess.

/**
 * Test if every neighborhood pixel of the image was really accessed during
 * the map operation.
 *
 * @see MapNeighborhoodWithCenter
 */
@Test
public void testMapNeighborhoodsWithCenterAccess() {
    final Op mapOp = ops.op(MapNeighborhoodWithCenter.class, out, in, new RectangleShape(1, false), new CountNeighborsWithCenter());
    mapOp.run();
    for (final ByteType t : out) {
        assertEquals(9, t.get());
    }
    for (final ByteType t : in) {
        assertEquals(9, t.get());
    }
}
Also used : AbstractUnaryComputerOp(net.imagej.ops.special.computer.AbstractUnaryComputerOp) Op(net.imagej.ops.Op) RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) 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