public MosaicMultiLevelSource(Band sourceBand, int imageWidth, int imageHeight, int tileWidth, int tileHeight, int levels, AffineTransform transform) { super(new DefaultMultiLevelModel(levels, transform, imageWidth, imageHeight)); this.imageWidth = imageWidth; this.imageHeight = imageHeight; this.tileWidth = tileWidth; this.tileHeight = tileHeight; this.sourceBand = sourceBand; this.logger = Logger.getLogger(MosaicMultiLevelSource.class.getName()); }
public MosaicMultiLevelSource(Band[][] sourceBands, int imageWidth, int imageHeight, int tileWidth, int tileHeight, int numTilesX, int numTilesY, int levels, int dataType, AffineTransform transform) { super(new DefaultMultiLevelModel(levels, //Product.findImageToModelTransform(geoCoding), transform, imageWidth, imageHeight)); this.imageWidth = imageWidth; this.imageHeight = imageHeight; this.tileWidth = tileWidth; this.tileHeight = tileHeight; this.numXTiles = numTilesX; this.numYTiles = numTilesY; this.sourceBands = sourceBands; this.dataType = dataType; logger = Logger.getLogger(MosaicMultiLevelSource.class.getName()); }
public MosaicMultiLevelSource(Band[][] sourceBands, int imageWidth, int imageHeight, int tileWidth, int tileHeight, int numTilesX, int numTilesY, int levels, int dataType, AffineTransform transform) { super(new DefaultMultiLevelModel(levels, //Product.findImageToModelTransform(geoCoding), transform, imageWidth, imageHeight)); this.imageWidth = imageWidth; this.imageHeight = imageHeight; this.tileWidth = tileWidth; this.tileHeight = tileHeight; this.numXTiles = numTilesX; this.numYTiles = numTilesY; this.sourceBands = sourceBands; this.dataType = dataType; logger = Logger.getLogger(MosaicMultiLevelSource.class.getName()); }
public MosaicMultiLevelSource(Map<Band, String> sourceBand, int imageWidth, int imageHeight, int tileWidth, int tileHeight, int levels, TileComponent tileComponent, AffineTransform transform) { super(new DefaultMultiLevelModel(levels, transform, imageWidth, imageHeight)); this.imageWidth = imageWidth; this.imageHeight = imageHeight; this.tileWidth = tileWidth; this.tileHeight = tileHeight; List<Band> bands = new ArrayList<>(); List<String> tiles = new ArrayList<>(); for(Map.Entry<Band, String>entry: sourceBand.entrySet()) { bands.add(entry.getKey()); tiles.add(entry.getValue()); } this.sourceBand = bands.toArray(new Band[bands.size()]); this.tilesNames = tiles.toArray(new String[tiles.size()]); this.tileComponent = tileComponent; this.logger = Logger.getLogger(MosaicMultiLevelSource.class.getName()); }
public S2MosaicMultiLevelSource(Band[] sourceBands, double originX, double originY, int imageWidth, int imageHeight, int tileWidth, int tileHeight, int levels, GeoCoding geoCoding, String mosaicType) { super(new DefaultMultiLevelModel(levels, Product.findImageToModelTransform(geoCoding), imageWidth, imageHeight)); this.originX = originX; this.originY = originY; this.imageWidth = imageWidth; this.imageHeight = imageHeight; this.tileWidth = tileWidth; this.tileHeight = tileHeight; this.sourceBands = sourceBands; this.mosaicType = mosaicType; this.tileImages = new HashMap<>(); for (int i = 0; i < levels; i++) { this.tileImages.put(i, Collections.synchronizedList(new ArrayList<>())); } this.logger = Logger.getLogger(S2MosaicMultiLevelSource.class.getName()); }
public static TiledFileMultiLevelSource create(File imageDir) throws IOException { Assert.notNull(imageDir); final Properties imageProperties = new Properties(); imageProperties.load(new FileReader(new File(imageDir, "image.properties"))); int levelCount = Integer.parseInt(imageProperties.getProperty("numLevels")); int sourceWidth = Integer.parseInt(imageProperties.getProperty("width")); int sourceHeight = Integer.parseInt(imageProperties.getProperty("height")); final String s = imageProperties.getProperty("i2mTransform"); AffineTransform i2mTransform = new AffineTransform(); if (s != null) { try { double[] matrix = StringUtils.toDoubleArray(s, ","); if (matrix.length == 6) { i2mTransform = new AffineTransform(matrix); } } catch (IllegalArgumentException e) { // may be thrown by StringUtils.toDoubleArray(), use identity instead } } final MultiLevelModel model = new DefaultMultiLevelModel(levelCount, i2mTransform, sourceWidth, sourceHeight); return new TiledFileMultiLevelSource(model, imageDir, imageProperties); }
AbstractL1bSceneMultiLevelSource(L1bSceneDescription sceneDescription, AffineTransform imageToModelTransform, int numResolutions) { super(new DefaultMultiLevelModel(numResolutions, imageToModelTransform, sceneDescription.getSceneRectangle().width, sceneDescription.getSceneRectangle().height)); this.sceneDescription = sceneDescription; } }
AbstractL1cSceneMultiLevelSource(S2OrthoSceneLayout sceneDescription, S2SpatialResolution bandResolution, AffineTransform imageToModelTransform, int numResolutions) { super(new DefaultMultiLevelModel(numResolutions, imageToModelTransform, sceneDescription.getSceneDimension(bandResolution).width, sceneDescription.getSceneDimension(bandResolution).height)); this.sceneDescription = sceneDescription; } }
int tileWidth, int tileHeight, int numTilesX, int numTilesY, int levels, int dataType, GeoCoding geoCoding) { super(new DefaultMultiLevelModel(levels, Product.findImageToModelTransform(geoCoding), imageWidth, imageHeight));
GDALMultiLevelSource(Path sourceFile, int bandIndex, int numBands, int imageWidth, int imageHeight, int tileWidth, int tileHeight, int levels, int dataBufferType, GeoCoding geoCoding) { super(new DefaultMultiLevelModel(levels, Product.findImageToModelTransform(geoCoding), imageWidth, imageHeight)); this.sourceFile = sourceFile; this.dataBufferType = dataBufferType; this.bandIndex = bandIndex; int numTilesX = imageWidth / tileWidth; if (imageWidth % tileWidth != 0) { numTilesX++; } int numTilesY = imageHeight / tileHeight; if (imageHeight % tileHeight != 0) { numTilesY++; } this.tileLayout = new TileLayout(imageWidth, imageHeight, tileWidth, tileHeight, numTilesX, numTilesY, levels); this.tileLayout.numBands = numBands; this.tileManager = new TileImageDisposer(); }
public static MultiLevelImage createMultiLevelImage(float[] data, int width, int height, AffineTransform affineTransform) { //create a planarImage with the data PlanarImage planarImage = createFloatPlanarImage(data, width, height); //create multi-level model DefaultMultiLevelModel multiLevelModel = new DefaultMultiLevelModel(affineTransform, width, height); //create multi-level source DefaultMultiLevelSource multiLevelSource= new DefaultMultiLevelSource(planarImage, multiLevelModel, Interpolation.getInstance(Interpolation.INTERP_NEAREST)); //create multi-level image MultiLevelImage multiLevelImage = new DefaultMultiLevelImage(multiLevelSource); return multiLevelImage; }
/** * @deprecated since BEAM 5 because it creates a {@code DefaultMultiLevelModel}, which is not the desired behaviour in many cases */ @Deprecated private static BandImageMultiLevelSource create(RasterDataNode[] rasterDataNodes, AffineTransform i2mTransform, int levelCount, ProgressMonitor pm) { Assert.notNull(rasterDataNodes); Assert.argument(rasterDataNodes.length > 0); final int w = rasterDataNodes[0].getSceneRasterWidth(); final int h = rasterDataNodes[0].getSceneRasterHeight(); MultiLevelModel model = new DefaultMultiLevelModel(levelCount, i2mTransform, w, h); return create(rasterDataNodes, model, pm); }
@Override public Layer createLayer(LayerContext ctx, PropertySet configuration) { final File file = (File) configuration.getValue(PROPERTY_NAME_IMAGE_FILE); final AffineTransform transform = (AffineTransform) configuration.getValue(PROPERTY_NAME_WORLD_TRANSFORM); RenderedImage image = FileLoadDescriptor.create(file.getPath(), null, true, null); final Rectangle2D modelBounds = DefaultMultiLevelModel.getModelBounds(transform, image); final DefaultMultiLevelModel model = new DefaultMultiLevelModel(1, transform, modelBounds); final MultiLevelSource multiLevelSource = new DefaultMultiLevelSource(image, model); return new ImageLayer(this, multiLevelSource, configuration); }
@Override public Layer createLayer(LayerContext ctx, PropertySet configuration) { final File file = (File) configuration.getValue(PROPERTY_NAME_IMAGE_FILE); final AffineTransform transform = (AffineTransform) configuration.getValue(PROPERTY_NAME_WORLD_TRANSFORM); RenderedImage image = FileLoadDescriptor.create(file.getPath(), null, true, null); final Rectangle2D modelBounds = DefaultMultiLevelModel.getModelBounds(transform, image); final DefaultMultiLevelModel model = new DefaultMultiLevelModel(1, transform, modelBounds); final MultiLevelSource multiLevelSource = new DefaultMultiLevelSource(image, model); return new ImageLayer(this, multiLevelSource, configuration); }
/** * Creates a model for an image pyramid. The method makes us of the * {@link org.esa.beam.framework.datamodel.Product#getNumResolutionsMax()} method in order to determine the * number of resolution levels for the pyramid. * * @param productNode The product node requesting the model. * @return A new image pyramid model. */ public static MultiLevelModel createMultiLevelModel(ProductNode productNode) { final Scene scene = SceneFactory.createScene(productNode); if (scene == null) { return null; } final int w = scene.getRasterWidth(); final int h = scene.getRasterHeight(); final AffineTransform i2mTransform = getImageToModelTransform(scene.getGeoCoding()); final Product product = scene.getProduct(); if (product != null && product.getNumResolutionsMax() > 0) { return new DefaultMultiLevelModel(product.getNumResolutionsMax(), i2mTransform, w, h); } else { return new DefaultMultiLevelModel(i2mTransform, w, h); } }
public static MultiLevelSource create(Product product, Color color, String expression, boolean inverseMask, AffineTransform i2mTransform) { Assert.notNull(product); Assert.notNull(color); Assert.notNull(expression); final int width = product.getSceneRasterWidth(); final int height = product.getSceneRasterHeight(); MultiLevelModel model = new DefaultMultiLevelModel(i2mTransform, width, height); return new MaskImageMultiLevelSource(model, product, color, expression, inverseMask); }
public static RenderedImage adjustImageToModelTransform(final MultiLevelImage image, MultiLevelModel model) { MultiLevelModel actualModel = model; if (model.getLevelCount() > image.getModel().getLevelCount()) { actualModel = new DefaultMultiLevelModel(image.getModel().getLevelCount(), model.getImageToModelTransform(0), image.getWidth(), image.getHeight()); } final AbstractMultiLevelSource source = new AbstractMultiLevelSource(actualModel) { @Override protected RenderedImage createImage(int level) { return image.getImage(level); } }; return new DefaultMultiLevelImage(source); }
i2mTransform.scale((double) sceneWidth / image.getWidth(), (double) sceneHeight / image.getHeight()); final Rectangle2D bounds = DefaultMultiLevelModel.getModelBounds(i2mTransform, image); final DefaultMultiLevelModel multiLevelModel = new DefaultMultiLevelModel(1, i2mTransform, bounds); multiLevelSource = new DefaultMultiLevelSource(image, multiLevelModel); } catch (Exception e) {
i2mTransform.scale((double) sceneWidth / image.getWidth(), (double) sceneHeight / image.getHeight()); final Rectangle2D bounds = DefaultMultiLevelModel.getModelBounds(i2mTransform, image); final DefaultMultiLevelModel multiLevelModel = new DefaultMultiLevelModel(1, i2mTransform, bounds); multiLevelSource = new DefaultMultiLevelSource(image, multiLevelModel); } catch (Exception e) {
@Test public void testSentinel2L1CTileResolutions() throws Exception { DefaultMultiLevelModel model = new DefaultMultiLevelModel(6, new AffineTransform(), new Rectangle2D.Double(0, 0, 1, 1)); // S-2 MSI 10m and 20m Tile testGetLevelImageBounds(4096, 4096, 0, model); testGetLevelImageBounds(2048, 4096, 1, model); testGetLevelImageBounds(1024, 4096, 2, model); testGetLevelImageBounds(512, 4096, 3, model); testGetLevelImageBounds(256, 4096, 4, model); testGetLevelImageBounds(128, 4096, 5, model); // S-2 MSI 60m Tile testGetLevelImageBounds(1826, 1826, 0, model); testGetLevelImageBounds(913, 1826, 1, model); testGetLevelImageBounds(457, 1826, 2, model); testGetLevelImageBounds(229, 1826, 3, model); testGetLevelImageBounds(115, 1826, 4, model); testGetLevelImageBounds(58, 1826, 5, model); }