本文整理汇总了Java中com.bc.ceres.glevel.MultiLevelModel类的典型用法代码示例。如果您正苦于以下问题:Java MultiLevelModel类的具体用法?Java MultiLevelModel怎么用?Java MultiLevelModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MultiLevelModel类属于com.bc.ceres.glevel包,在下文中一共展示了MultiLevelModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRendering
import com.bc.ceres.glevel.MultiLevelModel; //导入依赖的package包/类
private static BufferedImageRendering createRendering(BufferedImage bufferedImage, MultiLevelModel multiLevelModel) {
AffineTransform m2iTransform = multiLevelModel.getModelToImageTransform(0);
final Viewport vp2 = new DefaultViewport(new Rectangle(bufferedImage.getWidth(), bufferedImage.getHeight()),
m2iTransform.getDeterminant() > 0.0);
vp2.zoom(multiLevelModel.getModelBounds());
final BufferedImageRendering imageRendering = new BufferedImageRendering(bufferedImage, vp2);
// because image to model transform is stored with the exported image we have to invert
// image to view transformation
final AffineTransform v2mTransform = vp2.getViewToModelTransform();
v2mTransform.preConcatenate(m2iTransform);
final AffineTransform v2iTransform = new AffineTransform(v2mTransform);
final Graphics2D graphics2D = imageRendering.getGraphics();
v2iTransform.concatenate(graphics2D.getTransform());
graphics2D.setTransform(v2iTransform);
return imageRendering;
}
示例2: GDALTileOpImage
import com.bc.ceres.glevel.MultiLevelModel; //导入依赖的package包/类
private GDALTileOpImage(Path imageFile, int bandIndex, int sourceX, int sourceY, TileLayout tileLayout, MultiLevelModel imageModel, int dataBufferType, int level) {
super(dataBufferType, null, tileLayout.tileWidth, tileLayout.tileHeight,
getTileDimensionAtResolutionLevel(tileLayout.tileWidth, tileLayout.tileHeight, level),
null, ResolutionLevel.create(imageModel, level));
Assert.notNull(imageFile, "imageFile");
Assert.notNull(tileLayout, "tileLayout");
Assert.notNull(imageModel, "imageModel");
this.sourceX = sourceX;
this.sourceY = sourceY;
this.imageFile = imageFile;
this.tileLayout = tileLayout;
this.bandIndex = bandIndex;
this.dataBufferType = dataBufferType;
}
示例3: create
import com.bc.ceres.glevel.MultiLevelModel; //导入依赖的package包/类
/**
* Factory method for creating a TileOpImage instance.
*
* @param imageFile The JP2 file
* @param cacheDir The directory where decompressed tiles will be extracted
* @param bandIdx The index of the band for which the operator is created
* @param row The row of the tile in the scene layout
* @param col The column of the tile in the scene layout
* @param tileLayout The scene layout
* @param imageModel The multi-level image model
* @param dataType The data type of the tile raster
* @param level The resolution at which the tile is created
*/
public static PlanarImage create(Path imageFile, Path cacheDir, int bandIdx,
int row, int col, TileLayout tileLayout,
MultiLevelModel imageModel, int dataType, int level) throws IOException {
Assert.notNull(cacheDir, "cacheDir");
Assert.notNull(tileLayout, "imageLayout");
Assert.notNull(imageModel, "imageModel");
if (imageFile != null) {
//jp2TileOpImage.setTileCache(null); // the MosaicOpImage will be in the cache
return new JP2TileOpImage(imageFile, bandIdx, cacheDir, row, col, tileLayout, imageModel, dataType, level);
} else {
int targetWidth = tileLayout.tileWidth;
int targetHeight = tileLayout.tileHeight;
Dimension targetTileDim = getTileDimAtResolutionLevel(tileLayout.tileWidth, tileLayout.tileHeight, level);
SampleModel sampleModel = ImageUtils.createSingleBandedSampleModel(dataType, targetWidth, targetHeight);
ImageLayout imageLayout = new ImageLayout(0, 0, targetWidth, targetHeight, 0, 0, targetTileDim.width, targetTileDim.height, sampleModel, null);
return ConstantDescriptor.create((float) imageLayout.getWidth(null),
(float) imageLayout.getHeight(null),
new Short[]{0},
new RenderingHints(JAI.KEY_IMAGE_LAYOUT, imageLayout));
}
}
示例4: S2TileOpImage
import com.bc.ceres.glevel.MultiLevelModel; //导入依赖的package包/类
public S2TileOpImage(
File imageFile,
File cacheDir,
Point imagePos,
TileLayout tileLayout,
MultiLevelModel imageModel,
int level) {
super(S2Config.SAMPLE_DATA_BUFFER_TYPE,
imagePos,
tileLayout.width,
tileLayout.height,
getTileDimAtResolutionLevel(tileLayout.tileWidth, tileLayout.tileHeight, level),
null,
ResolutionLevel.create(imageModel, level));
Assert.notNull(imageFile, "imageFile");
Assert.notNull(cacheDir, "cacheDir");
Assert.notNull(tileLayout, "tileLayout");
Assert.notNull(imageModel, "imageModel");
this.logger = SystemUtils.LOG;
this.imageFile = imageFile;
this.cacheDir = cacheDir;
this.tileLayout = tileLayout;
}
示例5: readValues
import com.bc.ceres.glevel.MultiLevelModel; //导入依赖的package包/类
public void readValues() {
Debug.assertNotNull(bands);
for (int i = 0; i < bands.length; i++) {
final Band band = bands[i];
if (placemark != null) {
// position of placemark is given in image (L0) coordinates
// we have to transform them to the current level
final MultiLevelModel multiLevelModel = band.getMultiLevelModel();
final AffineTransform i2mTransform = multiLevelModel.getImageToModelTransform(0);
final AffineTransform m2iTransform = multiLevelModel.getModelToImageTransform(0);
final Point2D modelPixel = i2mTransform.transform(placemark.getPixelPos(), null);
final Point2D imagePixel = m2iTransform.transform(modelPixel, null);
int pixelX = (int) Math.floor(imagePixel.getX());
int pixelY = (int) Math.floor(imagePixel.getY());
energies[i] = getSample(band, pixelX, pixelY, 0);
}
}
IndexValidator validator = new IndexValidator() {
@Override
public boolean validateIndex(int index) {
return energies[index] != bands[index].getGeophysicalNoDataValue();
}
};
Range.computeRangeDouble(energies, validator, energyRange, ProgressMonitor.NULL);
// no invalidate() call here, SpectrumDiagram does this
}
示例6: readEnergy
import com.bc.ceres.glevel.MultiLevelModel; //导入依赖的package包/类
private double readEnergy(Placemark pin, Band spectralBand) {
//todo [Multisize_products] use scenerastertransform here
final Object pinGeometry = pin.getFeature().getDefaultGeometry();
if (pinGeometry == null || !(pinGeometry instanceof Point)) {
return spectralBand.getGeophysicalNoDataValue();
}
final Point2D.Double modelPoint = new Point2D.Double(((Point) pinGeometry).getCoordinate().x,
((Point) pinGeometry).getCoordinate().y);
final MultiLevelModel multiLevelModel = spectralBand.getMultiLevelModel();
int level = getLevel(multiLevelModel);
final AffineTransform m2iTransform = multiLevelModel.getModelToImageTransform(level);
final PixelPos pinLevelRasterPos = new PixelPos();
m2iTransform.transform(modelPoint, pinLevelRasterPos);
int pinLevelRasterX = (int) Math.floor(pinLevelRasterPos.getX());
int pinLevelRasterY = (int) Math.floor(pinLevelRasterPos.getY());
if (coordinatesAreInRasterBounds(spectralBand, pinLevelRasterX, pinLevelRasterY, level) &&
isPixelValid(spectralBand, pinLevelRasterX, pinLevelRasterY, level)) {
return ProductUtils.getGeophysicalSampleAsDouble(spectralBand, pinLevelRasterX, pinLevelRasterY, level);
}
return spectralBand.getGeophysicalNoDataValue();
}
示例7: quicklookRGBwOverlay
import com.bc.ceres.glevel.MultiLevelModel; //导入依赖的package包/类
public static void quicklookRGBwOverlay(Product product, File rgbFile, String[] RGBbandNames, String vectorName) throws IOException {
/* Create RGB image */
Band[] bands = new Band[3];
for (int k = 0; k < RGBbandNames.length; k++){
bands[k] = product.getBand(RGBbandNames[k]);
}
ImageInfo information = ProductUtils.createImageInfo(bands, true, ProgressMonitor.NULL);
RenderedImage renderedRGB = ImageManager.getInstance().createColoredBandImage(bands, information, 0);
/* Create image layers*/
CollectionLayer collectionLayer = new CollectionLayer();
LayerContext ctx = new MyLayerContext(product, collectionLayer);
SceneTransformProvider provider = bands[0];
MultiLevelModel multiLevelModel = bands[0].getMultiLevelModel();
// RGB
ImageLayer RGBLayer = new ImageLayer(renderedRGB, bands[0].getImageToModelTransform(), 1);
// Vector
VectorDataNode vectorDataNode = product.getVectorDataGroup().get(vectorName);
VectorDataLayer vectorDataLayer = new VectorDataLayer(ctx, vectorDataNode, provider );
/* Create the complete image by overlaying */
collectionLayer.getChildren().add(vectorDataLayer);
collectionLayer.getChildren().add(RGBLayer);
BufferedImage buffered = new BufferedImage(renderedRGB.getWidth(), renderedRGB.getHeight(), BufferedImage.TYPE_INT_ARGB);
BufferedImageRendering rendering = createRendering(buffered, multiLevelModel);
collectionLayer.render(rendering);
JAI.create("filestore", rendering.getImage(), rgbFile.toString(), "PNG");
}
示例8: createNaNReplacedImage
import com.bc.ceres.glevel.MultiLevelModel; //导入依赖的package包/类
private MultiLevelImage createNaNReplacedImage(final MultiLevelImage projectedImage, MultiLevelModel targetModel, final double value) {
return new DefaultMultiLevelImage(new AbstractMultiLevelSource(targetModel) {
@Override
public RenderedImage createImage(int targetLevel) {
return new ReplaceNaNOpImage(projectedImage.getImage(targetLevel), value);
}
});
}
示例9: createProjectedImage
import com.bc.ceres.glevel.MultiLevelModel; //导入依赖的package包/类
private MultiLevelImage createProjectedImage(final GeoCoding sourceGeoCoding, final MultiLevelImage sourceImage,
MultiLevelModel sourceModel, final Band targetBand, final Interpolation resampling,
MultiLevelModel targetModel, Reproject reprojection) {
final CoordinateReferenceSystem sourceModelCrs = Product.findModelCRS(sourceGeoCoding);
final CoordinateReferenceSystem targetModelCrs = Product.findModelCRS(targetBand.getGeoCoding());
final AffineTransform sourceImageToMapTransform = Product.findImageToModelTransform(sourceGeoCoding);
final AffineTransform targetImageToMapTransform = Product.findImageToModelTransform(targetBand.getGeoCoding());
return new DefaultMultiLevelImage(new AbstractMultiLevelSource(targetModel) {
@Override
public RenderedImage createImage(int targetLevel) {
final double targetScale = targetModel.getScale(targetLevel);
final int sourceLevel = sourceImage.getModel().getLevel(targetScale);
RenderedImage leveledSourceImage = sourceImage.getImage(sourceLevel);
final Rectangle sourceBounds = new Rectangle(leveledSourceImage.getMinX(),
leveledSourceImage.getMinY(),
leveledSourceImage.getWidth(),
leveledSourceImage.getHeight());
// the following transformation maps the source level image to level zero and then to the model,
// which either is a map or an image CRS
final AffineTransform i2mSource = sourceModel.getImageToModelTransform(sourceLevel);
i2mSource.concatenate(sourceModel.getModelToImageTransform(0));
i2mSource.concatenate(sourceImageToMapTransform);
ImageGeometry sourceGeometry = new ImageGeometry(sourceBounds,
sourceModelCrs,
i2mSource);
ImageLayout imageLayout = ImageManager.createSingleBandedImageLayout(
ImageManager.getDataBufferType(targetBand.getDataType()),
targetBand.getRasterWidth(),
targetBand.getRasterHeight(),
targetProduct.getPreferredTileSize(),
ResolutionLevel.create(getModel(), targetLevel));
Rectangle targetBounds = new Rectangle(imageLayout.getMinX(null), imageLayout.getMinY(null),
imageLayout.getWidth(null), imageLayout.getHeight(null));
// the following transformation maps the target level image to level zero and then to the model,
// which always is a map
final AffineTransform i2mTarget = getModel().getImageToModelTransform(targetLevel);
i2mTarget.concatenate(getModel().getModelToImageTransform(0));
i2mTarget.concatenate(targetImageToMapTransform);
ImageGeometry targetGeometry = new ImageGeometry(targetBounds,
targetModelCrs,
i2mTarget);
Hints hints = new Hints(JAI.KEY_IMAGE_LAYOUT, imageLayout);
hints.put(Hints.LENIENT_DATUM_SHIFT, Boolean.TRUE);
Dimension tileSize = ImageManager.getPreferredTileSize(targetProduct);
try {
return reprojection.reproject(leveledSourceImage, sourceGeometry, targetGeometry,
targetBand.getNoDataValue(), resampling, hints, targetLevel,
tileSize);
} catch (FactoryException | TransformException e) {
Debug.trace(e);
throw new RuntimeException(e);
}
}
});
}
示例10: DefaultReprojectionSettingsProvider
import com.bc.ceres.glevel.MultiLevelModel; //导入依赖的package包/类
DefaultReprojectionSettingsProvider(ImageGeometry imageGeometry) {
Band firstBand = sourceProduct.getBandGroup().get(0);
MultiLevelModel sourceModel = firstBand.getMultiLevelModel();
MultiLevelModel targetModel = targetProduct.createMultiLevelModel();
Reproject reprojection = new Reproject(targetModel.getLevelCount());
defaultReprojectionSettings = new ReprojectionSettings(null, sourceModel, imageGeometry);
defaultReprojectionSettings.setTargetModel(targetModel);
defaultReprojectionSettings.setReprojection(reprojection);
}
示例11: adjustImageToModelTransform
import com.bc.ceres.glevel.MultiLevelModel; //导入依赖的package包/类
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);
}
示例12: createInterpolatedImage
import com.bc.ceres.glevel.MultiLevelModel; //导入依赖的package包/类
public static MultiLevelImage createInterpolatedImage(MultiLevelImage sourceImage, double noDataValue,
AffineTransform sourceImageToModelTransform,
int referenceWidth,
int referenceHeight,
Dimension tileSize,
MultiLevelModel referenceMultiLevelModel,
Interpolation interpolation) {
return Resample.createInterpolatedMultiLevelImage(sourceImage, noDataValue, sourceImageToModelTransform,
referenceWidth, referenceHeight, tileSize,
referenceMultiLevelModel, interpolation);
}
示例13: JP2TileOpImage
import com.bc.ceres.glevel.MultiLevelModel; //导入依赖的package包/类
private JP2TileOpImage(Path imageFile, int bandIdx, Path cacheDir, int row, int col,
TileLayout tileLayout, MultiLevelModel imageModel, int dataType, int level) throws IOException {
super(dataType, null, tileLayout.tileWidth, tileLayout.tileHeight,
getTileDimAtResolutionLevel(tileLayout.tileWidth, tileLayout.tileHeight, level),
null, ResolutionLevel.create(imageModel, level));
Assert.notNull(imageFile, "imageFile");
Assert.notNull(cacheDir, "cacheDir");
Assert.notNull(tileLayout, "tileLayout");
Assert.notNull(imageModel, "imageModel");
this.logger = SystemUtils.LOG;
this.imageFile = imageFile;
this.cacheDir = cacheDir;
this.tileLayout = tileLayout;
this.tileIndex = col + row * tileLayout.numXTiles;
this.bandIndex = bandIdx;
this.dataType = dataType;
//if (useOpenJp2Jna == null) {
/* Uncomment to use the direct openJp2 decompression */
String openJp2 = OpenJpegExecRetriever.getOpenJp2();
useOpenJp2Jna = Boolean.parseBoolean(Config.instance("s2tbx").preferences().get("use.openjp2.jna", "false")) &&
openJp2 != null && tileLayout.numBands == 1;
/*useOpenJp2Jna = false;*/
//}
}
示例14: create
import com.bc.ceres.glevel.MultiLevelModel; //导入依赖的package包/类
public static PlanarImage create(File imageFile,
File cacheDir,
Point imagePos,
TileLayout tileLayout,
S2Config config,
MultiLevelModel imageModel,
S2SpatialResolution productResolution,
int level) {
Assert.notNull(cacheDir, "cacheDir");
Assert.notNull(tileLayout, "imageLayout");
Assert.notNull(imageModel, "imageModel");
if (imageFile != null) {
SystemUtils.LOG.fine("Image layout: " + tileLayout);
S2TileOpImage s2TileOpImage = new S2TileOpImage(imageFile, cacheDir, imagePos, tileLayout, imageModel, level);
s2TileOpImage.setTileCache(null); // the MosaicOpImage will be in the cache
return s2TileOpImage;
} else {
SystemUtils.LOG.fine("Using empty image !");
TileLayout tileLaoutForProductResolution = config.getTileLayout(productResolution);
int targetWidth = getSizeAtResolutionLevel(tileLaoutForProductResolution.width, level);
int targetHeight = getSizeAtResolutionLevel(tileLaoutForProductResolution.height, level);
Dimension targetTileDim = getTileDimAtResolutionLevel(tileLaoutForProductResolution.tileWidth, tileLaoutForProductResolution.tileHeight, level);
SampleModel sampleModel = ImageUtils.createSingleBandedSampleModel(S2Config.SAMPLE_DATA_BUFFER_TYPE, targetWidth, targetHeight);
ImageLayout imageLayout = new ImageLayout(0, 0, targetWidth, targetHeight, 0, 0, targetTileDim.width, targetTileDim.height, sampleModel, null);
return ConstantDescriptor.create((float) imageLayout.getWidth(null),
(float) imageLayout.getHeight(null),
new Short[]{S2Config.FILL_CODE_NO_FILE},
new RenderingHints(JAI.KEY_IMAGE_LAYOUT, imageLayout));
}
}
示例15: getPixelString
import com.bc.ceres.glevel.MultiLevelModel; //导入依赖的package包/类
private String getPixelString(RasterDataNode raster) {
if (raster.getImageToModelTransform().equals(currentRaster.getImageToModelTransform())
&& raster.getSceneToModelTransform().equals(currentRaster.getSceneToModelTransform())) {
if (!pixelPosValidInRaster) {
return RasterDataNode.INVALID_POS_TEXT;
}
return getPixelString(raster, pixelX, pixelY, rasterLevel);
}
final Point2D.Double scenePos = new Point2D.Double(sceneX, sceneY);
Point2D.Double modelPos = new Point2D.Double();
try {
raster.getSceneToModelTransform().transform(scenePos, modelPos);
if (Double.isNaN(modelPos.getX()) || Double.isNaN(modelPos.getY())) {
return PixelInfoViewModelUpdater.INVALID_POS_TEXT;
}
} catch (TransformException e) {
return PixelInfoViewModelUpdater.INVALID_POS_TEXT;
}
final MultiLevelModel multiLevelModel = raster.getMultiLevelModel();
final int level = getLevel(multiLevelModel);
final PixelPos rasterPos = (PixelPos) multiLevelModel.getModelToImageTransform(level).transform(modelPos, new PixelPos());
final int rasterX = floor(rasterPos.getX());
final int rasterY = floor(rasterPos.getY());
if (!coordinatesAreInRasterBounds(raster, rasterX, rasterY, level)) {
return RasterDataNode.INVALID_POS_TEXT;
}
return getPixelString(raster, rasterX, rasterY, level);
}