/** * Returns whether a pyramid should be used for the given {@link Pixels}. * This usually implies that this is a "Big image" and therefore will * need tiling. * * @param pixels * @return {@code true} if a pyramid should be used, {@code false} * otherwise */ public boolean requiresPixelsPyramid(Pixels pixels) { String type = pixels.getPixelsType().getValue(); if ("float".equals(type) || "double".equals(type)) return false; final long sizeX = pixels.getSizeX(); final long sizeY = pixels.getSizeY(); final boolean requirePyramid = (sizeX * sizeY) > (sizes.getMaxPlaneWidth()*sizes.getMaxPlaneHeight()); return requirePyramid; }
public synchronized Dimension getTileSize() { if (isWrite()) { return new Dimension(sizes.getTileWidth(), sizes.getTileHeight()); } return delegate().getTileSize(); }
int maxPlaneSize = sizes.getMaxPlaneWidth() * sizes.getMaxPlaneHeight(); if (((long) reader.getSizeX() * (long) reader.getSizeY()) > maxPlaneSize) {
protected double calculate() throws Exception { final String key = String.format("%s.%sX%s", getClass().getName(), sizes.getTileWidth(), sizes.getTileHeight()); StopWatch sw; BufferedImage image; ByteArrayOutputStream stream; long elapsed = 0; for (int i = 0; i < count; i++) { sw = new Slf4JStopWatch(key); JPEG2000CodecOptions options = JPEG2000CodecOptions.getDefaultOptions(); options.lossless = false; options.codeBlockSize = CODE_BLOCK; options.quality = 1.0f; image = new BufferedImage(sizes.getTileWidth(), sizes.getTileHeight(), IMAGE_TYPE); stream = new ByteArrayOutputStream(); service.writeImage(stream, image, options); sw.stop(); elapsed += sw.getElapsedTime(); } return ((double) elapsed) / count; }
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]; }
tileSize = new Dimension(Math.min(pixels.getSizeX(), sizes.getTileWidth()), Math.min(pixels.getSizeY(), sizes.getTileHeight())); || tileDimensionTooSmall) tileSize = new Dimension(Math.min(pixels.getSizeX(), sizes.getTileWidth()), Math.min(pixels.getSizeY(), sizes.getTileHeight()));