/** * Iterates over every tile in a given pixel buffer based on the * over arching dimensions and a requested maximum tile width and height. * @param iteration Invoker to call for each tile. * @param pixelBuffer Pixel buffer which is backing the pixel data. * @param tileWidth <b>Maximum</b> width of the tile requested. The tile * request itself will be smaller than the original tile width requested if * <code>x + tileWidth > sizeX</code>. * @param tileHeight <b>Maximum</b> height of the tile requested. The tile * request itself will be smaller if <code>y + tileHeight > sizeY</code>. * @throws FailedTileLoopException if the tile loop was aborted; exception bears completed tile count * @return The total number of tiles iterated over. */ public static int forEachTile(TileLoopIteration iteration, PixelBuffer pixelBuffer, int tileWidth, int tileHeight) throws FailedTileLoopException { int sizeX = pixelBuffer.getSizeX(); int sizeY = pixelBuffer.getSizeY(); int sizeZ = pixelBuffer.getSizeZ(); int sizeC = pixelBuffer.getSizeC(); int sizeT = pixelBuffer.getSizeT(); return forEachTile(iteration, sizeX, sizeY, sizeZ, sizeC, sizeT, tileWidth, tileHeight); }
protected int countTiles(Pixels pixels) { final int[] count = new int[] { 0 }; try { ome.io.nio.Utils.forEachTile(new TileLoopIteration() { public void run(int z, int c, int t, int x, int y, int tileWidth, int tileHeight, int tileCount) { count[0]++; } }, pixels.getSizeX(), pixels.getSizeY(), pixels.getSizeZ(), pixels.getSizeC(), pixels.getSizeT(), sizes.getTileWidth(), sizes.getTileHeight()); } catch (FailedTileLoopException ftle) { // impossible, never thrown by run method } return count[0]; }
(Math.ceil(source.getSizeY() / tileSize.getHeight())); final int tenPercent = Math.max((int) totalTiles / 10, 1); Utils.forEachTile(new TileLoopIteration() { public void run(int z, int c, int t, int x, int y, int w, int h, int tileCount) throws FailedTileLoopException