javax.media.jai.Interpolation.getInstance()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(15.1k)|赞(0)|评价(0)|浏览(126)

本文整理了Java中javax.media.jai.Interpolation.getInstance()方法的一些代码示例,展示了Interpolation.getInstance()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Interpolation.getInstance()方法的具体详情如下:
包路径:javax.media.jai.Interpolation
类名称:Interpolation
方法名:getInstance

Interpolation.getInstance介绍

暂无

代码示例

代码示例来源:origin: geotools/geotools

/**
 * Returns the interpolation used for all {@code evaluate(...)} methods. The default
 * implementation returns {@link javax.media.jai.InterpolationNearest}.
 *
 * @return The interpolation.
 */
public Interpolation getInterpolation() {
  return Interpolation.getInstance(Interpolation.INTERP_NEAREST);
}

代码示例来源:origin: geotools/geotools

/**
 * Constructs a new interpolator using default interpolations.
 *
 * @param coverage The coverage to interpolate.
 */
public static GridCoverage2D create(final GridCoverage2D coverage) {
  // No need to synchronize: not a big deal if two arrays are created.
  if (DEFAULTS == null) {
    DEFAULTS =
        new Interpolation[] {
          Interpolation.getInstance(Interpolation.INTERP_BICUBIC),
          Interpolation.getInstance(Interpolation.INTERP_BILINEAR),
          Interpolation.getInstance(Interpolation.INTERP_NEAREST)
        };
  }
  return create(coverage, DEFAULTS);
}

代码示例来源:origin: geotools/geotools

/**
 * Returns interpolations. The first array's element is the interpolation for this grid
 * coverage. Other elements (if any) are fallbacks.
 */
public Interpolation[] getInterpolations() {
  final List<Interpolation> interp = new ArrayList<Interpolation>(4);
  Interpolator2D scan = this;
  do {
    interp.add(interpolation);
    if (scan.fallback == scan) {
      interp.add(Interpolation.getInstance(Interpolation.INTERP_NEAREST));
      break;
    }
    scan = scan.fallback;
  } while (scan != null);
  return interp.toArray(new Interpolation[interp.size()]);
}

代码示例来源:origin: geotools/geotools

/**
 * Warps an image.
 *
 * @param source The source coverage.
 * @param warp The {@link Warp}object for this class.
 * @throws CoverageProcessingException if the operation can't be applied.
 * @see org.geotools.coverage.processing.operation.Scale
 * @since 2.3
 */
public GridCoverage warp(final GridCoverage source, final Warp warp)
    throws CoverageProcessingException {
  return warp(source, warp, Interpolation.getInstance(Interpolation.INTERP_NEAREST));
}
/**

代码示例来源:origin: geotools/geotools

Interpolation getRenderingInterpolation(Layer currLayer) {
  if (currLayer != null && currLayer.getUserData().containsKey(BYLAYER_INTERPOLATION)) {
    return (Interpolation) currLayer.getUserData().get(BYLAYER_INTERPOLATION);
  }
  if (java2dHints == null) {
    return Interpolation.getInstance(Interpolation.INTERP_NEAREST);
  }
  Object interpolationHint = java2dHints.get(RenderingHints.KEY_INTERPOLATION);
  if (interpolationHint == null
      || interpolationHint == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR) {
    return Interpolation.getInstance(Interpolation.INTERP_NEAREST);
  } else if (interpolationHint == RenderingHints.VALUE_INTERPOLATION_BILINEAR) {
    return Interpolation.getInstance(Interpolation.INTERP_BILINEAR);
  } else {
    return Interpolation.getInstance(Interpolation.INTERP_BICUBIC);
  }
}

代码示例来源:origin: geotools/geotools

/**
 * Subsamples an image by integral factors.
 *
 * @param source The source coverage.
 * @param scaleX The scale factor along the <var>x</var> axis. The default value is 2.
 * @param scaleY The scale factor along the <var>y</var> axis. The default value is 2.
 * @param qsFilter The filter. Default to a quadrant symmetric filter generated from a Gaussian
 *     kernel
 * @throws CoverageProcessingException if the operation can't be applied.
 * @see org.geotools.coverage.processing.operation.FilteredSubsample
 * @since 2.3
 */
public GridCoverage filteredSubsample(
    final GridCoverage source, final int scaleX, final int scaleY, final float[] qsFilter)
    throws CoverageProcessingException {
  return filteredSubsample(
      source,
      scaleX,
      scaleY,
      qsFilter,
      Interpolation.getInstance(Interpolation.INTERP_NEAREST));
}

代码示例来源:origin: geotools/geotools

/**
 * Casts the specified object to an {@link Interpolation object}.
 *
 * @param type The interpolation type as an {@link Interpolation} or a {@link CharSequence}
 *     object.
 * @return The interpolation object for the specified type.
 * @throws IllegalArgumentException if the specified interpolation type is not a know one.
 */
