コード例 #1
0
 private RenderedOp createScaledImage(
     RenderedImage sourceImage, S2Resolution resolution, int level) {
   int sourceWidth = sourceImage.getWidth();
   int sourceHeight = sourceImage.getHeight();
   int targetWidth = imageLayouts[0].width >> level;
   int targetHeight = imageLayouts[0].height >> level;
   float scaleX = (float) targetWidth / (float) sourceWidth;
   float scaleY = (float) targetHeight / (float) sourceHeight;
   float corrFactorX = resolution == S2Resolution.R20M ? R20M_X_FACTOR : R60M_X_FACTOR;
   float corrFactorY = resolution == S2Resolution.R20M ? R20M_Y_FACTOR : R60M_Y_FACTOR;
   final Dimension tileDim = getTileDim(targetWidth, targetHeight);
   ImageLayout imageLayout = new ImageLayout();
   imageLayout.setTileWidth(tileDim.width);
   imageLayout.setTileHeight(tileDim.height);
   RenderingHints renderingHints =
       new RenderingHints(
           JAI.KEY_BORDER_EXTENDER, BorderExtender.createInstance(BorderExtender.BORDER_ZERO));
   renderingHints.put(JAI.KEY_IMAGE_LAYOUT, imageLayout);
   RenderedOp scaledImage =
       ScaleDescriptor.create(
           sourceImage,
           scaleX * corrFactorX,
           scaleY * corrFactorY,
           0F,
           0F,
           Interpolation.getInstance(Interpolation.INTERP_NEAREST),
           renderingHints);
   if (scaledImage.getWidth() != targetWidth || scaledImage.getHeight() != targetHeight) {
     return CropDescriptor.create(
         scaledImage, 0.0F, 0.0F, (float) targetWidth, (float) targetHeight, null);
   } else {
     return scaledImage;
   }
 }
コード例 #2
0
ファイル: GeoCodingFactory.java プロジェクト: bcdev/beam
 private static RenderedImage getSourceImage(ProductSubsetDef subsetDef, Band band) {
   RenderedImage sourceImage = band.getSourceImage();
   if (subsetDef != null) {
     final Rectangle region = subsetDef.getRegion();
     if (region != null) {
       float x = region.x;
       float y = region.y;
       float width = region.width;
       float height = region.height;
       sourceImage = CropDescriptor.create(sourceImage, x, y, width, height, null);
     }
     final int subSamplingX = subsetDef.getSubSamplingX();
     final int subSamplingY = subsetDef.getSubSamplingY();
     if (mustSubSample(subSamplingX, subSamplingY) || mustTranslate(region)) {
       float scaleX = 1.0f / subSamplingX;
       float scaleY = 1.0f / subSamplingY;
       float transX = region != null ? -region.x : 0;
       float transY = region != null ? -region.y : 0;
       Interpolation interpolation = Interpolation.getInstance(Interpolation.INTERP_NEAREST);
       sourceImage =
           ScaleDescriptor.create(
               sourceImage, scaleX, scaleY, transX, transY, interpolation, null);
     }
   }
   return sourceImage;
 }
コード例 #3
0
  /**
   * This method downscales a band by a given factor
   *
   * @param inputBand - the input band
   * @param scalingFactor - the scaling factor
   * @return Band - the downscaled band
   */
  public static Band downscaleBand(Band inputBand, float scalingFactor) {
    final RenderedImage sourceImage = inputBand.getSourceImage();
    final RenderedOp downscaledImage =
        ScaleDescriptor.create(
            sourceImage,
            1.0f / scalingFactor,
            1.0f / scalingFactor,
            0.0f,
            0.0f,
            Interpolation.getInstance(Interpolation.INTERP_NEAREST),
            null);
    Band downscaledBand =
        new Band(
            inputBand.getName(), inputBand.getDataType(),
            downscaledImage.getWidth(), downscaledImage.getHeight());

    downscaledBand.setSourceImage(downscaledImage);
    return downscaledBand;
  }
コード例 #4
0
ファイル: HdfEosBandPart.java プロジェクト: maduhu/beam
    @Override
    protected RenderedImage createImage(int level) {
      RasterDataNode rdn = getRasterDataNode();
      NetcdfFile lock = ctx.getNetcdfFile();
      final Object object = ctx.getProperty(Constants.Y_FLIPPED_PROPERTY_NAME);
      boolean isYFlipped = object instanceof Boolean && (Boolean) object;
      int dataBufferType = ImageManager.getDataBufferType(rdn.getDataType());
      int sourceWidth = (int) (rdn.getSceneRasterWidth() / scaleFactor);
      int sourceHeight = (int) (rdn.getSceneRasterHeight() / scaleFactor);
      ResolutionLevel resolutionLevel = ResolutionLevel.create(getModel(), level);
      Dimension tileSize = getPreferredTileSize(rdn);

      RenderedImage netcdfImg;
      if (variable.getDataType() == DataType.LONG) {
        if (rdn.getName().endsWith("_lsb")) {
          netcdfImg =
              NetcdfOpImage.createLsbImage(
                  variable,
                  imageOrigin,
                  isYFlipped,
                  lock,
                  dataBufferType,
                  sourceWidth,
                  sourceHeight,
                  tileSize,
                  resolutionLevel);
        } else {
          netcdfImg =
              NetcdfOpImage.createMsbImage(
                  variable,
                  imageOrigin,
                  isYFlipped,
                  lock,
                  dataBufferType,
                  sourceWidth,
                  sourceHeight,
                  tileSize,
                  resolutionLevel);
        }
      } else {
        netcdfImg =
            new NetcdfOpImage(
                variable,
                imageOrigin,
                isYFlipped,
                lock,
                dataBufferType,
                sourceWidth,
                sourceHeight,
                tileSize,
                resolutionLevel);
      }

      return ScaleDescriptor.create(
          netcdfImg,
          scaleFactor,
          scaleFactor,
          0.5f,
          0.5f,
          Interpolation.getInstance(Interpolation.INTERP_NEAREST),
          null);
    }
コード例 #5
0
ファイル: Tools.java プロジェクト: Holdlen2DH/nest
 public static RenderedOp scaleImage(RenderedImage image, float scale) {
   final Interpolation interpol = Interpolation.getInstance(Interpolation.INTERP_NEAREST);
   return ScaleDescriptor.create(image, scale, scale, 0.0f, 0.0f, interpol, null);
 }