use of net.imglib2.FinalInterval in project imagej-ops by imagej.
the class ShearViewTest method defaultShearTest.
/**
* Tests {@link DefaultShearView}.
*/
@Test
public void defaultShearTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 2, 2 }, new DoubleType());
Cursor<DoubleType> imgC = img.cursor();
while (imgC.hasNext()) {
imgC.next().set(1);
}
TransformView<DoubleType> il2 = Views.shear(Views.extendZero(img), 0, 1);
TransformView<DoubleType> opr = ops.transform().shearView(Views.extendZero(img), 0, 1);
Cursor<DoubleType> il2C = Views.interval(il2, new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 })).cursor();
RandomAccess<DoubleType> oprRA = Views.interval(opr, new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 })).randomAccess();
while (il2C.hasNext()) {
il2C.next();
oprRA.setPosition(il2C);
assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
}
}
use of net.imglib2.FinalInterval in project imagej-ops by imagej.
the class UnshearViewTest method defaultUnshearTest.
@Test
public void defaultUnshearTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 2, 2 }, new DoubleType());
Cursor<DoubleType> imgC = img.cursor();
while (imgC.hasNext()) {
imgC.next().set(1);
}
TransformView<DoubleType> il2 = Views.unshear(Views.shear(Views.extendZero(img), 0, 1), 0, 1);
TransformView<DoubleType> opr = ops.transform().unshearView(Views.shear(Views.extendZero(img), 0, 1), 0, 1);
Cursor<DoubleType> il2C = Views.interval(il2, new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 })).cursor();
RandomAccess<DoubleType> oprRA = Views.interval(opr, new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 })).randomAccess();
while (il2C.hasNext()) {
il2C.next();
oprRA.setPosition(il2C);
assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
}
}
use of net.imglib2.FinalInterval in project imagej-ops by imagej.
the class UnshearViewTest method UnshearIntervalTest.
@Test
public void UnshearIntervalTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 2, 2 }, new DoubleType());
Cursor<DoubleType> imgC = img.cursor();
while (imgC.hasNext()) {
imgC.next().set(1);
}
Cursor<DoubleType> il2 = Views.unshear(Views.shear(Views.extendZero(img), 0, 1), new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 }), 0, 1).cursor();
RandomAccess<DoubleType> opr = ops.transform().unshearView(Views.shear(Views.extendZero(img), 0, 1), new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 }), 0, 1).randomAccess();
while (il2.hasNext()) {
il2.next();
opr.setPosition(il2);
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
}
}
use of net.imglib2.FinalInterval in project imagej-ops by imagej.
the class CropTest method testCropTypes.
/**
* Verifies that the types of the objects returned are correct.
*/
@Test
public void testCropTypes() {
// Set-up interval
final Interval defInterval = new FinalInterval(new long[] { 0, 0, 0 }, new long[] { 19, 19, 19 });
final Interval smallerInterval = new FinalInterval(new long[] { 0, 0, 0 }, new long[] { 19, 19, 18 });
// check if result is ImgView
assertTrue(ops.run(CropRAI.class, in, defInterval) instanceof Img);
// check if result is ImgPlus
final Object imgPlus = ops.run(CropImgPlus.class, new ImgPlus<>(in), defInterval);
assertTrue(imgPlus instanceof ImgPlus);
// check if result is RandomAccessibleInterval
final Object run = ops.run(CropRAI.class, Views.interval(in, smallerInterval), smallerInterval);
assertTrue(run instanceof RandomAccessibleInterval && !(run instanceof Img));
}
use of net.imglib2.FinalInterval in project imagej-ops by imagej.
the class AbstractOpTest method generateUnsignedVariableBitLengthTypeArrayTestImg.
public ArrayImg<UnsignedVariableBitLengthType, LongArray> generateUnsignedVariableBitLengthTypeArrayTestImg(final boolean fill, final int nbits, final long... dims) {
final long[] array = new long[(int) Intervals.numElements(new FinalInterval(dims))];
if (fill) {
seed = 17;
for (int i = 0; i < array.length; i++) {
array[i] = (long) (((pseudoRandom() / Integer.MAX_VALUE)) % (Math.pow(2, nbits)));
}
}
final LongArray l = new LongArray(array);
return ArrayImgs.unsignedVariableBitLengths(l, nbits, dims);
}
Aggregations