public static Interpolation toInterpolation(final Object type) throws IllegalArgumentException {
  if (type instanceof Interpolation) {
    return (Interpolation) type;
  } else if (type instanceof CharSequence) {
    final String name = type.toString();
    final int length = INTERPOLATION_NAMES.length;
    for (int i = 0; i < length; i++) {
      if (INTERPOLATION_NAMES[i].equalsIgnoreCase(name)) {
        return Interpolation.getInstance(INTERPOLATION_TYPES[i]);
      }
    }
  }
  throw new IllegalArgumentException(Errors.format(ErrorKeys.UNKNOW_INTERPOLATION_$1, type));
}

代码示例来源:origin: geotools/geotools

/**
 * Translates and resizes an image.
 *
 * @param source The source coverage.
 * @param xScale The scale factor along the <var>x</var> axis.
 * @param yScale The scale factor along the <var>y</var> axis.
 * @param xTrans The translation along the <var>x</var> axis.
 * @param yTrans The translation along the <var>x</var> axis.
 * @throws CoverageProcessingException if the operation can't be applied.
 * @see org.geotools.coverage.processing.operation.Scale
 * @since 2.3
 */
public GridCoverage scale(
    final GridCoverage source,
    final double xScale,
    final double yScale,
    final double xTrans,
    final double yTrans)
    throws CoverageProcessingException {
  return scale(
      source,
      xScale,
      yScale,
      xTrans,
      yTrans,
      Interpolation.getInstance(Interpolation.INTERP_NEAREST));
}

代码示例来源:origin: geotools/geotools

/**
 * Returns the interpolation name for the specified interpolation object. This method tries to
 * infer the name from the object's class name.
 *
 * @param Interpolation The interpolation object, or {@code null} for "nearest" (which is an
 *     other way to say "no interpolation").
 */
public static String getInterpolationName(Interpolation interp) {
  if (interp == null) {
    interp = Interpolation.getInstance(Interpolation.INTERP_NEAREST);
  }
  final String prefix = "Interpolation";
  for (Class<?> classe = interp.getClass(); classe != null; classe = classe.getSuperclass()) {
    String name = Classes.getShortName(classe);
    int index = name.lastIndexOf(prefix);
    if (index >= 0) {
      return name.substring(index + prefix.length());
    }
  }
  return Classes.getShortClassName(interp);
}

代码示例来源: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: geotools/geotools

@Test
public void testReprojectGoogleMercatorTouchDateline() throws Exception {
  CoordinateReferenceSystem googleMercator = CRS.decode("EPSG:3857");
  ReferencedEnvelope mapExtent =
      new ReferencedEnvelope(20037508.34, 40075016.68, 0, 20037508.34, googleMercator);
  Rectangle screenSize = new Rectangle(256, 256);
  AffineTransform w2s = RendererUtilities.worldToScreenTransform(mapExtent, screenSize);
  GridCoverageRenderer renderer =
      new GridCoverageRenderer(googleMercator, mapExtent, screenSize, w2s);
  RasterSymbolizer rasterSymbolizer = new StyleBuilder().createRasterSymbolizer();
  RenderedImage image =
      renderer.renderImage(
          worldReader,
          null,
          rasterSymbolizer,
          Interpolation.getInstance(Interpolation.INTERP_NEAREST),
          Color.RED,
          256,
          256);
  File reference =
      new File(
          "src/test/resources/org/geotools/renderer/lite/gridcoverage2d/googleMercatorTouchDateline.png");
  ImageAssert.assertEquals(reference, image, 10);
}

代码示例来源: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

@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

@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: geotools/geotools

@Test
public void testCrashOutsideValidArea() throws Exception {
  ReferencedEnvelope mapExtent =
      new ReferencedEnvelope(
          0.00023726353151687,
          180.00025801626,
          -269.99984914217,
          -89.999828389438,
          DefaultGeographicCRS.WGS84);
  Rectangle screenSize = new Rectangle(256, 256);
  AffineTransform w2s = RendererUtilities.worldToScreenTransform(mapExtent, screenSize);
  GridCoverageRenderer renderer =
      new GridCoverageRenderer(DefaultGeographicCRS.WGS84, mapExtent, screenSize, w2s);
  RasterSymbolizer rasterSymbolizer = new StyleBuilder().createRasterSymbolizer();
  RenderedImage image =
      renderer.renderImage(
          worldReader,
          null,
          rasterSymbolizer,
          Interpolation.getInstance(Interpolation.INTERP_NEAREST),
          Color.RED,
          256,
          256);
  assertNull(image);
}

代码示例来源:origin: geotools/geotools

