throw new ImgIOException("Pixel type not supported. " + "Please convert your image to a supported type.");
@Override public RandomAccessibleInterval< T > load( final String fn ) { try { System.out.println( fn ); return opener.openImgs( fn, factory, type ).get( 0 ); } catch ( final ImgIOException e ) { e.printStackTrace(); } return null; } }
throw new ImgIOException("Pixel type not supported. " + "Please convert your image to a supported type.");
/** * Intermediate {@link #writeImg} method. Ensures the given writer has proper * {@link Metadata}, or creates it if possible. */ private Metadata writeImg(final Writer w, final String id, final SCIFIOImgPlus<?> imgPlus, final int imageIndex, final SCIFIOConfig config, final int sliceCount) throws ImgIOException, IncompatibleTypeException { if (w.getMetadata() == null) { if (id == null || id.length() == 0) { throw new ImgIOException( "A Writer with no Metadata was provided, with no way to determine " + "the desired output path. Default value: ImgPlus's source."); } try { populateMeta(w, imgPlus, config, id, imageIndex); } catch (final FormatException e) { throw new ImgIOException(e, "SCIFIO exception when writing to file " + id + ":\n" + e.getMessage()); } catch (final IOException e) { throw new ImgIOException(e, "I/O exception writing to file " + id + ":\n" + e.getMessage()); } } return writeImg(w, imgPlus, imageIndex, sliceCount); }
/** * Intermediate {@link #writeImg} method. Ensures the given writer has proper * {@link Metadata}, or creates it if possible. */ private Metadata writeImg(final Writer w, final String id, final SCIFIOImgPlus<?> imgPlus, final int imageIndex, final SCIFIOConfig config, final int sliceCount) throws ImgIOException, IncompatibleTypeException { if (w.getMetadata() == null) { if (id == null || id.length() == 0) { throw new ImgIOException( "A Writer with no Metadata was provided, with no way to determine " + "the desired output path. Default value: ImgPlus's source."); } try { populateMeta(w, imgPlus, config, id, imageIndex); } catch (final FormatException e) { throw new ImgIOException(e, "SCIFIO exception when writing to file " + id + ":\n" + e.getMessage()); } catch (final IOException e) { throw new ImgIOException(e, "I/O exception writing to file " + id + ":\n" + e.getMessage()); } } return writeImg(w, imgPlus, imageIndex, sliceCount); }
throw new ImgIOException(e); throw new ImgIOException(e); throw new ImgIOException(e);
throw new ImgIOException(e); throw new ImgIOException(e); throw new ImgIOException(e);
throw new ImgIOException(e);
throw new ImgIOException(e);
/** * @param source - the location of the dataset to assess * @return The number of images in the specified dataset. */ @Override public int getImageCount(final String source) throws ImgIOException { try { final Format format = scifio().format().getFormat(source); return format.createParser().parse(source).getImageCount(); } catch (final FormatException e) { throw new ImgIOException(e); } catch (final IOException e) { throw new ImgIOException(e); } }
/** * @param source - the location of the dataset to assess * @return The number of images in the specified dataset. */ @Override public int getImageCount(final String source) throws ImgIOException { try { final Format format = scifio().format().getFormat(source); return format.createParser().parse(source).getImageCount(); } catch (final FormatException e) { throw new ImgIOException(e); } catch (final IOException e) { throw new ImgIOException(e); } }
/** * Entry {@link #writeImg} method. Gathers necessary metadata, creates default * configuration options if needed, and delegates to the appropriate * intermediate {@link #writeImg} method if able. */ private Metadata writeImg(final String id, final Writer w, final SCIFIOImgPlus<?> img, final int imageIndex, SCIFIOConfig config) throws ImgIOException, IncompatibleTypeException { // Create the SCIFIOConfig if needed if (config == null) { config = new SCIFIOConfig(); } final int sliceCount = countSlices(img); if (w == null) { if (id == null || id.length() == 0) { throw new ImgIOException( "No output destination or pre-configured Writer was provided, and" + " no way to determine the desired output path. Default value:" + " ImgPlus's source."); } return writeImg(id, img, imageIndex, config, sliceCount); } return writeImg(w, id, img, imageIndex, config, sliceCount); }
/** * Entry {@link #writeImg} method. Gathers necessary metadata, creates default * configuration options if needed, and delegates to the appropriate * intermediate {@link #writeImg} method if able. */ private Metadata writeImg(final String id, final Writer w, final SCIFIOImgPlus<?> img, final int imageIndex, SCIFIOConfig config) throws ImgIOException, IncompatibleTypeException { // Create the SCIFIOConfig if needed if (config == null) { config = new SCIFIOConfig(); } final int sliceCount = countSlices(img); if (w == null) { if (id == null || id.length() == 0) { throw new ImgIOException( "No output destination or pre-configured Writer was provided, and" + " no way to determine the desired output path. Default value:" + " ImgPlus's source."); } return writeImg(id, img, imageIndex, config, sliceCount); } return writeImg(w, id, img, imageIndex, config, sliceCount); }
/** * @param source - Dataset source to open * @param config - Options object for opening this dataset * @return A Reader initialized to open the specified id */ private Reader createReader(final String source, final SCIFIOConfig config) throws ImgIOException { final boolean computeMinMax = config.imgOpenerIsComputeMinMax(); statusService.showStatus("Initializing " + source); ReaderFilter r = null; try { r = initializeService.initializeReader(source, config); r.enable(ChannelFiller.class); r.enable(PlaneSeparator.class).separate(axesToSplit(r)); if (computeMinMax) r.enable(MinMaxFilter.class); } catch (final FormatException e) { throw new ImgIOException(e); } catch (final IOException e) { throw new ImgIOException(e); } return r; }
/** * @param source - Dataset source to open * @param config - Options object for opening this dataset * @return A Reader initialized to open the specified id */ private Reader createReader(final String source, final SCIFIOConfig config) throws ImgIOException { final boolean computeMinMax = config.imgOpenerIsComputeMinMax(); statusService.showStatus("Initializing " + source); ReaderFilter r = null; try { r = initializeService.initializeReader(source, config); r.enable(ChannelFiller.class); r.enable(PlaneSeparator.class).separate(axesToSplit(r)); if (computeMinMax) r.enable(MinMaxFilter.class); } catch (final FormatException e) { throw new ImgIOException(e); } catch (final IOException e) { throw new ImgIOException(e); } return r; }
/** * @param reader - An initialized {@link Reader} to use for reading image * data. * @param type - The {@link Type} T of the output {@link ImgPlus}, which must * match the typing of the {@link ImgFactory}. * @param config - {@link SCIFIOConfig} to use when opening this dataset * @return - the {@link ImgPlus} or null * @throws ImgIOException if there is a problem reading the image data. */ public <T extends RealType<T> & NativeType<T>> List<SCIFIOImgPlus<T>> openImgs(final Reader reader, final T type, SCIFIOConfig config) throws ImgIOException { if (config == null) { config = new SCIFIOConfig().imgOpenerSetComputeMinMax(true); } final ImgFactoryHeuristic heuristic = getHeuristic(config); ImgFactory<T> imgFactory; try { imgFactory = heuristic.createFactory(reader.getMetadata(), config .imgOpenerGetImgModes(), type); } catch (final IncompatibleTypeException e) { throw new ImgIOException(e); } return openImgs(reader, imgFactory, config); }
/** * @param reader - An initialized {@link Reader} to use for reading image * data. * @param type - The {@link Type} T of the output {@link ImgPlus}, which must * match the typing of the {@link ImgFactory}. * @param config - {@link SCIFIOConfig} to use when opening this dataset * @return - the {@link ImgPlus} or null * @throws ImgIOException if there is a problem reading the image data. */ public <T extends RealType<T> & NativeType<T>> List<SCIFIOImgPlus<T>> openImgs(final Reader reader, final T type, SCIFIOConfig config) throws ImgIOException { if (config == null) { config = new SCIFIOConfig().imgOpenerSetComputeMinMax(true); } final ImgFactoryHeuristic heuristic = getHeuristic(config); ImgFactory<T> imgFactory; try { imgFactory = heuristic.createFactory(reader.getMetadata(), config .imgOpenerGetImgModes(), type); } catch (final IncompatibleTypeException e) { throw new ImgIOException(e); } return openImgs(reader, imgFactory, config); }
/** * @param reader - An initialized {@link Reader} to use for reading image * data. * @param config - {@link SCIFIOConfig} to use when opening this dataset * @return - the {@link ImgPlus} or null * @throws ImgIOException if there is a problem reading the image data. */ @SuppressWarnings({ "unchecked", "rawtypes" }) public List<SCIFIOImgPlus<?>> openImgs(final Reader reader, SCIFIOConfig config) throws ImgIOException { final RealType t = getType(reader); if (config == null) { config = new SCIFIOConfig().imgOpenerSetComputeMinMax(true); } final ImgFactoryHeuristic heuristic = getHeuristic(config); ImgFactory imgFactory; try { if (t instanceof NativeType) { imgFactory = heuristic.createFactory(reader.getMetadata(), // config.imgOpenerGetImgModes(), (NativeType) t); } else return null; } catch (final IncompatibleTypeException e) { throw new ImgIOException(e); } return openImgs(reader, imgFactory, config); }
/** * @param reader - An initialized {@link Reader} to use for reading image * data. * @param config - {@link SCIFIOConfig} to use when opening this dataset * @return - the {@link ImgPlus} or null * @throws ImgIOException if there is a problem reading the image data. */ @SuppressWarnings({ "unchecked", "rawtypes" }) public List<SCIFIOImgPlus<?>> openImgs(final Reader reader, SCIFIOConfig config) throws ImgIOException { final RealType t = getType(reader); if (config == null) { config = new SCIFIOConfig().imgOpenerSetComputeMinMax(true); } final ImgFactoryHeuristic heuristic = getHeuristic(config); ImgFactory imgFactory; try { if (t instanceof NativeType) { imgFactory = heuristic.createFactory(reader.getMetadata(), // config.imgOpenerGetImgModes(), (NativeType) t); } else return null; } catch (final IncompatibleTypeException e) { throw new ImgIOException(e); } return openImgs(reader, imgFactory, config); }
throw new ImgIOException(e); throw new ImgIOException(e); throw new ImgIOException(e);