JAIUtils { public static Dimension computePreferredTileSize(int imageWidth, int imageHeight, int granularity) { return new Dimension(computePreferredTileSize(imageWidth, granularity), computePreferredTileSize(imageHeight, granularity)); }  static void setDefaultTileCacheCapacity(int megabytes); static RenderedOp createTileFormatOp(RenderedImage img, int tileWidth, int tileHeight); static TiledImage createTiledImage(float[] data,
                                              int width,
                                              int height); static TiledImage createTiledImage(float[][] data,
                                              int width,
                                              int height,
                                              int numBands); static TiledImage createTiledImage(Raster raster); static PlanarImage createPlanarImage(WritableRaster raster); static RenderedOp createColorToGrayOp(RenderedImage src); static double[][] getExtrema(RenderedImage src); static double[] getExtrema(RenderedImage src,
                                      double[] extrema); static RenderedOp createScaleOp(RenderedImage src,
                                           double xScale,
                                           double yScale,
                                           double xTrans,
                                           double yTrans,
                                           Interpolation ip); static RenderedOp createRectifyOp(RenderedImage src,
                                             int degree,
                                             RectificationGrid grid,
                                             Interpolation interp); static RenderedOp createRescaleOp(RenderedImage src,
                                             double scale,
                                             double offset); static RenderedOp createFormatOp(RenderedImage src, int dataType); static RenderedOp createClampOp(RenderedImage src,
                                           double minValue,
                                           double maxValue); static RenderedOp createLookupOp(RenderedImage src, byte[][] lookupTable); static RenderedOp createLogOp(RenderedImage src); static RenderedOp createExpOp(RenderedImage src); static RenderedOp createNullOp(RenderingHints rh); static RenderedOp createRotateOp(RenderedImage src,
                                            double xOrigin,
                                            double yOrigin,
                                            double angle); static RenderedOp createByteCastOp(RenderedImage src); static RenderedOp createShortCastOp(RenderedImage src); static RenderedOp createUShortCastOp(RenderedImage src); static RenderedOp createIntCastOp(RenderedImage src); static RenderedOp createStretchOp(RenderedImage src,
                                             double minValue,
                                             double maxValue); static RenderedOp createStretchOp(RenderedImage src,
                                             double minValueOld,
                                             double maxValueOld,
                                             double minValueNew,
                                             double maxValueNew); static RenderedOp createValueToIndexOp(RenderedImage src,
                                                  double minValue,
                                                  double maxValue,
                                                  int numIndices); static RenderedOp createValueToIndexOp(RenderedImage src,
                                                  int numIndices); static PlanarImage createPaletteOp(RenderedImage src,
                                              byte[] r,
                                              byte[] g,
                                              byte[] b); static PlanarImage createWindowLevelImage(RenderedImage image,
                                                     double window,
                                                     double level); static PlanarImage createRescaledImage(RenderedImage image,
                                                  double low,
                                                  double high); static Histogram getHistogramOf(PlanarImage sourceImage); static double[] getNativeMinMaxOf(PlanarImage sourceImage, double[] minmax); static RenderedOp createHistogramImage(PlanarImage sourceImage, int binCount); static RenderedOp createHistogramImage(PlanarImage sourceImage, int binCount, double minValue,
                                                  double maxValue); static RenderedOp createHistogramEqualizedImage(PlanarImage sourceImage); static RenderedOp createHistogramNormalizedImage(PlanarImage sourceImage); static RenderedOp createHistogramNormalizedImage(PlanarImage sourceImage, double[] mean, double[] stdDev); static PlanarImage createAlphaOverlay(PlanarImage baseImage, PlanarImage alphaImage, Color color); static LookupTableJAI createColorLookupTable(IndexColorModel icm); static Dimension computePreferredTileSize(int imageWidth,
                                                     int imageHeight,
                                                     int granularity); static PlanarImage createMapping2(RenderedImage sourceImage, IntMap indexMap); static PlanarImage createIndexedImage(RenderedImage sourceImage, IntMap intMap, int undefinedIndex);  }
