本文整理汇总了Java中javax.media.jai.BorderExtender.createInstance方法的典型用法代码示例。如果您正苦于以下问题:Java BorderExtender.createInstance方法的具体用法?Java BorderExtender.createInstance怎么用?Java BorderExtender.createInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.jai.BorderExtender
的用法示例。
在下文中一共展示了BorderExtender.createInstance方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: blur
import javax.media.jai.BorderExtender; //导入方法依赖的package包/类
public void blur(int blurFactor) throws ExpressionException{
ParameterBlock params = new ParameterBlock();
params.addSource(image());
params.add(blurFactor);
RenderingHints hint= new RenderingHints(JAI.KEY_BORDER_EXTENDER,BorderExtender.createInstance(1));
image(JAI.create("boxfilter", params, hint).getAsBufferedImage());
}
示例2: computeTileStack
import javax.media.jai.BorderExtender; //导入方法依赖的package包/类
@Override
public void computeTileStack(Map<Band, Tile> targetTiles, Rectangle tarRec, ProgressMonitor pm) throws OperatorException {
Rectangle srcRec = new Rectangle(tarRec.x - OFF, tarRec.y - OFF, tarRec.width + BOX, tarRec.height + BOX);
BorderExtender borderExtender = BorderExtender.createInstance(BorderExtender.BORDER_ZERO);
Tile latTile = getSourceTile(aotProduct.getBand("latitude"), srcRec, borderExtender);
Tile aotTile = getSourceTile(aotProduct.getBand(AotConsts.aot.name), srcRec, borderExtender);
Tile aotErrTile = getSourceTile(aotProduct.getBand(AotConsts.aotErr.name), srcRec, borderExtender);
Tile tarAotTile = targetTiles.get(targetProduct.getBand(AotConsts.aot.name));
Tile tarAotErrTile = targetTiles.get(targetProduct.getBand(AotConsts.aotErr.name));
Tile tarAotFlagsTile = targetTiles.get(targetProduct.getBand(AotConsts.aotFlags.name));
double noDataVal = aotTile.getRasterDataNode().getGeophysicalNoDataValue();
float aotPixel;
float aotErrPixel;
for (int y = tarRec.y; y < tarRec.y + tarRec.height; y++) {
for (int x = tarRec.x; x < tarRec.x + tarRec.width; x++) {
double climAot = calcClimAot(latTile.getSampleFloat(x, y));
aotPixel = aotTile.getSampleFloat(x, y);
aotErrPixel = aotErrTile.getSampleFloat(x, y);
if (Double.compare(noDataVal, aotPixel) != 0) {
tarAotTile.setSample(x, y, aotPixel);
tarAotErrTile.setSample(x, y, aotErrPixel);
tarAotFlagsTile.setSample(x, y, 0);
} else {
float[] fillResult = new float[2];
int flagPixel = fillPixel(x, y, aotTile, aotErrTile, climAot, noDataVal, fillResult);
tarAotTile.setSample(x, y, fillResult[0]);
tarAotErrTile.setSample(x, y, fillResult[1]);
tarAotFlagsTile.setSample(x, y, flagPixel);
}
}
}
}
示例3: scaleAll
import javax.media.jai.BorderExtender; //导入方法依赖的package包/类
public void scaleAll(float scale) throws ImageOpException {
RenderedImage scaledImg;
// DEBUG
logger.debug("scaleAll: " + scale);
ParameterBlockJAI param = new ParameterBlockJAI("Scale");
param.addSource(img);
param.setParameter("xScale", scale);
param.setParameter("yScale", scale);
param.setParameter("interpolation", interpol);
// hint with border extender
RenderingHints hint = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
BorderExtender.createInstance(BorderExtender.BORDER_COPY));
// scale
scaledImg = JAI.create("Scale", param, hint);
if (scaledImg == null) {
throw new ImageOpException("Unable to scale");
}
img = scaledImg;
}
示例4: scaleBinary
import javax.media.jai.BorderExtender; //导入方法依赖的package包/类
public void scaleBinary(float scale) throws ImageOpException {
RenderedImage scaledImg;
// DEBUG
logger.debug("scaleBinary: " + scale);
ParameterBlockJAI param = new ParameterBlockJAI("SubsampleBinaryToGray");
param.addSource(img);
param.setParameter("xScale", scale);
param.setParameter("yScale", scale);
// hint with border extender
RenderingHints hint = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
BorderExtender.createInstance(BorderExtender.BORDER_COPY));
// scale
scaledImg = JAI.create("SubsampleBinaryToGray", param, hint);
if (scaledImg == null) {
throw new ImageOpException("Unable to scale");
}
img = scaledImg;
}
示例5: createTargetProduct
import javax.media.jai.BorderExtender; //导入方法依赖的package包/类
private void createTargetProduct() throws OperatorException {
targetProduct = new Product(sourceProduct.getName(),
sourceProduct.getProductType(),
sourceProduct.getSceneRasterWidth(),
sourceProduct.getSceneRasterHeight());
targetProduct.setStartTime(sourceProduct.getStartTime());
targetProduct.setEndTime(sourceProduct.getEndTime());
targetProduct.setPreferredTileSize(pixelsPerCell, pixelsPerCell);
ProductUtils.copyMetadata(sourceProduct, targetProduct);
ProductUtils.copyTiePointGrids(sourceProduct, targetProduct);
ProductUtils.copyFlagBands(sourceProduct, targetProduct, true);
ProductUtils.copyMasks(sourceProduct, targetProduct);
Band b = sourceProduct.getBand(ScapeMConstants.VISIBILITY_BAND_NAME);
RenderedImage sourceImage = b.getSourceImage();
final int kernelSize = pixelsPerCell;
float[] kernelMatrix = new float[kernelSize * kernelSize];
for (int k = 0; k < kernelMatrix.length; k++) {
kernelMatrix[k] = 1.0f / (kernelSize * kernelSize);
}
KernelJAI kernel = new KernelJAI(kernelSize, kernelSize, kernelMatrix);
final BorderExtender borderExtender = BorderExtender.createInstance(BorderExtender.BORDER_COPY);
RenderingHints testHints = new RenderingHints(JAI.KEY_BORDER_EXTENDER, borderExtender);
RenderedOp targetImage = ConvolveDescriptor.create(sourceImage, kernel, testHints);
Band targetBand = ProductUtils.copyBand(ScapeMConstants.VISIBILITY_BAND_NAME, sourceProduct, targetProduct, false);
targetBand.setSourceImage(targetImage);
}
示例6: paste
import javax.media.jai.BorderExtender; //导入方法依赖的package包/类
public void paste(Image topImage, int x, int y) throws ExpressionException {
RenderingHints interp = new RenderingHints(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BICUBIC);
BorderExtender extender = BorderExtender.createInstance(1);
Graphics2D g = getGraphics();
g.addRenderingHints(new RenderingHints(JAI.KEY_BORDER_EXTENDER,extender));
g.drawImage(topImage.image(), (new AffineTransformOp(AffineTransform.getTranslateInstance(x,y),interp)), 0, 0);
}
示例7: toBorderExtender
import javax.media.jai.BorderExtender; //导入方法依赖的package包/类
private Object toBorderExtender(int borderType, Color color) {
if (borderType==Image.BORDER_TYPE_CONSTANT) {
double[] colorArray = { color.getRed(), color.getGreen(), color.getBlue() };
return new BorderExtenderConstant(colorArray);
}
return BorderExtender.createInstance(borderType);
}
示例8: create
import javax.media.jai.BorderExtender; //导入方法依赖的package包/类
/**
* Creates a new instance of <code>BorderOpImage</code>
* in the rendered layer.
*
* @param args The source image and the border information
* @param hints Optionally contains destination image layout.
*/
public RenderedImage create(ParameterBlock args,
RenderingHints renderHints) {
// Get ImageLayout from renderHints if any.
ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
RenderedImage source = args.getRenderedSource(0);
int leftPad = args.getIntParameter(0);
int rightPad = args.getIntParameter(1);
int topPad = args.getIntParameter(2);
int bottomPad = args.getIntParameter(3);
BorderExtender type =
(BorderExtender)args.getObjectParameter(4);
if (type ==
BorderExtender.createInstance(BorderExtender.BORDER_WRAP)) {
int minX = source.getMinX() - leftPad;
int minY = source.getMinY() - topPad;
int width = source.getWidth() + leftPad + rightPad;
int height = source.getHeight() + topPad + bottomPad;
return new PatternOpImage(source.getData(),
source.getColorModel(),
minX, minY,
width, height);
} else {
return new BorderOpImage(source, renderHints, layout,
leftPad, rightPad, topPad, bottomPad,
type);
}
}
示例9: createImage
import javax.media.jai.BorderExtender; //导入方法依赖的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;
}
示例10: createImage
import javax.media.jai.BorderExtender; //导入方法依赖的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;
}
示例11: initialize
import javax.media.jai.BorderExtender; //导入方法依赖的package包/类
@Override
public void initialize() throws OperatorException {
productName = sourceProduct.getName() + "_AOT";
productType = sourceProduct.getProductType() + "_AOT";
validateReflectanceBandNames(reflectanceBandNames);
julianDay = sourceProduct.getStartTime().getMJD();
final int dayOfYear = sourceProduct.getStartTime().getAsCalendar().get(Calendar.DAY_OF_YEAR);
distanceCorrection = S2LutUtils.getDistanceCorr(dayOfYear);
initRasterDimensions(sourceProduct, scale);
final String validExpression = InstrumentConsts.VALID_RETRIEVAL_EXPRESSION;
validBand = AerosolUtils.createBooleanExpressionBand(validExpression, sourceProduct);
validName = validBand.getName();
auxRasterDataNodeNames = new String[]{
InstrumentConsts.OZONE_NAME,
InstrumentConsts.SURFACE_PRESSURE_NAME,
InstrumentConsts.ELEVATION_NAME,
InstrumentConsts.WATER_VAPOUR_NAME,
InstrumentConsts.AEROSOL_TYPE_NAME,
validName
};
bandIndexes = getBandIndexes(reflectanceBandNames);
specWeights = new double[bandIndexes.length];
Arrays.fill(specWeights, 1.0);
specWeights = AerosolUtils.normalize(specWeights);
specWvl = getSpectralWvl(reflectanceBandNames);
nSpecWvl = specWvl[0].length;
readSurfaceSpectra(surfaceSpecName);
// in the source product we have:
// - B1,...,B12
// - sun_zenith, sun_azimuth, view_zenith_mean, view_azimuth_mean
// - pixel_classif_flag
// - elevation
// - surfPressEstimate
try {
createS2LookupTable();
} catch (IOException e) {
throw new OperatorException("Failed to read LUTs. " + e.getMessage(), e);
}
borderExt = BorderExtender.createInstance(BorderExtender.BORDER_COPY);
pixelWindow = new Rectangle(0, 0, scale, scale);
createTargetProduct();
}