コード例 #1
0
  @Test(dependsOnMethods = {"testMetadataLevel"})
  public void testMetadataLevelEquivilentPlaneData() throws FormatException, IOException {
    for (int i = 0; i < minimalWrapper.getSeriesCount(); i++) {
      minimalWrapper.setSeries(i);
      wrapper.setSeries(i);
      assertEquals(wrapper.getImageCount(), minimalWrapper.getImageCount());
      for (int j = 0; j < minimalWrapper.getImageCount(); j++) {
        byte[] pixelsOnlyPlane = minimalWrapper.openBytes(j);
        String pixelsOnlySHA1 = sha1(pixelsOnlyPlane);
        byte[] allPlane = wrapper.openBytes(j);
        String allSHA1 = sha1(allPlane);

        if (!pixelsOnlySHA1.equals(allSHA1)) {
          fail(
              String.format(
                  "MISMATCH: Series:%d Image:%d PixelsOnly%s All:%s",
                  i, j, pixelsOnlySHA1, allSHA1));
        }
      }
    }
  }
コード例 #2
0
 /**
  * Read a plane and update the pixels checksum
  *
  * @param size Sizes of the Pixels set.
  * @param z The Z-section offset to write to.
  * @param c The channel offset to write to.
  * @param t The timepoint offset to write to.
  * @param bytesPerPixel Number of bytes per pixel.
  * @param fileName Name of the file.
  * @param md Current Pixels set message digest.
  * @throws FormatException If there is an error reading Pixel data via Bio-Formats.
  * @throws IOException If there is an I/O error reading Pixel data via Bio-Formats.
  */
 private void parseDataByPlane(
     ImportSize size, int z, int c, int t, int bytesPerPixel, String fileName, MessageDigest md)
     throws FormatException, IOException {
   int tileHeight = reader.getOptimalTileHeight();
   int tileWidth = reader.getOptimalTileWidth();
   int planeNumber, x, y, w, h;
   for (int tileOffsetY = 0;
       tileOffsetY < (size.sizeY + tileHeight - 1) / tileHeight;
       tileOffsetY++) {
     for (int tileOffsetX = 0;
         tileOffsetX < (size.sizeX + tileWidth - 1) / tileWidth;
         tileOffsetX++) {
       x = tileOffsetX * tileWidth;
       y = tileOffsetY * tileHeight;
       w = tileWidth;
       h = tileHeight;
       if ((x + tileWidth) > size.sizeX) {
         w = size.sizeX - x;
       }
       if ((y + tileHeight) > size.sizeY) {
         h = size.sizeY - y;
       }
       int bytesToRead = w * h * bytesPerPixel;
       if (arrayBuf.length != bytesToRead) {
         arrayBuf = new byte[bytesToRead];
       }
       planeNumber = reader.getIndex(z, c, t);
       if (log.isDebugEnabled()) {
         log.debug(
             String.format(
                 "Plane:%d X:%d Y:%d TileWidth:%d TileHeight:%d " + "arrayBuf.length:%d",
                 planeNumber, x, y, w, h, arrayBuf.length));
       }
       arrayBuf = reader.openBytes(planeNumber, arrayBuf, x, y, w, h);
       try {
         md.update(arrayBuf);
       } catch (Exception e) {
         // This better not happen. :)
         throw new RuntimeException(e);
       }
     }
   }
 }