/** Converts the given reader into a ChannelMerger, wrapping if needed. */ public static ChannelMerger makeChannelMerger(IFormatReader r) { if (r instanceof ChannelMerger) return (ChannelMerger) r; return new ChannelMerger(r); }
@Override public int getSize() { if (reader.getCurrentFile() == null) return 0; reader.setSeries(series); if (merge) return new ChannelMerger(reader).getImageCount(); return planeIndexes == null ? reader.getImageCount() : planeIndexes.length; }
@Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.assertId(getCurrentFile(), true, 2); if (!canMerge()) return super.openBytes(no, buf, x, y, w, h); int sizeC = getSizeC(); int[] nos = getZCTCoords(no); int z = nos[0], t = nos[2]; for (int c=0; c<sizeC; c++) { byte[] b = reader.openBytes(reader.getIndex(z, c, t), x, y, w, h); System.arraycopy(b, 0, buf, c * b.length, b.length); } return buf; }
@Override public int getImageCount() { FormatTools.assertId(getCurrentFile(), true, 2); int no = reader.getImageCount(); if (canMerge()) no /= getSizeC(); return no; }
@Override public byte[] openBytes(int no, int x, int y, int w, int h) throws FormatException, IOException { int bpp = FormatTools.getBytesPerPixel(getPixelType()); int ch = getRGBChannelCount(); byte[] newBuffer = DataTools.allocate(w, h, ch, bpp); return openBytes(no, newBuffer, x, y, w, h); }
@Override public boolean isIndexed() { FormatTools.assertId(getCurrentFile(), true, 2); return !canMerge() && reader.isIndexed(); }
if (merge) pos = new ChannelMerger(reader).getZCTCoords(sliceIndex); int[] cachePos = FormatTools.rasterToPosition(len, sliceIndex); ImageProcessor ip = null;
subC = new int[] {r.getSizeC()}; if (merge) subC = new int[] {new ChannelMerger(r).getEffectiveSizeC()}; len = new int[subC.length + 2]; System.arraycopy(subC, 0, len, 0, subC.length);
/** * Returns the image number in the original dataset that corresponds to the * given image number. * * @param no is an image number greater than or equal to 0 and less than * getImageCount() * @return the corresponding image number in the original (unmerged) data. */ public int getOriginalIndex(int no) throws FormatException, IOException { int imageCount = getImageCount(); int originalCount = reader.getImageCount(); if (imageCount == originalCount) return no; int[] coords = getZCTCoords(no); return reader.getIndex(coords[0], coords[1], coords[2]); }
if (merge) pos = new ChannelMerger(reader).getZCTCoords(sliceIndex); int[] cachePos = FormatTools.rasterToPosition(len, sliceIndex); ImageProcessor ip = null;
subC = new int[] {r.getSizeC()}; if (merge) subC = new int[] {new ChannelMerger(r).getEffectiveSizeC()}; len = new int[subC.length + 2]; System.arraycopy(subC, 0, len, 0, subC.length);
@Override public boolean isInterleaved() { FormatTools.assertId(getCurrentFile(), true, 2); return canMerge() ? false : reader.isInterleaved(); }
/** * Returns the image number in the original dataset that corresponds to the * given image number. * * @param no is an image number greater than or equal to 0 and less than * getImageCount() * @return the corresponding image number in the original (unmerged) data. */ public int getOriginalIndex(int no) throws FormatException, IOException { int imageCount = getImageCount(); int originalCount = reader.getImageCount(); if (imageCount == originalCount) return no; int[] coords = getZCTCoords(no); return reader.getIndex(coords[0], coords[1], coords[2]); }
@Override public int getImageCount() { FormatTools.assertId(getCurrentFile(), true, 2); int no = reader.getImageCount(); if (canMerge()) no /= getSizeC(); return no; }
@Override public byte[] openBytes(int no, int x, int y, int w, int h) throws FormatException, IOException { int bpp = FormatTools.getBytesPerPixel(getPixelType()); int ch = getRGBChannelCount(); byte[] newBuffer = DataTools.allocate(w, h, ch, bpp); return openBytes(no, newBuffer, x, y, w, h); }
/** Converts the given reader into a ChannelMerger, wrapping if needed. */ public static ChannelMerger makeChannelMerger(IFormatReader r) { if (r instanceof ChannelMerger) return (ChannelMerger) r; return new ChannelMerger(r); }
@Override public int getSize() { if (reader.getCurrentFile() == null) return 0; reader.setSeries(series); if (merge) return new ChannelMerger(reader).getImageCount(); return planeIndexes == null ? reader.getImageCount() : planeIndexes.length; }
@Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.assertId(getCurrentFile(), true, 2); if (!canMerge()) return super.openBytes(no, buf, x, y, w, h); int sizeC = getSizeC(); int[] nos = getZCTCoords(no); int z = nos[0], t = nos[2]; for (int c=0; c<sizeC; c++) { byte[] b = reader.openBytes(reader.getIndex(z, c, t), x, y, w, h); System.arraycopy(b, 0, buf, c * b.length, b.length); } return buf; }
@Override public boolean isIndexed() { FormatTools.assertId(getCurrentFile(), true, 2); return !canMerge() && reader.isIndexed(); }
fileReader = new ChannelMerger(new FileStitcher()); myReader = new BufferedImageReader(fileReader); fileWriter = new ImageWriter();