net.imglib2.img.planar.PlanarImgFactory Java Examples
The following examples show how to use
net.imglib2.img.planar.PlanarImgFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultJsonServiceTest.java From imagej-server with Apache License 2.0 | 6 votes |
@Test public void deserializeSpecialTypes() throws Exception { final LinkedHashMap<String, Object> inputs = new LinkedHashMap<>(); final ByteType type = new ByteType(); final Img<ByteType> img0 = Imgs.create(new ArrayImgFactory<>(type), Intervals.createMinMax(0, 10, 0, 10), type); final Img<ByteType> img1 = Imgs.create(new PlanarImgFactory<>(type), Intervals.createMinMax(0, 10, 0, 10), type); final Foo foo = new Foo("test string"); inputs.put("img0", img0); inputs.put("img1", img1); inputs.put("foo", foo); objectService.register(img0, ""); objectService.register(img1, ""); objectService.register(foo, ""); @SuppressWarnings("unchecked") final Map<String, Object> deserialized = modifiedMapper.readValue(fixture( "fixtures/inputs/specialTypes.json"), Map.class); assertEquals(deserialized, inputs); }
Example #2
Source File: CopyIITest.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
@Before public void createData() { input = new PlanarImgFactory<DoubleType>().create( new int[] { 120, 100 }, new DoubleType()); final MersenneTwisterFast r = new MersenneTwisterFast(System.currentTimeMillis()); final Cursor<DoubleType> inc = input.cursor(); while (inc.hasNext()) { inc.next().set(r.nextDouble()); } }
Example #3
Source File: DefaultJsonServiceTest.java From imagej-server with Apache License 2.0 | 5 votes |
@Test public void serializeSpecialTypes() throws Exception { // MixIns and special types are tested together here. Could separate them if // needed in the future. final LinkedHashMap<String, Object> outputs = new LinkedHashMap<>(); final IntType intType = new IntType(1); final ByteType byteType = new ByteType((byte) 1); final ShortType shortType = new ShortType((short) 1); final LongType longType = new LongType(1L); final FloatType floatType = new FloatType(1.5f); final DoubleType doubleType = new DoubleType(1.5d); final ComplexDoubleType complexDoubleType = new ComplexDoubleType(1.5, 2.5); final Img<ByteType> img0 = Imgs.create(new ArrayImgFactory<>(byteType), Intervals.createMinMax(0, 10, 0, 10), byteType); final Img<ByteType> img1 = Imgs.create(new PlanarImgFactory<>(byteType), Intervals.createMinMax(0, 10, 0, 10), byteType); final Foo foo = new Foo("test string"); outputs.put("intType", intType); outputs.put("byteType", byteType); outputs.put("shortType", shortType); outputs.put("longType", longType); outputs.put("floatType", floatType); outputs.put("doubleType", doubleType); outputs.put("complexDoubleType", complexDoubleType); outputs.put("img0", img0); outputs.put("img1", img1); outputs.put("foo", foo); final String normalized = mapper.writeValueAsString(mapper.readValue( fixture("fixtures/outputs/specialTypes.json"), Object.class)); assertEquals(jsonService.parseObject(outputs), normalized); }
Example #4
Source File: XmlIoSlideBook6ImgLoader.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
@Override public SlideBook6ImgLoader fromXml( final Element elem, File basePath, final AbstractSequenceDescription<?, ?, ?> sequenceDescription ) { try { final File path = loadPath( elem, DIRECTORY_TAG, basePath ); final String masterFile = XmlHelpers.getText( elem, MASTER_FILE_TAG ); final String container = XmlHelpers.getText( elem, IMGLIB2CONTAINER_PATTERN_TAG ); final ImgFactory< FloatType > imgFactory; if ( container == null ) { System.out.println( "WARNING: No Img implementation defined in XML, using ArrayImg." ); // if no factory is defined we define an ArrayImgFactory imgFactory = new ArrayImgFactory< FloatType >(); } else { if ( container.toLowerCase().contains( "cellimg" ) ) { imgFactory = new CellImgFactory< FloatType >( 256 ); } else if ( container.toLowerCase().contains( "arrayimg" ) ) { imgFactory = new ArrayImgFactory< FloatType >(); } else if ( container.toLowerCase().contains( "planarimg" ) ) { imgFactory = new PlanarImgFactory< FloatType >(); } else { // if factory is unknown we define an ArrayImgFactory imgFactory = new ArrayImgFactory< FloatType >(); System.out.println( "WARNING: Unknown Img implementation defined in XML:'" + container + "', using ArrayImg." ); } } return new SlideBook6ImgLoader( new File( path, masterFile ), imgFactory, sequenceDescription ); } catch ( final Exception e ) { throw new RuntimeException( e ); } }
Example #5
Source File: XmlIoLightSheetZ1ImgLoader.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
@Override public LightSheetZ1ImgLoader fromXml( final Element elem, File basePath, final AbstractSequenceDescription<?, ?, ?> sequenceDescription ) { try { final File path = loadPath( elem, DIRECTORY_TAG, basePath ); final String masterFile = XmlHelpers.getText( elem, MASTER_FILE_TAG ); final String container = XmlHelpers.getText( elem, IMGLIB2CONTAINER_PATTERN_TAG ); final ImgFactory< FloatType > imgFactory; if ( container == null ) { System.out.println( "WARNING: No Img implementation defined in XML, using ArrayImg." ); // if no factory is defined we define an ArrayImgFactory imgFactory = new ArrayImgFactory< FloatType >(); } else { if ( container.toLowerCase().contains( "cellimg" ) ) { imgFactory = new CellImgFactory< FloatType >( 256 ); } else if ( container.toLowerCase().contains( "arrayimg" ) ) { imgFactory = new ArrayImgFactory< FloatType >(); } else if ( container.toLowerCase().contains( "planarimg" ) ) { imgFactory = new PlanarImgFactory< FloatType >(); } else { // if factory is unknown we define an ArrayImgFactory imgFactory = new ArrayImgFactory< FloatType >(); System.out.println( "WARNING: Unknown Img implementation defined in XML:'" + container + "', using ArrayImg." ); } } return new LightSheetZ1ImgLoader( new File( path, masterFile ), imgFactory, sequenceDescription ); } catch ( final Exception e ) { throw new RuntimeException( e ); } }
Example #6
Source File: XmlIoStackImgLoader.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
@Override public T fromXml( final Element elem, final File basePath, final AbstractSequenceDescription< ?, ?, ? > sequenceDescription ) { try { File path = loadPath( elem, DIRECTORY_TAG, basePath ); String fileNamePattern = XmlHelpers.getText( elem, FILE_PATTERN_TAG ); int layoutTP = XmlHelpers.getInt( elem, LAYOUT_TP_TAG ); int layoutChannels = XmlHelpers.getInt( elem, LAYOUT_CHANNEL_TAG ); int layoutIllum = XmlHelpers.getInt( elem, LAYOUT_ILLUMINATION_TAG ); int layoutAngles = XmlHelpers.getInt( elem, LAYOUT_ANGLE_TAG ); final String container = XmlHelpers.getText( elem, IMGLIB2CONTAINER_PATTERN_TAG ); ImgFactory< FloatType > imgFactory; if ( container == null ) { System.out.println( "WARNING: No Img implementation defined, using ArrayImg." ); // if no factory is defined we define an ArrayImgFactory imgFactory = new ArrayImgFactory< FloatType >(); } else { if ( container.toLowerCase().contains( "cellimg" ) ) { imgFactory = new CellImgFactory< FloatType >( 256 ); } else if ( container.toLowerCase().contains( "arrayimg" ) ) { imgFactory = new ArrayImgFactory< FloatType >(); } else if ( container.toLowerCase().contains( "planarimg" ) ) { imgFactory = new PlanarImgFactory< FloatType >(); } else { // if factory is unknown we define an ArrayImgFactory imgFactory = new ArrayImgFactory< FloatType >(); System.out.println( "WARNING: Unknown Img implementation '" + container + "', using ArrayImg." ); } } return createImgLoader( path, fileNamePattern, imgFactory, layoutTP, layoutChannels, layoutIllum, layoutAngles, sequenceDescription ); } catch ( final Exception e ) { throw new RuntimeException( e ); } }
Example #7
Source File: DefaultImgFactoryHeuristic.java From scifio with BSD 2-Clause "Simplified" License | 4 votes |
private <T extends NativeType<T>> ImgFactory<T> createNativeFactory( final Metadata m, final ImgMode[] imgModes, final T type) throws IncompatibleTypeException { // Max size of a plane of a PlanarImg, or total dataset for ArrayImg. // 2GB. final long maxSize = ArrayUtils.safeMultiply64(2, 1024, 1024, 1024); final long availableMem = // (long) (MemoryTools.totalAvailableMemory() * MEMORY_THRESHOLD); long datasetSize = m.getDatasetSize(); // check for overflow if (datasetSize <= 0) datasetSize = Long.MAX_VALUE; // divide by 1024 to compare to max_size and avoid overflow final long planeSize = m.get(0).getAxisLength(Axes.X) * // m.get(0).getAxisLength(Axes.Y) * // FormatTools.getBytesPerPixel(m.get(0).getPixelType()); final boolean fitsInMemory = availableMem > datasetSize; // loop over ImgOptions in preferred order final List<ImgMode> modes = new ArrayList<>(Arrays.asList(imgModes)); modes.add(ImgMode.AUTO); for (final ImgMode mode : modes) { switch (mode) { case AUTO: if (!fitsInMemory) return new SCIFIOCellImgFactory<>(type); if (datasetSize < maxSize) return new ArrayImgFactory<>(type); // FIXME: No CellImgFactory right now. // Isn't guaranteed to handle all images well (e.g. RGB). //if (planeSize < maxSize) return new PlanarImgFactory<>(type); //return new CellImgFactory<>(type); return new PlanarImgFactory<>(type); case ARRAY: if (datasetSize < maxSize && fitsInMemory) return new ArrayImgFactory<>(type); break; case PLANAR: if (planeSize < maxSize && fitsInMemory) return new PlanarImgFactory<>(type); break; case CELL: // FIXME: No CellImgFactory right now. // Isn't guaranteed to handle all images well (e.g. RGB). //if (fitsInMemory) return new CellImgFactory<>(type); //return new SCIFIOCellImgFactory<>(type); return new SCIFIOCellImgFactory<>(type); } } // No compatible modes. throw new IncompatibleTypeException(this, "Cannot create ImgFactory of type " + type.getClass().getName()); }