/** @deprecated Use {@link io.scif.img.IO#openImg(String, ImgOptions)}. */ public static<T extends RealType<T> & NativeType<T>> Img<T> open(final String pathOrURL) throws ImgIOException, IncompatibleTypeException { return (Img<T>) new ImgOpener().openImg(pathOrURL); // Old: //return wrap(IJ.openImage(pathOrURL)); }
public ArrayImgLoader( final T type ) { opener = new ImgOpener(); factory = new ArrayImgFactory<>(); this.type = type; }
/** @deprecated Use {@link io.scif.img.IO#openImg(String, ImgOptions)}. */ @Deprecated public static<T extends RealType<T> & NativeType<T>> Img<T> openVirtual(final String pathOrUrl) throws ImgIOException, IncompatibleTypeException { return (Img<T>) new ImgOpener().openImg(pathOrUrl, new SCIFIOConfig().imgOpenerSetImgModes( ImgMode.CELL )); }
/** * Creates a new ImgOpener. The first time this method runs, an additional * Context is created and the logService is cached for future logging. * * @return A new ImgOpener instance with its own Context */ private static ImgOpener opener() { final ImgOpener opener = new ImgOpener(); if (logService == null) { synchronized (IO.class) { if (logService == null) { logService = opener.getContext().getService(LogService.class); } } } return opener; }
/** * Creates a new ImgOpener. The first time this method runs, an additional * Context is created and the logService is cached for future logging. * * @return A new ImgOpener instance with its own Context */ private static ImgOpener opener() { final ImgOpener opener = new ImgOpener(); if (logService == null) { synchronized (IO.class) { if (logService == null) { logService = opener.getContext().getService(LogService.class); } } } return opener; }
@Override public List<net.imagej.Dataset> openAll(String source, SCIFIOConfig config) throws IOException { final ArrayList<Dataset> datasetList = new ArrayList<>(); final ImgOpener imageOpener = new ImgOpener(getContext()); try { final List<SCIFIOImgPlus<?>> openImgs = imageOpener.openImgs(source, config); for (int imgId = 0; imgId != openImgs.size(); imgId++) { final SCIFIOImgPlus<?> imgPlus = openImgs.get(imgId); @SuppressWarnings({"rawtypes", "unchecked"}) final Dataset dataset = datasetService.create((ImgPlus) imgPlus); final ImageMetadata imageMeta = imgPlus.getImageMetadata(); updateDataset(dataset, imageMeta); datasetList.add(dataset); } } catch (final ImgIOException exc) { throw new IOException(exc); } return datasetList; }
@Override public List<net.imagej.Dataset> openAll(String source, SCIFIOConfig config) throws IOException { final ArrayList<Dataset> datasetList = new ArrayList<>(); final ImgOpener imageOpener = new ImgOpener(getContext()); try { final List<SCIFIOImgPlus<?>> openImgs = imageOpener.openImgs(source, config); for (int imgId = 0; imgId != openImgs.size(); imgId++) { final SCIFIOImgPlus<?> imgPlus = openImgs.get(imgId); @SuppressWarnings({"rawtypes", "unchecked"}) final Dataset dataset = datasetService.create((ImgPlus) imgPlus); final ImageMetadata imageMeta = imgPlus.getImageMetadata(); updateDataset(dataset, imageMeta); datasetList.add(dataset); } } catch (final ImgIOException exc) { throw new IOException(exc); } return datasetList; }
public LegacyStackImageLoader( final HashMap< ViewId, String > filenames, final boolean useImageJOpener ) { this.filenames = filenames; this.useImageJOpener = useImageJOpener; opener = useImageJOpener ? null : new ImgOpener( new Context( SCIFIOService.class, AppService.class, StatusService.class ) ); factory = new ArrayImgFactory<>(); type = new UnsignedShortType(); }
@Override public Dataset open(final String source, final SCIFIOConfig config) throws IOException { final ImgOpener imageOpener = new ImgOpener(getContext()); try { // TODO openImgs we are only using the first image index in the // SCIFIOConfig.imgOpenerGetRange - so this image index corresponds to the // first ImgPlus in the list returned by the ImgOpener. See // https://github.com/scifio/scifio/issues/259 final SCIFIOImgPlus<?> imgPlus = imageOpener.openImgs(source, config).get(0); @SuppressWarnings({ "rawtypes", "unchecked" }) final Dataset dataset = datasetService.create((ImgPlus) imgPlus); final ImageMetadata imageMeta = imgPlus.getImageMetadata(); updateDataset(dataset, imageMeta); return dataset; } catch (final ImgIOException exc) { throw new IOException(exc); } }
@Override public Dataset open(final String source, final SCIFIOConfig config) throws IOException { final ImgOpener imageOpener = new ImgOpener(getContext()); try { // TODO openImgs we are only using the first image index in the // SCIFIOConfig.imgOpenerGetRange - so this image index corresponds to the // first ImgPlus in the list returned by the ImgOpener. See // https://github.com/scifio/scifio/issues/259 final SCIFIOImgPlus<?> imgPlus = imageOpener.openImgs(source, config).get(0); @SuppressWarnings({ "rawtypes", "unchecked" }) final Dataset dataset = datasetService.create((ImgPlus) imgPlus); final ImageMetadata imageMeta = imgPlus.getImageMetadata(); updateDataset(dataset, imageMeta); return dataset; } catch (final ImgIOException exc) { throw new IOException(exc); } }
final ImgOpener opener = new ImgOpener(context);
public static void main(final String... args) throws ImgIOException { final JFileChooser fileChooser = new JFileChooser(); if (fileChooser.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) return; final File file = fileChooser.getSelectedFile(); final SCIFIO scifio = new SCIFIO(); final List<SCIFIOImgPlus<?>> imgs = // new ImgOpener(scifio.context()).openImgs(file.getAbsolutePath()); System.out.println("Found " + imgs.size() + " images"); for (final SCIFIOImgPlus<?> img : imgs) { System.out.println("\t" + img); } scifio.context().dispose(); } }
private static void convertImg(final File file) throws Exception { final Context c = new Context(); final SCIFIOConfig config = new SCIFIOConfig().imgOpenerSetImgModes(ImgMode.ARRAY); final ImgPlus<?> img = new ImgOpener(c).openImgs(file.getAbsolutePath(), config).get(0); final String outPath = file.getParent() + File.separator + "out_" + img.getName(); new ImgSaver(c).saveImg(outPath, img); c.dispose(); }
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); }
public static void main(final String[] args) throws ImgIOException { final ImgOpener imageOpener = new ImgOpener();
/** * Write an image to memory using the {@link ImgSaver} and verify that the * given {@link ImgPlus} is not corrupted during the process. */ @Test public void testImgPlusIntegrity() throws ImgIOException, IncompatibleTypeException { final ImgOpener o = new ImgOpener(ctx); final ImgSaver s = new ImgSaver(ctx); final SCIFIOConfig config = new SCIFIOConfig().imgOpenerSetImgModes( ImgMode.PLANAR); final ByteArrayHandle bah = new ByteArrayHandle(); locationService.mapFile(out, bah); final SCIFIOImgPlus<?> openImg = o.openImgs(id, config).get(0); final String source = openImg.getSource(); s.saveImg(out, openImg); assertEquals(source, openImg.getSource()); }