use of net.imglib2.interpolation.randomaccess.FloorInterpolatorFactory in project imagej-ops by imagej.
the class RasterViewTest method defaultRasterTest.
@Test
public void defaultRasterTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
Random r = new Random();
for (DoubleType d : img) {
d.set(r.nextDouble());
}
RealRandomAccessible<DoubleType> realImg = Views.interpolate(img, new FloorInterpolatorFactory<DoubleType>());
RandomAccessibleOnRealRandomAccessible<DoubleType> il2 = Views.raster(realImg);
RandomAccessibleOnRealRandomAccessible<DoubleType> opr = ops.transform().rasterView(realImg);
Cursor<DoubleType> il2C = Views.interval(il2, img).localizingCursor();
RandomAccess<DoubleType> oprRA = Views.interval(opr, img).randomAccess();
while (il2C.hasNext()) {
il2C.next();
oprRA.setPosition(il2C);
assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
}
}
use of net.imglib2.interpolation.randomaccess.FloorInterpolatorFactory in project imagej-ops by imagej.
the class InterpolateViewTest method defaultInterpolateTest.
@Test
public void defaultInterpolateTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
Random r = new Random();
for (DoubleType d : img) {
d.set(r.nextDouble());
}
RealRandomAccess<DoubleType> il2 = Views.interpolate(img, new FloorInterpolatorFactory<DoubleType>()).realRandomAccess();
RealRandomAccess<DoubleType> opr = ops.transform().interpolateView(img, new FloorInterpolatorFactory<DoubleType>()).realRandomAccess();
il2.setPosition(new double[] { 1.75, 5.34 });
opr.setPosition(new double[] { 1.75, 5.34 });
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
il2.setPosition(new double[] { 3, 7 });
opr.setPosition(new double[] { 3, 7 });
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
il2.setPosition(new double[] { 8.37, 3.97 });
opr.setPosition(new double[] { 8.37, 3.97 });
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
}
Aggregations