public ImageHeader(RenderedImage image, String tileFormat) { this( new ImageLayout( image.getMinX(), image.getMinY(), image.getWidth(), image.getHeight(), image.getTileGridXOffset(), image.getTileGridYOffset(), image.getTileWidth(), image.getTileHeight(), image.getSampleModel(), image.getColorModel()), tileFormat); }
/** Set source */ private void setDefaults(RenderedImage imgsrc) { // override the params in the super class setSuperProperties(); tilingMode = MODE_EXPLICIT; if (imgsrc != null) { this.imgsrc = imgsrc; tileGridXOffset = imgsrc.getTileGridXOffset(); tileGridYOffset = imgsrc.getTileGridYOffset(); tileWidth = imgsrc.getTileWidth(); tileHeight = imgsrc.getTileHeight(); tilingSet = true; numTiles = imgsrc.getNumXTiles() * imgsrc.getNumYTiles(); numComponents = imgsrc.getSampleModel().getNumBands(); } setDefaults(); }
public static void dumpImageInfo(RenderedImage image) { final SampleModel sampleModel = image.getSampleModel(); final ColorModel colorModel = image.getColorModel(); System.out.println("image: " + image); System.out.println(" minX = " + image.getMinX()); System.out.println(" minY = " + image.getMinY()); System.out.println(" width = " + image.getWidth()); System.out.println(" height = " + image.getHeight()); System.out.println( " colorModel = " + (colorModel != null ? colorModel.getClass() : "null")); System.out.println( " colorSpace = " + (colorModel != null ? colorModel.getColorSpace() : "null")); System.out.println(" sampleModel = " + sampleModel.getClass()); System.out.println(" numBands = " + sampleModel.getNumBands()); System.out.println(" dataType = " + sampleModel.getDataType()); System.out.println(" transferType = " + sampleModel.getTransferType()); System.out.println(" tileGridXOffset = " + image.getTileGridXOffset()); System.out.println(" tileGridYOffset = " + image.getTileGridYOffset()); System.out.println(" minTileX = " + image.getMinTileX()); System.out.println(" minTileY = " + image.getMinTileY()); System.out.println(" tileWidth = " + image.getTileWidth()); System.out.println(" tileHeight = " + image.getTileHeight()); }
/** * Checking if NoData and ROI are defined correctly * * @param indexed * @param image * @param roi * @param nodata * @param destNoData */ private void checkNoDataROI( RenderedImage indexed, RenderedImage image, ROI roi, Range nodata, int destNoData) { // Ensure the dimensions are the same assertEquals(indexed.getMinX(), image.getMinX()); assertEquals(indexed.getMinY(), image.getMinY()); assertEquals(indexed.getWidth(), image.getWidth()); assertEquals(indexed.getHeight(), image.getHeight()); boolean roiExists = roi != null; boolean nodataExists = nodata != null; // Simply ensure no exception is thrown if (!nodataExists && !roiExists) { PlanarImage.wrapRenderedImage(indexed).getTiles(); return; } if (nodataExists) { nodata = RangeFactory.convertToDoubleRange(nodata); } RandomIter roiIter = null; Rectangle roiBounds = null; if (roiExists) { PlanarImage roiIMG = roi.getAsImage(); roiIter = RandomIterFactory.create(roiIMG, null, true, true); roiBounds = roi.getBounds(); } // Else check ROI and NoData RandomIter sourceIter = RandomIterFactory.create(image, null, true, true); RandomIter destIter = RandomIterFactory.create(indexed, null, true, true); // Start the iteration (we iterate only the first band) int w = image.getWidth(); int h = image.getHeight(); int minX = image.getMinX(); int minY = image.getMinY(); int maxX = minX + w; int maxY = minY + h; int limx = minX - image.getTileGridXOffset(); int limy = minY - image.getTileGridYOffset(); Rectangle translated = new Rectangle(limx, limy, w, h); for (int y = minY; y < maxY; y++) { for (int x = minX; x < maxX; x++) { double src = sourceIter.getSampleDouble(x, y, 0); double dest = destIter.getSampleDouble(x, y, 0); boolean valid = true; // ROI Check if (roiExists && !(roiBounds.contains(x, y) && roiIter.getSample(x, y, 0) > 0) && translated.contains(x, y)) { valid = false; } // NoData Check if (nodataExists && nodata.contains(src)) { valid = false; } if (!valid) { assertEquals(destNoData, dest, TOLERANCE); } } } }