@Test
public void testIndexedWithNoBackground() 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);
  RasterSymbolizer rasterSymbolizer = new StyleBuilder().createRasterSymbolizer();
  RenderedImage image =
      renderer.renderImage(
          worldPaletteReader,
          null,
          rasterSymbolizer,
          Interpolation.getInstance(Interpolation.INTERP_BICUBIC),
          null,
          256,
          256);
  assertNotNull(image);
}

代码示例来源:origin: geotools/geotools

@Test
public void testAcrossDatelineBilinear() throws Exception {
  ReferencedEnvelope mapExtent =
      new ReferencedEnvelope(10, 350, -90, 90, DefaultGeographicCRS.WGS84);
  Rectangle screenSize =
      new Rectangle(500, (int) (mapExtent.getHeight() / mapExtent.getWidth() * 500));
  AffineTransform w2s = RendererUtilities.worldToScreenTransform(mapExtent, screenSize);
  GridCoverageRenderer renderer =
      new GridCoverageRenderer(DefaultGeographicCRS.WGS84, mapExtent, screenSize, w2s);
  RasterSymbolizer rasterSymbolizer = new StyleBuilder().createRasterSymbolizer();
  RenderedImage image =
      renderer.renderImage(
          worldReader,
          null,
          rasterSymbolizer,
          Interpolation.getInstance(Interpolation.INTERP_NEAREST),
          Color.RED,
          256,
          256);
  File reference =
      new File(
          "src/test/resources/org/geotools/renderer/lite/gridcoverage2d/wrapDatelineNearest.png");
  ImageAssert.assertEquals(reference, image, 20);
}

代码示例来源:origin: geotools/geotools

@Test
public void testAcrossDatelineBicubic() throws Exception {
  ReferencedEnvelope mapExtent =
      new ReferencedEnvelope(10, 350, -90, 90, DefaultGeographicCRS.WGS84);
  Rectangle screenSize =
      new Rectangle(500, (int) (mapExtent.getHeight() / mapExtent.getWidth() * 500));
  AffineTransform w2s = RendererUtilities.worldToScreenTransform(mapExtent, screenSize);
  GridCoverageRenderer renderer =
      new GridCoverageRenderer(DefaultGeographicCRS.WGS84, mapExtent, screenSize, w2s);
  RasterSymbolizer rasterSymbolizer = new StyleBuilder().createRasterSymbolizer();
  RenderedImage image =
      renderer.renderImage(
          worldReader,
          null,
          rasterSymbolizer,
          Interpolation.getInstance(Interpolation.INTERP_BICUBIC),
          Color.RED,
          256,
          256);
  File reference =
      new File(
          "src/test/resources/org/geotools/renderer/lite/gridcoverage2d/wrapDatelineBicubic.png");
  ImageAssert.assertEquals(reference, image, 0);
}

代码示例来源:origin: geotools/geotools

@Test
public void testCoverage_0_360() throws Exception {
  CoordinateReferenceSystem crs = CRS.decode("EPSG:4326", true);
  ReferencedEnvelope mapExtent = new ReferencedEnvelope(100, 260, -90, 90, crs);
  Rectangle screenSize =
      new Rectangle(400, (int) (mapExtent.getHeight() / mapExtent.getWidth() * 400));
  AffineTransform w2s = RendererUtilities.worldToScreenTransform(mapExtent, screenSize);
  GridCoverageRenderer renderer =
      new GridCoverageRenderer(
          mapExtent.getCoordinateReferenceSystem(), mapExtent, screenSize, w2s);
  RasterSymbolizer rasterSymbolizer = new StyleBuilder().createRasterSymbolizer();
  RenderedImage image =
      renderer.renderImage(
          worldReader_0_360,
          null,
          rasterSymbolizer,
          Interpolation.getInstance(Interpolation.INTERP_NEAREST),
          Color.BLACK,
          256,
          256);
  assertNotNull(image);
  File reference =
      new File(
          "src/test/resources/org/geotools/renderer/lite/gridcoverage2d/world_0_360.png");
  ImageAssert.assertEquals(reference, image, 10);
}

代码示例来源:origin: geotools/geotools

private void checkPadding(
    Rectangle screenSize, ReferencedEnvelope requestedEnvelope, int padding)
    throws FactoryException, IOException {
  // Setup padding Hints
  Hints hints = new Hints(GridCoverageRenderer.PADDING, padding);
  GridCoverageReaderHelper helper =
      new GridCoverageReaderHelper(
          worldReader,
          screenSize,
          requestedEnvelope,
          Interpolation.getInstance(Interpolation.INTERP_BILINEAR),
          hints);
  // Get the read envelope which should have been expanded by padding
  ReferencedEnvelope readEnvelope = helper.getReadEnvelope();
  assertEquals(requestedEnvelope.getWidth() + padding * 2, readEnvelope.getWidth(), DELTA);
  assertEquals(requestedEnvelope.getHeight() + padding * 2, readEnvelope.getHeight(), DELTA);
}

相关文章