/** * @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); helperReader.openBytes(no, buf, x, y, w, h); return buf; }
/** * @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); helperReader.openBytes(no, buf, x, y, w, h); return buf; }
/** * @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 { if (Location.getMappedFile(entryName) == null) { initFile(currentId); } reader.setId(entryName); 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 { if (Location.getMappedFile(entryName) == null) { initFile(currentId); } reader.setId(entryName); return reader.openBytes(no, buf, x, y, w, h); }
@Test(dependsOnMethods={"testSetId"}) public void testPlaneData() throws FormatException, IOException { for (int i=0; i<pixelsOnly.getSeriesCount(); i++) { pixelsOnly.setSeries(i); all.setSeries(i); noOverlays.setSeries(i); assertEquals(all.getImageCount(), pixelsOnly.getImageCount()); assertEquals(all.getImageCount(), noOverlays.getImageCount()); for (int j=0; j<pixelsOnly.getImageCount(); j++) { byte[] pixelsOnlyPlane = pixelsOnly.openBytes(j); String pixelsOnlySHA1 = sha1(pixelsOnlyPlane); byte[] allPlane = all.openBytes(j); String allSHA1 = sha1(allPlane); byte[] noOverlaysPlane = noOverlays.openBytes(j); String noOverlaysSHA1 = sha1(noOverlaysPlane); if (!pixelsOnlySHA1.equals(allSHA1)) { fail(String.format("MISMATCH: Series:%d Image:%d PixelsOnly%s All:%s", i, j, pixelsOnlySHA1, allSHA1)); } if (!noOverlaysSHA1.equals(allSHA1)) { fail(String.format("MISMATCH: Series:%d Image:%d PixelsOnly%s All:%s", i, j, noOverlaysSHA1, allSHA1)); } } } }
@Test public void testLosslessPixels() throws Exception { int failureCount = 0; for (int i=0; i<files.size(); i++) { ImageReader reader = new ImageReader(); reader.setId(files.get(i)); byte[] plane = reader.openBytes(0); if (plane[0] != pixels[i][0]) { LOGGER.debug("FAILED on {}", pixels[i][0]); failureCount++; } reader.close(); } assertEquals(failureCount, 0); }
@Test public void testEquivalentPixels16Bit() throws Exception { ImageReader reader = new ImageReader(); reader.setId(FILE_16); byte[] plane = reader.openBytes(0); assertEquals(plane.length, PIXELS_16.length); for (int q=0; q<plane.length; q++) { assertEquals(plane[q], PIXELS_16[q]); } reader.close(); }
private void parseROIs(MetadataStore store) throws FormatException, IOException { String roiID = MetadataTools.createLSID("ROI", 0, 0); String maskID = MetadataTools.createLSID("Shape", 0, 0); store.setROIID(roiID, 0); store.setMaskID(maskID, 0, 0); String positionData = DataTools.readFile(roiDrawFile); String[] coordinates = positionData.split("[ ,]"); double x1 = Double.parseDouble(coordinates[1]); double y1 = Double.parseDouble(coordinates[2]); double x2 = Double.parseDouble(coordinates[3]); double y2 = Double.parseDouble(coordinates[5]); store.setMaskX(x1, 0, 0); store.setMaskY(y1, 0, 0); store.setMaskWidth(x2 - x1, 0, 0); store.setMaskHeight(y2 - y1, 0, 0); store.setImageROIRef(roiID, 0, 0); ImageReader roiReader = new ImageReader(); roiReader.setId(roiFile); byte[] roiPixels = roiReader.openBytes(0); roiReader.close(); BitWriter bits = new BitWriter(roiPixels.length / 8); for (int i=0; i<roiPixels.length; i++) { bits.write(roiPixels[i] == 0 ? 0 : 1, 1); } store.setMaskBinData(bits.toByteArray(), 0, 0); }
private void parseROIs(MetadataStore store) throws FormatException, IOException { String roiID = MetadataTools.createLSID("ROI", 0, 0); String maskID = MetadataTools.createLSID("Shape", 0, 0); store.setROIID(roiID, 0); store.setMaskID(maskID, 0, 0); String positionData = DataTools.readFile(roiDrawFile); String[] coordinates = positionData.split("[ ,]"); double x1 = Double.parseDouble(coordinates[1]); double y1 = Double.parseDouble(coordinates[2]); double x2 = Double.parseDouble(coordinates[3]); double y2 = Double.parseDouble(coordinates[5]); store.setMaskX(x1, 0, 0); store.setMaskY(y1, 0, 0); store.setMaskWidth(x2 - x1, 0, 0); store.setMaskHeight(y2 - y1, 0, 0); store.setImageROIRef(roiID, 0, 0); ImageReader roiReader = new ImageReader(); roiReader.setId(roiFile); byte[] roiPixels = roiReader.openBytes(0); roiReader.close(); BitWriter bits = new BitWriter(roiPixels.length / 8); for (int i=0; i<roiPixels.length; i++) { bits.write(roiPixels[i] == 0 ? 0 : 1, 1); } store.setMaskBinData(bits.toByteArray(), 0, 0); }
@Test public void testEquivalentPixels8Bit() throws Exception { ImageReader reader = new ImageReader(); reader.setId(FILE_8); byte[] plane = reader.openBytes(0); assertEquals(plane.length, PIXELS_8.length); for (int q=0; q<plane.length; q++) { assertEquals(plane[q], PIXELS_8[q]); } reader.close(); }
return helper.openBytes(no, buf, x, y, w, h);
return helper.openBytes(no, buf, x, y, w, h);
assertTrue(reader.getImageCount() == rgbChannels || reader.isRGB()); byte[] readPlane = reader.openBytes(0);
byte[] plane = reader.openBytes(0); for (int q=0; q<plane.length; q++) { if (plane[q] != pixels[q]) {