Search in sources :

Example 81 with ByteType

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

the class CreateImgTest method testCreateFromRaiDifferentType.

@Test
public void testCreateFromRaiDifferentType() {
    final IntervalView<ByteType> input = Views.interval(PlanarImgs.bytes(10, 10, 10), new FinalInterval(new long[] { 10, 10, 1 }));
    final Img<?> res = (Img<?>) ops.run(CreateImgFromDimsAndType.class, input, new ShortType());
    assertEquals("Image Type: ", ShortType.class, res.firstElement().getClass());
    assertArrayEquals("Image Dimensions: ", Intervals.dimensionsAsLongArray(input), Intervals.dimensionsAsLongArray(res));
    assertEquals("Image Factory: ", ArrayImgFactory.class, res.factory().getClass());
}
Also used : CreateImgFromImg(net.imagej.ops.create.img.CreateImgFromImg) Img(net.imglib2.img.Img) CreateImgFromDimsAndType(net.imagej.ops.create.img.CreateImgFromDimsAndType) ShortType(net.imglib2.type.numeric.integer.ShortType) FinalInterval(net.imglib2.FinalInterval) UnsignedByteType(net.imglib2.type.numeric.integer.UnsignedByteType) ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 82 with ByteType

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

the class CreateImgTest method testImageType.

@Test
public void testImageType() {
    final Dimensions dim = new FinalDimensions(10, 10, 10);
    assertEquals("Image Type: ", BitType.class, ((Img<?>) ops.run(CreateImgFromDimsAndType.class, dim, new BitType())).firstElement().getClass());
    assertEquals("Image Type: ", ByteType.class, ((Img<?>) ops.run(CreateImgFromDimsAndType.class, dim, new ByteType())).firstElement().getClass());
    assertEquals("Image Type: ", UnsignedByteType.class, ((Img<?>) ops.create().img(dim, new UnsignedByteType())).firstElement().getClass());
    assertEquals("Image Type: ", IntType.class, ((Img<?>) ops.run(CreateImgFromDimsAndType.class, dim, new IntType())).firstElement().getClass());
    assertEquals("Image Type: ", FloatType.class, ((Img<?>) ops.run(CreateImgFromDimsAndType.class, dim, new FloatType())).firstElement().getClass());
    assertEquals("Image Type: ", DoubleType.class, ((Img<?>) ops.run(CreateImgFromDimsAndType.class, dim, new DoubleType())).firstElement().getClass());
}
Also used : FinalDimensions(net.imglib2.FinalDimensions) CreateImgFromImg(net.imagej.ops.create.img.CreateImgFromImg) Img(net.imglib2.img.Img) BitType(net.imglib2.type.logic.BitType) CreateImgFromDimsAndType(net.imagej.ops.create.img.CreateImgFromDimsAndType) UnsignedByteType(net.imglib2.type.numeric.integer.UnsignedByteType) DoubleType(net.imglib2.type.numeric.real.DoubleType) FinalDimensions(net.imglib2.FinalDimensions) Dimensions(net.imglib2.Dimensions) UnsignedByteType(net.imglib2.type.numeric.integer.UnsignedByteType) ByteType(net.imglib2.type.numeric.integer.ByteType) IntType(net.imglib2.type.numeric.integer.IntType) FloatType(net.imglib2.type.numeric.real.FloatType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 83 with ByteType

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

the class CreateImgTest method testImgFromImg.

@Test
public void testImgFromImg() {
    // create img
    final Img<ByteType> img = ops.create().img(new FinalDimensions(1), new ByteType());
    @SuppressWarnings("unchecked") final Img<ByteType> newImg = (Img<ByteType>) ops.run(CreateImgFromImg.class, img);
    // should both be ByteType. New Img shouldn't be DoubleType (default)
    assertEquals(img.firstElement().getClass(), newImg.firstElement().getClass());
}
Also used : FinalDimensions(net.imglib2.FinalDimensions) CreateImgFromImg(net.imagej.ops.create.img.CreateImgFromImg) Img(net.imglib2.img.Img) CreateImgFromImg(net.imagej.ops.create.img.CreateImgFromImg) UnsignedByteType(net.imglib2.type.numeric.integer.UnsignedByteType) 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