本文整理了Java中javax.media.jai.Interpolation
类的一些代码示例,展示了Interpolation
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Interpolation
类的具体详情如下:
包路径:javax.media.jai.Interpolation
类名称:Interpolation
暂无
代码示例来源:origin: geotools/geotools
@Test
public void testNullSymbolizer() throws Exception {
CoordinateReferenceSystem googleMercator = CRS.decode("EPSG:3857");
ReferencedEnvelope mapExtent =
new ReferencedEnvelope(
-20037508.34, 20037508.34, -20037508.34, 20037508.34, googleMercator);
Rectangle screenSize =
new Rectangle(200, (int) (mapExtent.getHeight() / mapExtent.getWidth() * 200));
AffineTransform w2s = RendererUtilities.worldToScreenTransform(mapExtent, screenSize);
GridCoverageRenderer renderer =
new GridCoverageRenderer(googleMercator, mapExtent, screenSize, w2s);
GridCoverage2D coverage = worldReader.read(null);
RenderedImage image =
renderer.renderImage(
coverage,
null,
Interpolation.getInstance(Interpolation.INTERP_BICUBIC),
Color.RED,
256,
256);
File reference =
new File(
"src/test/resources/org/geotools/renderer/lite/gridcoverage2d/googleMercatorBicubic.png");
ImageAssert.assertEquals(reference, image, 0);
}
代码示例来源:origin: geotools/geotools
Object property = src.getProperty("ROI");
if (property == null
|| property.equals(java.awt.Image.UndefinedProperty)
&& ((GeometricOpImage) dst).getBorderExtender() == null) {
srcBounds =
new Rectangle(
src.getMinX() + interp.getLeftPadding(),
src.getMinY() + interp.getTopPadding(),
src.getWidth() - interp.getWidth() + 1,
src.getHeight() - interp.getHeight() + 1);
} else {
srcBounds =
new Rectangle(
src.getMinX(), src.getMinY(), src.getWidth(), src.getHeight());
if (!srcBounds.contains(srcROI.getBounds())) {
srcROI = srcROI.intersect(new ROIShape(srcBounds));
paramBlock.add(Interpolation.getInstance(Interpolation.INTERP_NEAREST));
Hints localHints = new Hints(op.getRenderingHints());
localHints.remove(JAI.KEY_IMAGE_LAYOUT);
代码示例来源:origin: geotools/geotools
final int rowCount = interpolation.getHeight();
final int colCount = interpolation.getWidth();
ints = samples = new int[rowCount][];
for (int i = 0; i < rowCount; i++) {
if (hasROI && !roiBounds.contains(ix, iy) && !roi.contains(ix, iy)) {
bounds.y = iy - top;
final RectIter iter =
RectIterFactory.create(image.getExtendedData(bounds, this.borderExtender), bounds);
boolean[][] gaps = hasNoData ? new boolean[samples.length][samples[0].length] : null;
for (; band < bandUp; band++) {
return dest;
final int xfrac = (int) ((x - x0) * (1 << interpolation.getSubsampleBitsH()));
final int yfrac = (int) ((y - y0) * (1 << interpolation.getSubsampleBitsV()));
dest[band] = interpolation.interpolate(samples, xfrac, yfrac);
代码示例来源:origin: geotools/geotools
final int left = interpolation.getLeftPadding();
final int top = interpolation.getTopPadding();
final int x = image.getMinX();
final int y = image.getMinY();
this.xmax = x + image.getWidth();
this.ymax = y + image.getHeight();
bounds = new Rectangle(0, 0, interpolation.getWidth(), interpolation.getHeight());
代码示例来源:origin: geotools/geotools
int lpad, rpad, tpad, bpad;
if (interp != null) {
lpad = interp.getLeftPadding();
rpad = interp.getRightPadding();
tpad = interp.getTopPadding();
bpad = interp.getBottomPadding();
} else {
lpad = rpad = tpad = bpad = 0;
try {
if (extender != null) {
minX = src.getMinX();
maxX = src.getMaxX();
minY = src.getMinY();
maxY = src.getMaxY();
iter = getRandomIterator(src, lpad, rpad, tpad, bpad, extender);
int kwidth = interp.getWidth();
int kheight = interp.getHeight();
int[][] data = dst.getIntDataArrays();
int precH = 1 << interp.getSubsampleBitsH();
int precV = 1 << interp.getSubsampleBitsV();
interp.interpolate(samples, xfrac, yfrac);
代码示例来源:origin: geotools/geotools
@Test
public void testOutsideDefinitionArea() throws Exception {
// setup a request that is outside of the coverage
CoordinateReferenceSystem crs = CRS.decode("EPSG:3031", true);
ReferencedEnvelope mapExtent =
new ReferencedEnvelope(-1250000, 0, -13750000, -12500000, crs);
// System.out.println(mapExtent.transform(DefaultGeographicCRS.WGS84, true));
GridCoverageReaderHelper helper =
new GridCoverageReaderHelper(
reader,
new Rectangle(400, 200),
mapExtent,
Interpolation.getInstance(Interpolation.INTERP_NEAREST));
// read, nothing should come out
ProjectionHandler handler =
ProjectionHandlerFinder.getHandler(
mapExtent, reader.getCoordinateReferenceSystem(), true);
List<GridCoverage2D> coverages = helper.readCoverages(null, handler);
assertTrue(coverages.isEmpty());
}
代码示例来源:origin: org.geoserver.extension/gs-wps-core
kwidth = interp.getWidth();
kheight = interp.getHeight();
if (interp != null) {
lpad = interp.getLeftPadding();
rpad = interp.getRightPadding();
tpad = interp.getTopPadding();
bpad = interp.getBottomPadding();
} else {
lpad = rpad = tpad = bpad = 0;
extender = GridCoverage2DRIA.DEFAULT_BORDEREXTENDER;
PlanarImage srcImage = PlanarImage.wrapRenderedImage(src.getRenderedImage());
if (!(lpad == rpad
&& rpad == tpad
&& tpad == bpad
&& bpad == 0)) { // there is need to extend
minX = srcImage.getMinX();
maxX = srcImage.getMaxX() - 1;
minY = srcImage.getMinY();
maxY = srcImage.getMaxY() - 1;
Rectangle bounds =
new Rectangle(
srcImage.getMinX() - lpad,
srcImage.getMinY() - tpad,
代码示例来源:origin: geotools/geotools
if (srcROI.getBounds().isEmpty()) {
return java.awt.Image.UndefinedProperty;
Interpolation.getInstance(Interpolation.INTERP_NEAREST);
&& ((GeometricOpImage) dst).getBorderExtender() == null) {
srcBounds =
new Rectangle(
src.getMinX() + interp.getLeftPadding(),
src.getMinY() + interp.getTopPadding(),
src.getWidth() - interp.getWidth() + 1,
src.getHeight() - interp.getHeight() + 1);
} else {
srcBounds =
new Rectangle(
src.getMinX(), src.getMinY(), src.getWidth(), src.getHeight());
代码示例来源:origin: geotools/geotools
Object property = src.getProperty("ROI");
if (property == null
|| property.equals(java.awt.Image.UndefinedProperty)
if (srcROI.getBounds().isEmpty()) {
return java.awt.Image.UndefinedProperty;
&& ((GeometricOpImage) dst).getBorderExtender() == null) {
srcBounds =
new Rectangle(
src.getMinX() + interp.getLeftPadding(),
src.getMinY() + interp.getTopPadding(),
src.getWidth() - interp.getWidth() + 1,
src.getHeight() - interp.getHeight() + 1);
} else {
srcBounds =
new Rectangle(
src.getMinX(), src.getMinY(), src.getWidth(), src.getHeight());
PlanarImage.wrapRenderedImage(new WarpRIF().create(paramBlk, localHints));
代码示例来源:origin: geotools/geotools
int x = (int) destRect.getMinX();
int y = (int) destRect.getMinY();
int w = (int) destRect.getWidth();
int h = (int) destRect.getHeight();
float[] src = new float[w * h * 2];
srcRectExpanded.setRect(
srcRectExpanded.getMinX() - interp.getLeftPadding(),
srcRectExpanded.getMinY() - interp.getTopPadding(),
srcRectExpanded.getWidth() + interp.getRightPadding() + interp.getLeftPadding(),
srcRectExpanded.getHeight()
+ interp.getBottomPadding()
+ interp.getTopPadding());
if (!roiBounds.intersects(srcRectExpanded)) {
代码示例来源:origin: geotools/geotools
@Test
public void testAfricaEquidistantConic() throws Exception {
CoordinateReferenceSystem crs = CRS.parseWKT(AFRICA_EQUIDISTANT_CONIC_WKT);
new ReferencedEnvelope(
-15814047.554122284,
24919762.252195686,
new Rectangle(400, (int) (mapExtent.getHeight() / mapExtent.getWidth() * 400));
AffineTransform w2s = RendererUtilities.worldToScreenTransform(mapExtent, screenSize);
GridCoverageRenderer renderer =
null,
rasterSymbolizer,
Interpolation.getInstance(Interpolation.INTERP_NEAREST),
Color.RED,
256,
代码示例来源:origin: geotools/geotools
@Test
public void testRenderOffDateline() throws Exception {
File coverageFile =
DataUtilities.urlToFile(
GridCoverageReaderHelperTest.class.getResource(
"test-data/off_dateline.tif"));
assertTrue(coverageFile.exists());
GeoTiffReader offDatelineReader = new GeoTiffReader(coverageFile);
ReferencedEnvelope envelope =
new ReferencedEnvelope(-180, 0, -90, 90, DefaultGeographicCRS.WGS84);
GridCoverageRenderer renderer =
new GridCoverageRenderer(
DefaultGeographicCRS.WGS84, envelope, new Rectangle(0, 0, 450, 450), null);
RasterSymbolizer symbolizer = new StyleBuilder().createRasterSymbolizer();
Interpolation interpolation = Interpolation.getInstance(Interpolation.INTERP_NEAREST);
RenderedImage image =
renderer.renderImage(
offDatelineReader, null, symbolizer, interpolation, null, 256, 256);
assertNotNull(image);
File reference =
new File(
"src/test/resources/org/geotools/renderer/lite/gridcoverage2d/offDateline.png");
ImageAssert.assertEquals(reference, image, 0);
}
代码示例来源:origin: geotools/geotools
GridCoverage2D coverage = multiPixelPacked.read(null);
RenderedImage image = coverage.getRenderedImage();
ReferencedEnvelope mapExtent = ReferencedEnvelope.reference(coverage.getEnvelope2D());
Rectangle screenSize =
new Rectangle(
image.getMinX(), image.getMinY(), image.getWidth(), image.getHeight());
AffineTransform w2s = RendererUtilities.worldToScreenTransform(mapExtent, screenSize);
GridCoverageRenderer renderer =
coverage,
rasterSymbolizer,
Interpolation.getInstance(Interpolation.INTERP_NEAREST),
Color.RED,
256,
代码示例来源:origin: geotools/geotools
@Test
public void testPaddingHeteroMosaic() throws Exception {
String testLocation = "hetero_utm";
URL storeUrl = TestData.url(this.getClass(), testLocation);
File testDataFolder = new File(storeUrl.toURI());
File testDirectory = crsMosaicFolder.newFolder(testLocation);
FileUtils.copyDirectory(testDataFolder, testDirectory);
ImageMosaicReader imReader = new ImageMosaicReader(testDirectory, null);
ReferencedEnvelope mapExtent =
new ReferencedEnvelope(11, 13, -1, 1, DefaultGeographicCRS.WGS84);
GridCoverageReaderHelper helper =
new GridCoverageReaderHelper(
imReader,
new Rectangle(1024, 512),
mapExtent,
Interpolation.getInstance(Interpolation.INTERP_NEAREST));
ReferencedEnvelope readEnvelope = helper.getReadEnvelope();
final double EPS = 1e-3;
assertEquals(10.981, readEnvelope.getMinX(), EPS);
assertEquals(13.021, readEnvelope.getMaxX(), EPS);
assertEquals(-1.041, readEnvelope.getMinY(), EPS);
assertEquals(1.037, readEnvelope.getMaxY(), EPS);
}
代码示例来源:origin: senbox-org/s2tbx
(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("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);
(layoutRatioY * getProductResolution().resolution));
Rectangle fitRect = new Rectangle(0, 0, fitRectWidht, fitRectHeight);
final Rectangle destBounds = DefaultMultiLevelSource.getLevelImageBounds(fitRect, Math.pow(2.0, level));
代码示例来源:origin: geotools/geotools
PlanarImage sourceImage = PlanarImage.wrapRenderedImage(sourceCoverage.getRenderedImage());
assert sourceCoverage.getCoordinateReferenceSystem() == sourceCRS : sourceCoverage;
if (CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
new RenderingHints(
JAI.KEY_INTERPOLATION,
Interpolation.getInstance(Interpolation.INTERP_NEAREST));
} else {
targetHints.put(
JAI.KEY_INTERPOLATION, Interpolation.getInstance(Interpolation.INTERP_NEAREST));
|| (allSteps instanceof AffineTransform
&& XAffineTransform.isIdentity((AffineTransform) allSteps, EPS))) {
sourceImage = PlanarImage.wrapRenderedImage(sourceCoverage.getRenderedImage());
w.setImage(sourceImage);
if (targetBB.equals(sourceBB)) {
sourceImage = PlanarImage.wrapRenderedImage(sourceCoverage.getRenderedImage());
return create(
sourceCoverage, sourceImage, targetGG, null, null, hints, sourceProps);
if (sourceBB.contains(targetBB)) {
w.crop(
Float.valueOf(targetBB.x),
if ((automaticGR || targetBB.equals(sourceBB)) && allSteps instanceof AffineTransform) {
if (automaticGG) {
代码示例来源:origin: geotools/geotools
Float scaleX = Float.valueOf(((float) mosaicLocation.getSpan(0) / image.getWidth()));
Float scaleY = Float.valueOf(((float) mosaicLocation.getSpan(1) / image.getHeight()));
Float translateX = Float.valueOf(0);
Float translateY = Float.valueOf(0);
translateX,
translateY,
Interpolation.getInstance(Interpolation.INTERP_NEAREST));
int width = image.getWidth();
int height = image.getHeight();
代码示例来源:origin: bcdev/beam
@Override
protected Image doInBackground() throws Exception {
RenderedImage sourceImage = FileLoadDescriptor.create(imageFilePath, null, true, null);
int width = sourceImage.getWidth();
int height = sourceImage.getHeight();
float scale = (float) (targetDimension.getWidth() / width);
scale = (float) Math.min(scale, targetDimension.getHeight() / height);
if (scale > 1) {
scale = 1.0f;
}
Interpolation interpolation = Interpolation.getInstance(Interpolation.INTERP_NEAREST);
RenderedImage scaledImage = ScaleDescriptor.create(sourceImage,
scale, scale,
0.0f, 0.0f,
interpolation, null);
PlanarImage planarImage = PlanarImage.wrapRenderedImage(scaledImage);
BufferedImage bufferedImage = planarImage.getAsBufferedImage();
planarImage.dispose();
return bufferedImage;
}
代码示例来源:origin: bcdev/beam
public static RenderedImage createScaledImage(RenderedImage sourceImage, Integer forcedWidth,
Integer forcedHeight) {
final int iw = sourceImage.getWidth();
final int ih = sourceImage.getHeight();
double scale = 1.0;
if (forcedWidth != null && forcedWidth != iw) {
scale = forcedWidth / (double) iw;
} else if (forcedHeight != null && forcedHeight != ih) {
scale = forcedHeight / (double) ih;
}
if (scale != 1.0) {
return JAIUtils.createScaleOp(sourceImage, scale, scale, 0.0, 0.0,
Interpolation.getInstance(Interpolation.INTERP_BICUBIC));
} else {
return sourceImage;
}
}
代码示例来源:origin: geotools/geotools
imageLayout.setColorModel(src.getRenderedImage().getColorModel());
imageLayout.setSampleModel(src.getRenderedImage().getSampleModel());
false,
extender,
Interpolation.getInstance(Interpolation.INTERP_NEAREST),
nodata,
roi,
内容来源于网络,如有侵权,请联系作者删除!