/** * @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int) */ @Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); return reader.openBytes(no, buf, x, y, w, h); }
/** * @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int) */ @Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); return reader.openBytes(no, buf, x, y, w, h); }
@Override public void run(int z, int c, int t, int x, int y, int tileWidth, int tileHeight, int tileCount) { try { tileCount += theC * 320; int planeNumber = FormatTools.getIndex( "XYZCT", SIZE_Z, SIZE_C, SIZE_T, SIZE_Z * SIZE_C * SIZE_T, z, theC, t); byte[] tile = null; try { tile = reader.openBytes(planeNumber, x, y, tileWidth, tileHeight); } catch (Throwable throwable) { fail(String.format("Failure reading tile z:%d c:%d t:%d " + "x:%d y:%d", z, theC, t, x, y), throwable); } String readDigest = TestTools.md5(tile); String writtenDigest = hashDigests.get(tileCount); if (!writtenDigest.equals(readDigest)) { fail(String.format("Hash digest mismatch z:%d c:%d t:%d " + "x:%d y:%d -- %s != %s", z, theC, t, x, y, writtenDigest, readDigest)); } } catch (Exception e) { throw new RuntimeException(e); } } }, SIZE_X, SIZE_Y, SIZE_Z, 1, SIZE_T, TILE_WIDTH, TILE_HEIGHT);
/** * @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int) */ @Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); int n = no; for (int i=0; i<getSeries(); i++) { n += core.get(i).imageCount; } if (tiffReaders.length == 1) { return tiffReaders[0].openBytes(n, buf, x, y, w, h); } int plane = 0; if (tiffReaders[0].getImageCount() > 1) { n /= tiffReaders.length; plane = n % tiffReaders.length; } if (lastPlane != 0) { tiffReaders[lastPlane].close(); } lastPlane = n; tiffReaders[n].setId(tiffs.get(n)); return tiffReaders[n].openBytes(plane, buf, x, y, w, h); }
/** * @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int) */ @Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); int n = no; for (int i=0; i<getSeries(); i++) { n += core.get(i).imageCount; } if (tiffReaders.length == 1) { return tiffReaders[0].openBytes(n, buf, x, y, w, h); } int plane = 0; if (tiffReaders[0].getImageCount() > 1) { n /= tiffReaders.length; plane = n % tiffReaders.length; } if (lastPlane != 0) { tiffReaders[lastPlane].close(); } lastPlane = n; tiffReaders[n].setId(tiffs.get(n)); return tiffReaders[n].openBytes(plane, buf, x, y, w, h); }
@Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); if (singleTiffMode) return tiff.openBytes(no, buf, x, y, w, h); // convert 1D index to (sequence, index, channel) coordinates. final int[] zct = getZCTCoords(no); final int z = zct[0], c = zct[1], t = zct[2]; final Sequence sequence = sequence(t, getSeries()); final int index = frameIndex(sequence, z, t, getSeries()); final Frame frame = sequence.getFrame(index); if (frame == null) { warnFrame(sequence, index); return blank(buf); } final int channel = channels[c]; final PFile file = frame.getFile(channel); if (file == null) { warnFile(sequence, index, channel); return blank(buf); } tiff.setId(getPath(file)); return tiff.openBytes(0, buf, x, y, w, h); }
@Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); if (singleTiffMode) return tiff.openBytes(no, buf, x, y, w, h); // convert 1D index to (sequence, index, channel) coordinates. final int[] zct = getZCTCoords(no); final int z = zct[0], c = zct[1], t = zct[2]; final Sequence sequence = sequence(t, getSeries()); final int index = frameIndex(sequence, z, t, getSeries()); final Frame frame = sequence.getFrame(index); if (frame == null) { warnFrame(sequence, index); return blank(buf); } final int channel = channels[c]; final PFile file = frame.getFile(channel); if (file == null) { warnFile(sequence, index, channel); return blank(buf); } tiff.setId(getPath(file)); return tiff.openBytes(0, buf, x, y, w, h); }
public static void checkImage(TiffReader reader, Plane originalPlane, boolean interleaved, int rgbChannels, int seriesCount, int sizeT, String compression) throws FormatException, IOException { for (int s=0; s<reader.getSeriesCount(); s++) { reader.setSeries(s); assertEquals(reader.getSizeC(), rgbChannels); int imageCount = reader.isRGB() ? seriesCount * sizeT : rgbChannels * sizeT * seriesCount; assertEquals(reader.getImageCount(), imageCount); for (int image=0; image<reader.getImageCount(); image++) { byte[] readPlane = reader.openBytes(image); boolean lossy = compression.equals(COMPRESSION_JPEG) || compression.equals(COMPRESSION_J2K_LOSSY); boolean isJ2K = compression.equals(COMPRESSION_J2K) || compression.equals(COMPRESSION_J2K_LOSSY); boolean interleavedDiffs = interleaved || (isJ2K && !interleaved); if (!(lossy || interleavedDiffs)) { Plane newPlane = new Plane(readPlane, reader.isLittleEndian(), !reader.isInterleaved(), reader.getRGBChannelCount(), FormatTools.getPixelTypeString(reader.getPixelType())); assert(originalPlane.equals(newPlane)); } } } }
for (int i = 0; i < imageCount; i++) byte[] plane = source.openBytes(i); IFD ifd = new IFD();
for (int j = 0; j < n; j++) { x = w*j; tile = outputReader.openBytes(k, x, y, w, h); writtenDigest = tileMD5s[s][k][(i * n) + j]; readDigest = TestTools.md5(tile);
w = blockWidth; tile = outputReader.openBytes(k, x, y, w, h); writtenDigest = tileMD5s[s][k][(i * n) + j]; readDigest = TestTools.md5(tile);