use of net.imglib2.type.numeric.real.DoubleType in project imagej-ops by imagej.
the class RotateViewTest method testDefaultRotate.
@Test
public void testDefaultRotate() {
final Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 20, 10 }, new DoubleType());
final MixedTransformView<DoubleType> il2 = Views.rotate((RandomAccessible<DoubleType>) img, 1, 0);
final MixedTransformView<DoubleType> opr = ops.transform().rotateView(deinterval(img), 1, 0);
for (int i = 0; i < il2.getTransformToSource().getMatrix().length; i++) {
for (int j = 0; j < il2.getTransformToSource().getMatrix()[i].length; j++) {
assertEquals(il2.getTransformToSource().getMatrix()[i][j], opr.getTransformToSource().getMatrix()[i][j], 1e-10);
}
}
}
use of net.imglib2.type.numeric.real.DoubleType in project imagej-ops by imagej.
the class ShearViewTest method ShearIntervalTest.
/**
* Tests {@link ShearViewInterval}.
*/
@Test
public void ShearIntervalTest() {
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.shear(Views.extendZero(img), new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 }), 0, 1).cursor();
RandomAccess<DoubleType> opr = ops.transform().shearView(Views.extendZero(img), 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.type.numeric.real.DoubleType 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.type.numeric.real.DoubleType in project imagej-ops by imagej.
the class SubsampleViewTest method testIntervalSubsampleSteps.
@Test
public void testIntervalSubsampleSteps() {
Img<DoubleType> img = ArrayImgs.doubles(10, 10);
MersenneTwisterFast r = new MersenneTwisterFast(SEED);
for (DoubleType d : img) {
d.set(r.nextDouble());
}
SubsampleIntervalView<DoubleType> expected = Views.subsample((RandomAccessibleInterval<DoubleType>) img, 2, 1);
SubsampleIntervalView<DoubleType> actual = (SubsampleIntervalView<DoubleType>) ops.transform().subsampleView((RandomAccessibleInterval<DoubleType>) img, 2, 1);
Cursor<DoubleType> il2C = Views.interval(expected, new long[] { 0, 0 }, new long[] { 4, 9 }).localizingCursor();
RandomAccess<DoubleType> oprRA = actual.randomAccess();
while (il2C.hasNext()) {
il2C.next();
oprRA.setPosition(il2C);
assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
}
assertTrue(Intervals.equals(expected, actual));
}
use of net.imglib2.type.numeric.real.DoubleType in project imagej-ops by imagej.
the class SubsampleViewTest method defaultSubsampleStepsTest.
@Test
public void defaultSubsampleStepsTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
MersenneTwisterFast r = new MersenneTwisterFast(SEED);
for (DoubleType d : img) {
d.set(r.nextDouble());
}
SubsampleView<DoubleType> il2 = Views.subsample((RandomAccessible<DoubleType>) img, 2, 1);
SubsampleView<DoubleType> opr = ops.transform().subsampleView(img, 2, 1);
Cursor<DoubleType> il2C = Views.interval(il2, new long[] { 0, 0 }, new long[] { 4, 9 }).localizingCursor();
RandomAccess<DoubleType> oprRA = opr.randomAccess();
while (il2C.hasNext()) {
il2C.next();
oprRA.setPosition(il2C);
assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
}
}
Aggregations