Search in sources :

Example 16 with FinalDimensions

use of net.imglib2.FinalDimensions 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 17 with FinalDimensions

use of net.imglib2.FinalDimensions 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)

Example 18 with FinalDimensions

use of net.imglib2.FinalDimensions in project imagej-ops by imagej.

the class CreateLabelingTest method testImageFactory.

@SuppressWarnings("unchecked")
@Test
public void testImageFactory() {
    final Dimensions dim = new FinalDimensions(10, 10, 10);
    assertEquals("Labeling Factory: ", ArrayImgFactory.class, ((Img<?>) ((ImgLabeling<String, ?>) ops.run(DefaultCreateImgLabeling.class, dim, null, new ArrayImgFactory<IntType>())).getIndexImg()).factory().getClass());
    assertEquals("Labeling Factory: ", CellImgFactory.class, ((Img<?>) ((ImgLabeling<String, ?>) ops.run(DefaultCreateImgLabeling.class, dim, null, new CellImgFactory<IntType>())).getIndexImg()).factory().getClass());
}
Also used : FinalDimensions(net.imglib2.FinalDimensions) Img(net.imglib2.img.Img) Dimensions(net.imglib2.Dimensions) FinalDimensions(net.imglib2.FinalDimensions) IntType(net.imglib2.type.numeric.integer.IntType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 19 with FinalDimensions

use of net.imglib2.FinalDimensions in project imagej-ops by imagej.

the class CopyRAITest method createData.

@Before
public void createData() {
    input = new ArrayImgFactory<UnsignedByteType>().create(new int[] { 120, 100 }, new UnsignedByteType());
    final Random r = new Random(System.currentTimeMillis());
    final Cursor<UnsignedByteType> inc = input.cursor();
    while (inc.hasNext()) {
        inc.next().setReal(r.nextDouble() * 255);
    }
    // create
    final long[] start = new long[] { 16, 16, 16 };
    final long[] end = new long[] { 47, 47, 47 };
    // create an input with a cube at the center
    input2 = ops.create().img(new FinalDimensions(size1), new UnsignedByteType());
    // create the same input but force it to be a planar image
    inputPlanar = ops.create().img(new FinalDimensions(size1), new UnsignedByteType(), new PlanarImgFactory<UnsignedByteType>());
    // get centered views
    view = Views.interval(input2, new FinalInterval(start, end));
    viewPlanar = Views.interval(inputPlanar, new FinalInterval(start, end));
    final Cursor<UnsignedByteType> cursor = view.cursor();
    final Cursor<UnsignedByteType> cursorPlanar = viewPlanar.cursor();
    // set every pixel in the view to 100
    while (cursor.hasNext()) {
        cursor.fwd();
        cursorPlanar.fwd();
        cursor.get().setReal(100.0);
        cursorPlanar.get().setReal(100.0);
    }
}
Also used : FinalDimensions(net.imglib2.FinalDimensions) Random(java.util.Random) PlanarImgFactory(net.imglib2.img.planar.PlanarImgFactory) UnsignedByteType(net.imglib2.type.numeric.integer.UnsignedByteType) FinalInterval(net.imglib2.FinalInterval) ArrayImgFactory(net.imglib2.img.array.ArrayImgFactory) Before(org.junit.Before)

Example 20 with FinalDimensions

use of net.imglib2.FinalDimensions in project imagej-ops by imagej.

the class CopyRAITest method copyRAIDifferentSizeTest.

@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void copyRAIDifferentSizeTest() {
    // create a copy op
    final UnaryHybridCF<IntervalView<UnsignedByteType>, RandomAccessibleInterval<UnsignedByteType>> copy = (UnaryHybridCF) Hybrids.unaryCF(ops, CopyRAI.class, RandomAccessibleInterval.class, IntervalView.class);
    assertNotNull(copy);
    final Img<UnsignedByteType> out = ops.create().img(new FinalDimensions(size2), new UnsignedByteType());
    // copy view to output and assert that is equal to the mean of the view
    copy.compute(view, out);
    assertEquals(ops.stats().mean(out).getRealDouble(), 100.0, delta);
    // also try with a planar image
    final Img<UnsignedByteType> outFromPlanar = ops.create().img(new FinalDimensions(size2), new UnsignedByteType());
    copy.compute(viewPlanar, outFromPlanar);
    assertEquals(ops.stats().mean(outFromPlanar).getRealDouble(), 100.0, delta);
}
Also used : FinalDimensions(net.imglib2.FinalDimensions) IntervalView(net.imglib2.view.IntervalView) RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) UnsignedByteType(net.imglib2.type.numeric.integer.UnsignedByteType) UnaryHybridCF(net.imagej.ops.special.hybrid.UnaryHybridCF) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Aggregations

FinalDimensions (net.imglib2.FinalDimensions)20 Dimensions (net.imglib2.Dimensions)9 AbstractOpTest (net.imagej.ops.AbstractOpTest)8 Test (org.junit.Test)8 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)5 Img (net.imglib2.img.Img)5 UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)4 DoubleType (net.imglib2.type.numeric.real.DoubleType)4 CreateImgFromImg (net.imagej.ops.create.img.CreateImgFromImg)3 BitType (net.imglib2.type.logic.BitType)3 ByteType (net.imglib2.type.numeric.integer.ByteType)3 CreateImgFromDimsAndType (net.imagej.ops.create.img.CreateImgFromDimsAndType)2 PadShiftKernelFFTMethods (net.imagej.ops.filter.pad.PadShiftKernelFFTMethods)2 FinalInterval (net.imglib2.FinalInterval)2 Interval (net.imglib2.Interval)2 Point (net.imglib2.Point)2 ArrayImgFactory (net.imglib2.img.array.ArrayImgFactory)2 IntType (net.imglib2.type.numeric.integer.IntType)2 FloatType (net.imglib2.type.numeric.real.FloatType)2 Before (org.junit.Before)2