Search in sources :

Example 1 with PlanarImgFactory

use of net.imglib2.img.planar.PlanarImgFactory in project imagej-ops by imagej.

the class CopyIITest method createData.

@Before
public void createData() {
    input = new PlanarImgFactory<DoubleType>().create(new int[] { 120, 100 }, new DoubleType());
    final Random r = new Random(System.currentTimeMillis());
    final Cursor<DoubleType> inc = input.cursor();
    while (inc.hasNext()) {
        inc.next().set(r.nextDouble());
    }
}
Also used : Random(java.util.Random) PlanarImgFactory(net.imglib2.img.planar.PlanarImgFactory) DoubleType(net.imglib2.type.numeric.real.DoubleType) Before(org.junit.Before)

Example 2 with PlanarImgFactory

use of net.imglib2.img.planar.PlanarImgFactory 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)

Aggregations

Random (java.util.Random)2 PlanarImgFactory (net.imglib2.img.planar.PlanarImgFactory)2 Before (org.junit.Before)2 FinalDimensions (net.imglib2.FinalDimensions)1 FinalInterval (net.imglib2.FinalInterval)1 ArrayImgFactory (net.imglib2.img.array.ArrayImgFactory)1 UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)1 DoubleType (net.imglib2.type.numeric.real.DoubleType)1