@Test public void testComputePreferredTileSize_WithDifferentGranularity() throws Exception { assertEquals(new Dimension(408, 424), JAIUtils.computePreferredTileSize(4481, 2113, 4)); assertEquals(new Dimension(498, 302), JAIUtils.computePreferredTileSize(4481, 2113, 1)); }
@Test public void testPreferredTileSizeProperty() { assertEquals(new Dimension(20, 10), JAIUtils.computePreferredTileSize(20, 10, 1)); assertEquals(new Dimension(256, 120), JAIUtils.computePreferredTileSize(256, 120, 1)); assertEquals(new Dimension(500, 500), JAIUtils.computePreferredTileSize(500, 500, 1)); assertEquals(new Dimension(600, 500), JAIUtils.computePreferredTileSize(600, 500, 1)); assertEquals(new Dimension(350, 500), JAIUtils.computePreferredTileSize(700, 500, 1)); assertEquals(new Dimension(430, 500), JAIUtils.computePreferredTileSize(860, 500, 1)); assertEquals(new Dimension(512, 512), JAIUtils.computePreferredTileSize(1024, 1024, 1)); assertEquals(new Dimension(512, 512), JAIUtils.computePreferredTileSize(2048, 4096, 1)); assertEquals(new Dimension(640, 625), JAIUtils.computePreferredTileSize(12800, 25000, 1)); assertEquals(new Dimension(512, 10), JAIUtils.computePreferredTileSize(1024, 10, 1)); assertEquals(new Dimension(10, 512), JAIUtils.computePreferredTileSize(10, 4096, 1)); assertEquals(new Dimension(561, 485), JAIUtils.computePreferredTileSize(1121, 970, 1)); assertEquals(new Dimension(380, 561), JAIUtils.computePreferredTileSize(760, 1121, 1)); assertEquals(new Dimension(561, 561), JAIUtils.computePreferredTileSize(1121, 1121, 1)); assertEquals(new Dimension(561, 561), JAIUtils.computePreferredTileSize(1121, (1121 - 1) * 2 + 1, 1)); assertEquals(new Dimension(561, 561), JAIUtils.computePreferredTileSize(1121, (1121 - 1) * 3 + 1, 1)); assertEquals(new Dimension(561, 572), JAIUtils.computePreferredTileSize(1121, 14300, 1)); assertEquals(new Dimension(564, 564), JAIUtils.computePreferredTileSize(1121, 1121, 4)); assertEquals(new Dimension(564, 564), JAIUtils.computePreferredTileSize(1121, (1121 - 1) * 2 + 1, 4)); assertEquals(new Dimension(564, 260), JAIUtils.computePreferredTileSize(1121, (1121 - 1) * 3 + 1, 4)); assertEquals(new Dimension(564, 572), JAIUtils.computePreferredTileSize(1121, 14300, 4)); assertEquals(new Dimension(561, 561), JAIUtils.computePreferredTileSize(2241, 2241, 1)); assertEquals(new Dimension(561, 498), JAIUtils.computePreferredTileSize(2241, (2241 - 1) * 2 + 1, 1)); assertEquals(new Dimension(561, 611), JAIUtils.computePreferredTileSize(2241, (2241 - 1) * 3 + 1, 1)); assertEquals(new Dimension(498, 498), JAIUtils.computePreferredTileSize(4481, 4481, 1)); assertEquals(new Dimension(498, 309), JAIUtils.computePreferredTileSize(4481, (4481 - 1) * 2 + 1, 1)); assertEquals(new Dimension(498, 611), JAIUtils.computePreferredTileSize(4481, (4481 - 1) * 3 + 1, 1)); assertEquals(new Dimension(624, 436), JAIUtils.computePreferredTileSize(5602, 5221, 4)); }