use of net.imglib2.img.array.ArrayImgFactory 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.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class CollapseViewTest method defaultCollapseTest.
@Test
public void defaultCollapseTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
CompositeIntervalView<DoubleType, ? extends GenericComposite<DoubleType>> il2 = Views.collapse(img);
CompositeIntervalView<DoubleType, ? extends GenericComposite<DoubleType>> opr = ops.transform().collapseView(img);
assertEquals(il2.numDimensions(), opr.numDimensions());
}
use of net.imglib2.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class ExtendRandomViewTest method extendRandomTest.
@Test
public void extendRandomTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
OutOfBounds<DoubleType> il2 = Views.extendRandom(img, 0, 0).randomAccess();
OutOfBounds<DoubleType> opr = ops.transform().extendRandomView(img, 0, 0).randomAccess();
il2.setPosition(new int[] { -1, -1 });
opr.setPosition(new int[] { -1, -1 });
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
il2.setPosition(new int[] { 11, 11 });
opr.setPosition(new int[] { 11, 11 });
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
}
use of net.imglib2.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class ExtendValueViewTest method extendValueTest.
@Test
public void extendValueTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
OutOfBounds<DoubleType> il2 = Views.extendValue(img, new DoubleType(0)).randomAccess();
OutOfBounds<DoubleType> opr = ops.transform().extendValueView(img, new DoubleType(0)).randomAccess();
il2.setPosition(new int[] { -1, -1 });
opr.setPosition(new int[] { -1, -1 });
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
il2.setPosition(new int[] { 11, 11 });
opr.setPosition(new int[] { 11, 11 });
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
}
use of net.imglib2.img.array.ArrayImgFactory in project imagej-ops by imagej.
the class ConvolveTest method testConvolveMethodSelection.
/**
* Tests that the correct convolver is selected when using a small kernel.
*/
@Test
public void testConvolveMethodSelection() {
final Img<ByteType> in = new ArrayImgFactory<ByteType>().create(new int[] { 20, 20 }, new ByteType());
// use a small kernel
int[] kernelSize = new int[] { 3, 3 };
Img<FloatType> kernel = new ArrayImgFactory<FloatType>().create(kernelSize, new FloatType());
Op op = ops.op(Ops.Filter.Convolve.class, in, kernel);
// we should get ConvolveNaive
assertSame(ConvolveNaiveF.class, op.getClass());
// make sure it runs
@SuppressWarnings("unchecked") final Img<FloatType> out1 = (Img<FloatType>) ops.run(ConvolveNaiveF.class, in, kernel);
assertEquals(out1.dimension(0), 20);
// use a bigger kernel
kernelSize = new int[] { 30, 30 };
kernel = new ArrayImgFactory<FloatType>().create(kernelSize, new FloatType());
op = ops.op(Ops.Filter.Convolve.class, in, kernel);
// this time we should get ConvolveFFT
assertSame(ConvolveFFTF.class, op.getClass());
// make sure it runs
@SuppressWarnings("unchecked") final Img<FloatType> out2 = (Img<FloatType>) ops.run(ConvolveFFTF.class, in, kernel);
assertEquals(out2.dimension(0), 20);
}
Aggregations