/** * Returns a tile for reading. * * @param tileX The X index of the tile. * @param tileY The Y index of the tile. * @return The tile as a <code>Raster</code>. */ public Raster computeTile(int tileX, int tileY) { // STATISTICAL ELABORATIONS // selection of the format tags RasterFormatTag[] formatTags = getFormatTags(); // Selection of the RasterAccessor parameters Raster source = getSourceImage(0).getTile(tileX, tileY); // Control if the Period is bigger than the tile dimension, in that case, the // statistics are not updated if (xPeriod > getTileWidth() || yPeriod > getTileHeight()) { return source; } Rectangle srcRect = getSourceImage(0).getBounds().intersection(source.getBounds()); // creation of the RasterAccessor RasterAccessor src = new RasterAccessor(source, srcRect, formatTags[0], getSourceImage(0).getColorModel()); // ROI calculations if roiAccessor is used RasterAccessor roi = null; RandomIter roiIter = null; if (useROIAccessor) { // Note that the getExtendedData() method is not called because the input images are padded. // For each image there is a check if the rectangle is contained inside the source image; // if this not happen, the data is taken from the padded image. Raster roiRaster = null; if (srcROIImage.getBounds().contains(srcRect)) { roiRaster = srcROIImage.getData(srcRect); } else { roiRaster = srcROIImgExt.getData(srcRect); } // creation of the rasterAccessor roi = new RasterAccessor( roiRaster, srcRect, RasterAccessor.findCompatibleTags(new RenderedImage[] {srcROIImage}, srcROIImage)[0], srcROIImage.getColorModel()); } else if (hasROI) { roiIter = RandomIterFactory.create(srcROIImage, srcROIImage.getBounds(), true, true); } // Computation of the statistics switch (src.getDataType()) { case DataBuffer.TYPE_BYTE: byteLoop(src, srcRect, roi, stats, roiIter); break; case DataBuffer.TYPE_USHORT: ushortLoop(src, srcRect, roi, stats, roiIter); break; case DataBuffer.TYPE_SHORT: shortLoop(src, srcRect, roi, stats, roiIter); break; case DataBuffer.TYPE_INT: intLoop(src, srcRect, roi, stats, roiIter); break; case DataBuffer.TYPE_FLOAT: floatLoop(src, srcRect, roi, stats, roiIter); break; case DataBuffer.TYPE_DOUBLE: doubleLoop(src, srcRect, roi, stats, roiIter); break; } return source; }