/** * Test that ImgSaver writes each plane of a multi-plane PlanarImg correctly */ @Test public void testPlanarPlaneSaving() throws ImgIOException, IncompatibleTypeException { final SCIFIOConfig config = new SCIFIOConfig().imgOpenerSetImgModes( ImgMode.PLANAR); testPlaneSavingForConfig(config); }
private void testPlaneSavingForConfig(final SCIFIOConfig config) throws ImgIOException, IncompatibleTypeException { final ImgOpener o = new ImgOpener(ctx); final ImgSaver s = new ImgSaver(ctx); // write the image final SCIFIOImgPlus<UnsignedByteType> before = o.openImgs(id, new UnsignedByteType(), config).get(0); s.saveImg(out, before); // re-read the written image and check for consistency final SCIFIOImgPlus<UnsignedByteType> after = o.openImgs(out, new UnsignedByteType()).get(0); assertImagesEqual(before, after); }
private static <T> void assertImagesEqual(final ImgPlus<T> expected, final ImgPlus<T> actual) { // check dimensional lengths final long[] eDims = new long[expected.numDimensions()]; expected.dimensions(eDims); final long[] aDims = new long[actual.numDimensions()]; actual.dimensions(aDims); assertArrayEquals(eDims, aDims); // check dimensional axes final CalibratedAxis[] eAxes = new CalibratedAxis[expected.numDimensions()]; expected.axes(eAxes); final CalibratedAxis[] aAxes = new CalibratedAxis[actual.numDimensions()]; actual.axes(aAxes); assertArrayEquals(eAxes, aAxes); // check pixels assertIterationsEqual(expected, actual); }
/** * Test that ImgSaver writes each plane of a multi-plane CellImg correctly */ @Test public void testCellPlaneSaving() throws ImgIOException, IncompatibleTypeException { final SCIFIOConfig config = new SCIFIOConfig().imgOpenerSetImgModes( ImgMode.CELL); testPlaneSavingForConfig(config); }
/** * Test that ImgSaver writes each plane of a multi-plane ArrayImg correctly */ @Test public void testArrayPlaneSaving() throws ImgIOException, IncompatibleTypeException { final SCIFIOConfig config = new SCIFIOConfig().imgOpenerSetImgModes( ImgMode.ARRAY); testPlaneSavingForConfig(config); }