本文整理汇总了Java中javax.media.jai.ImageLayout.setMinY方法的典型用法代码示例。如果您正苦于以下问题:Java ImageLayout.setMinY方法的具体用法?Java ImageLayout.setMinY怎么用?Java ImageLayout.setMinY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.jai.ImageLayout
的用法示例。
在下文中一共展示了ImageLayout.setMinY方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: layoutHelper
import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
private static ImageLayout layoutHelper(RenderedImage source,
double scaleX,
double scaleY,
ImageLayout il) {
if(scaleX <= 0.0 || scaleX > 1.0) {
throw new IllegalArgumentException
(JaiI18N.getString("SubsampleAverageOpImage0"));
} else if(scaleY <= 0.0 || scaleY > 1.0) {
throw new IllegalArgumentException
(JaiI18N.getString("SubsampleAverageOpImage1"));
}
ImageLayout layout = (il == null) ?
new ImageLayout() : (ImageLayout)il.clone();
layout.setMinX((int)Math.floor(source.getMinX()*scaleX));
layout.setMinY((int)Math.floor(source.getMinY()*scaleY));
layout.setWidth((int)(source.getWidth()*scaleX));
layout.setHeight((int)(source.getHeight()*scaleY));
return layout;
}
示例2: crop
import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
private RenderedImage crop(RenderedImage source, Rectangle cropArea) {
ImageLayout layout = new ImageLayout();
layout.setMinX(cropArea.x);
layout.setMinY(cropArea.y);
layout.setWidth(cropArea.width);
layout.setHeight(cropArea.height);
return CropDescriptor.create(source, (float) cropArea.getX(), (float) cropArea.getY(),
(float) cropArea.getWidth(), (float) cropArea.getHeight(),
new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout)).getRendering();
}
示例3: layoutHelper
import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/**
* Sets up the image layout information for this Op.
* The minX, minY, width, and height are calculated based on
* the source's dimension and padding values. Any of these
* values specified in the layout parameter is ignored.
* All other variables are taken from the layout parameter or
* inherited from the source.
*/
private static ImageLayout layoutHelper(ImageLayout layout,
RenderedImage source,
int leftPad,
int rightPad,
int topPad,
int bottomPad) {
ImageLayout il = layout == null ?
new ImageLayout() : (ImageLayout)layout.clone();
// Set the image bounds according to the padding.
il.setMinX(source.getMinX() - leftPad);
il.setMinY(source.getMinY() - topPad);
il.setWidth(source.getWidth() + leftPad + rightPad);
il.setHeight(source.getHeight() + topPad + bottomPad);
// Set tile grid offset to minimize the probability that a
// tile's bounds does not intersect the source image bounds.
if(!il.isValid(ImageLayout.TILE_GRID_X_OFFSET_MASK)) {
il.setTileGridXOffset(il.getMinX(null));
}
if (!il.isValid(ImageLayout.TILE_GRID_Y_OFFSET_MASK)) {
il.setTileGridYOffset(il.getMinY(null));
}
// Force inheritance of source image SampleModel and ColorModel.
il.setSampleModel(source.getSampleModel());
il.setColorModel(source.getColorModel());
return il;
}
示例4: layoutHelper
import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/** <p> <code>layoutHelper</code> validates input and returns an
* <code>ImageLayout</code> object.
*
* @param source a RenderedImage object.
* @param interp an Interpolation object.
* @param scaleX an int downsample factor.
* @param scaleY an int downsample factor.
* @param filterSize an int representing the size of the combined
* filter and resample kernel.
* @param il an ImageLayout object.
* @return validated ImageLayout object.
*/
private static final ImageLayout layoutHelper(RenderedImage source,
Interpolation interp,
int scaleX,
int scaleY,
int filterSize,
ImageLayout il) {
if (scaleX < 1 || scaleY < 1 ) {
throw new IllegalArgumentException(
JaiI18N.getString("FilteredSubsample1"));
}
if (filterSize < 1) {
throw new IllegalArgumentException(
JaiI18N.getString("FilteredSubsample2"));
}
// Set the bounds to the scaled source bounds.
Rectangle bounds =
forwardMapRect(source.getMinX(), source.getMinY(),
source.getWidth(), source.getHeight(),
scaleX, scaleY);
// If the user has supplied a layout, use it
ImageLayout layout = (il == null) ?
new ImageLayout(bounds.x, bounds.y, bounds.width, bounds.height) :
(ImageLayout)il.clone();
// Override dimensions if user passed a hint
if (il != null) {
layout.setWidth(bounds.width);
layout.setHeight(bounds.height);
layout.setMinX(bounds.x);
layout.setMinY(bounds.y);
}
return layout;
}
示例5: layoutHelper
import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/**
* Force the destination image to be single-banded.
*/
private static ImageLayout layoutHelper(ImageLayout layout,
RenderedImage source) {
// Create or clone the layout.
ImageLayout il = layout == null ?
new ImageLayout() : (ImageLayout)layout.clone();
// Force the destination and source origins and dimensions to coincide.
il.setMinX(source.getMinX());
il.setMinY(source.getMinY());
il.setWidth(source.getWidth());
il.setHeight(source.getHeight());
// Get the SampleModel.
SampleModel sm = il.getSampleModel(source);
// Make sure that this OpImage is single-banded.
if (sm.getNumBands() != 1) {
sm =
RasterFactory.createComponentSampleModel(sm,
sm.getTransferType(),
sm.getWidth(),
sm.getHeight(),
1);
il.setSampleModel(sm);
}
il.setColorModel(null);
return il;
}
示例6: getImageLayout
import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
@Override
public ImageLayout getImageLayout(String name) throws IOException
{
log.fine("Getting JAI layout for: " + name);
if (!checkName(name)) {
throw new IllegalArgumentException("The specified coverage " + name + "is not found");
}
// get the pixel size of the base image
try
{
MrsImageDataProvider dp = DataProviderFactory
.getMrsImageDataProvider(name, DataProviderFactory.AccessMode.READ, providerProperties);
MrsPyramidMetadata meta = dp.getMetadataReader().read();
LongRectangle bounds = meta.getPixelBounds(meta.getMaxZoomLevel());
ImageLayout layout = new ImageLayout();
layout.setMinX(0);
layout.setMinY(0);
layout.setWidth((int)bounds.getWidth());
layout.setHeight((int)bounds.getHeight());
// only 1 tile!
layout.setTileGridXOffset(0);
layout.setTileGridYOffset(0);
layout.setTileWidth((int)bounds.getWidth());
layout.setTileHeight((int)bounds.getHeight());
MrsImageReader r = dp.getMrsTileReader(meta.getMaxZoomLevel());
final Iterator<MrGeoRaster> it = r.get();
try
{
Raster raster = it.next().toRaster();
layout.setColorModel(RasterUtils.createColorModel(raster));
layout.setSampleModel(raster.getSampleModel());
}
finally
{
if (!r.canBeCached() && it instanceof Closeable)
{
((Closeable) it).close();
r.close();
}
}
return layout;
}
catch (IOException e)
{
e.printStackTrace();
}
return null;
}
示例7: createImage
import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
@Override
protected RenderedImage createImage(int level) {
final List<RenderedImage> tileImages = Collections.synchronizedList(new ArrayList<>(numXTiles * numYTiles));
double factorX = 1.0 / Math.pow(2, level);
double factorY = 1.0 / Math.pow(2, level);
for (int x = 0; x < numYTiles; x++) {
for (int y = 0; y < numXTiles; y++) {
PlanarImage opImage;
try {
opImage = createTileImage(x, y, level);
if (opImage != null) {
opImage = TranslateDescriptor.create(opImage,
(float) (y * tileWidth * factorX),
(float) (x * tileHeight * factorY),
Interpolation.getInstance(Interpolation.INTERP_NEAREST),
null);
}
} catch (IOException ex) {
opImage = ConstantDescriptor.create((float) tileWidth, (float) tileHeight, new Number[]{0}, null);
}
tileImages.add(opImage);
}
}
if (tileImages.isEmpty()) {
logger.warning("No tile images for mosaic");
return null;
}
//if (imageLayout == null) {
imageLayout = new ImageLayout();
imageLayout.setMinX(0);
imageLayout.setMinY(0);
imageLayout.setTileWidth(JAI.getDefaultTileSize().width);
imageLayout.setTileHeight(JAI.getDefaultTileSize().height);
imageLayout.setTileGridXOffset(0);
imageLayout.setTileGridYOffset(0);
//imageLayout.setSampleModel(ImageUtils.createSingleBandedSampleModel(dataType, imageWidth, imageHeight));
//imageLayout.setColorModel(ImageUtils.create8BitGreyscaleColorModel());
//}
RenderedOp mosaicOp = MosaicDescriptor.create(tileImages.toArray(new RenderedImage[tileImages.size()]),
MosaicDescriptor.MOSAIC_TYPE_OVERLAY,
null, null, null, null,
new RenderingHints(JAI.KEY_IMAGE_LAYOUT, imageLayout));
int fittingRectWidth = scaleValue(imageWidth, level);
int fittingRectHeight = scaleValue(imageHeight, level);
Rectangle fitRect = new Rectangle(0, 0, fittingRectWidth, fittingRectHeight);
final Rectangle destBounds = DefaultMultiLevelSource.getLevelImageBounds(fitRect, Math.pow(2.0, level));
BorderExtender borderExtender = BorderExtender.createInstance(BorderExtender.BORDER_COPY);
if (mosaicOp.getWidth() < destBounds.width || mosaicOp.getHeight() < destBounds.height) {
int rightPad = destBounds.width - mosaicOp.getWidth();
int bottomPad = destBounds.height - mosaicOp.getHeight();
mosaicOp = BorderDescriptor.create(mosaicOp, 0, rightPad, 0, bottomPad, borderExtender, null);
}
return mosaicOp;
}
示例8: createImage
import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
@Override
protected RenderedImage createImage(int level) {
ArrayList<RenderedImage> tileImages = new ArrayList<>();
List<String> tiles = sceneDescription.getTileIds().stream().filter(x -> x.contains(tileBandInfo.detectorId)).collect(Collectors.toList());
TileLayout thisBandTileLayout = this.tileBandInfo.getImageLayout();
TileLayout productTileLayout = getConfig().getTileLayout(getProductResolution());
float layoutRatioX = (float) productTileLayout.width / thisBandTileLayout.width;
float layoutRatioY = (float) productTileLayout.height / thisBandTileLayout.height;
for (String tileId : tiles) {
int tileIndex = sceneDescription.getTileIndex(tileId);
Rectangle tileRectangle = sceneDescription.getTileRectangle(tileIndex);
PlanarImage opImage = createL1bTileImage(tileId, level);
{
double factorX = 1.0 / (Math.pow(2, level) * layoutRatioX);
double factorY = 1.0 / (Math.pow(2, level) * layoutRatioY);
opImage = TranslateDescriptor.create(opImage,
(float) Math.floor((tileRectangle.x * factorX)),
(float) Math.floor((tileRectangle.y * factorY)),
Interpolation.getInstance(Interpolation.INTERP_NEAREST), null);
logger.log(Level.parse(S2Config.LOG_SCENE), String.format("Translate descriptor: %s", ToStringBuilder.reflectionToString(opImage)));
}
logger.log(Level.parse(S2Config.LOG_SCENE), String.format("opImage added for level %d at (%d,%d) with size (%d,%d)%n", level, opImage.getMinX(), opImage.getMinY(), opImage.getWidth(), opImage.getHeight()));
tileImages.add(opImage);
}
if (tileImages.isEmpty()) {
logger.warning("No tile images for mosaic");
return null;
}
ImageLayout imageLayout = new ImageLayout();
imageLayout.setMinX(0);
imageLayout.setMinY(0);
imageLayout.setTileWidth(S2Config.DEFAULT_JAI_TILE_SIZE);
imageLayout.setTileHeight(S2Config.DEFAULT_JAI_TILE_SIZE);
imageLayout.setTileGridXOffset(0);
imageLayout.setTileGridYOffset(0);
RenderedOp mosaicOp = MosaicDescriptor.create(tileImages.toArray(new RenderedImage[tileImages.size()]),
MosaicDescriptor.MOSAIC_TYPE_OVERLAY,
null, null, new double[][]{{1.0}}, new double[]{S2Config.FILL_CODE_MOSAIC_BG},
new RenderingHints(JAI.KEY_IMAGE_LAYOUT, imageLayout));
int fitRectWidht = (int) (sceneDescription.getSceneEnvelope().getWidth() /
(layoutRatioX * getProductResolution().resolution));
int fitRectHeight = (int) (sceneDescription.getSceneEnvelope().getHeight() /
(layoutRatioY * getProductResolution().resolution));
Rectangle fitRect = new Rectangle(0, 0, fitRectWidht, fitRectHeight);
final Rectangle destBounds = DefaultMultiLevelSource.getLevelImageBounds(fitRect, Math.pow(2.0, level));
BorderExtender borderExtender = BorderExtender.createInstance(BorderExtender.BORDER_COPY);
if (mosaicOp.getWidth() < destBounds.width || mosaicOp.getHeight() < destBounds.height) {
int rightPad = destBounds.width - mosaicOp.getWidth();
int bottomPad = destBounds.height - mosaicOp.getHeight();
SystemUtils.LOG.log(Level.parse(S2Config.LOG_SCENE), String.format("Border: (%d, %d), (%d, %d)", mosaicOp.getWidth(), destBounds.width, mosaicOp.getHeight(), destBounds.height));
mosaicOp = BorderDescriptor.create(mosaicOp, 0, rightPad, 0, bottomPad, borderExtender, null);
}
logger.log(Level.parse(S2Config.LOG_SCENE), String.format("mosaicOp created for level %d at (%d,%d) with size (%d, %d)%n", level, mosaicOp.getMinX(), mosaicOp.getMinY(), mosaicOp.getWidth(), mosaicOp.getHeight()));
return mosaicOp;
}
示例9: layoutHelper
import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/**
* Override the dimension specification for the destination such that it
* has width and height which are equal to non-negative powers of 2.
*/
private static ImageLayout layoutHelper(ImageLayout layout,
RenderedImage source) {
// Create an ImageLayout or clone the one passed in.
ImageLayout il = layout == null ?
new ImageLayout() : (ImageLayout)layout.clone();
// Force the origin to coincide with that of the source.
il.setMinX(source.getMinX());
il.setMinY(source.getMinY());
// Recalculate the non-unity dimensions to be a positive power of 2.
// XXX This calculation should not be effected if an implementation
// of the FCT which supports arbitrary dimensions is used.
boolean createNewSampleModel = false;
int w = il.getWidth(source);
if(w > 1) {
int newWidth = MathJAI.nextPositivePowerOf2(w);
if(newWidth != w) {
il.setWidth(w = newWidth);
createNewSampleModel = true;
}
}
int h = il.getHeight(source);
if(h > 1) {
int newHeight = MathJAI.nextPositivePowerOf2(h);
if(newHeight != h) {
il.setHeight(h = newHeight);
createNewSampleModel = true;
}
}
// Force the image to contain floating point data.
SampleModel sm = il.getSampleModel(source);
int dataType = sm.getTransferType();
if(dataType != DataBuffer.TYPE_FLOAT &&
dataType != DataBuffer.TYPE_DOUBLE) {
dataType = DataBuffer.TYPE_FLOAT;
createNewSampleModel = true;
}
// Create a new SampleModel for the destination.
if(createNewSampleModel) {
sm = RasterFactory.createComponentSampleModel(sm, dataType, w, h,
sm.getNumBands());
il.setSampleModel(sm);
// Clear the ColorModel mask if needed.
ColorModel cm = il.getColorModel(null);
if(cm != null &&
!JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
// Clear the mask bit if incompatible.
il.unsetValid(ImageLayout.COLOR_MODEL_MASK);
}
}
return il;
}