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

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

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

JAI.create介绍

暂无

代码示例

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

/**
 * Reads an image from a GeoTIFF file. For more information, see <a
 * href="http://download.java.net/media/jai-imageio/javadoc/1.1/com/sun/media/jai/operator/ImageReadDescriptor.html#RenderedMode">ImageReadDescriptor</a>
 */
private static synchronized RenderedImage readImage(File inFile) throws IOException {
  final ParameterBlock readParams = new ParameterBlock();
  ImageInputStreamSpi lSpi = ImageIOExt.getImageInputStreamSPI(inFile);
  PlanarImage lImage = null;
  ImageInputStream lImgIn = lSpi.createInputStreamInstance(inFile, false, null);
  readParams.add(lImgIn);
  readParams.add(0);
  readParams.add(Boolean.FALSE);
  readParams.add(Boolean.FALSE);
  readParams.add(Boolean.FALSE);
  readParams.add(null);
  readParams.add(null);
  readParams.add(null);
  readParams.add(READER_SPI.createReaderInstance());
  lImage = JAI.create("ImageRead", readParams, null);
  final String lFileName = inFile.getName();
  final int lExtIndex = lFileName.lastIndexOf('.');
  final String lFileNameNoExt = lExtIndex < 0 ? lFileName : lFileName.substring(0, lExtIndex);
  lImage.setProperty("name", lFileNameNoExt);
  return lImage;
}

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

/**
 * Returns the {@linkplain #getRenderedImage rendered image} after null operation. This
 * operation may be used for setting new ImageProperties or for applying new RenderingHints.
 *
 * @return The rendered operation.
 * @see #getRenderedImage
 * @see #getPlanarImage
 * @see #getImageAsROI
 */
public ImageWorker nullOp() {
  // Creating a parameter block
  ParameterBlock pb = new ParameterBlock();
  pb.setSource(image, 0);
  // Executing the operation
  image = JAI.create("Null", pb, getRenderingHints());
  return this;
}

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

public ImageWorker translate(float xTrans, float yTrans, Interpolation interp) {
  ParameterBlock pb = new ParameterBlock();
  pb.addSource(image);
  pb.add(xTrans);
  pb.add(yTrans);
  pb.add(interp);
  // do not use getRenderingHints() with translate, as it cannot deal with layout hints
  image = JAI.create("Translate", pb, commonHints);
  return this;
}

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

/**
 * Retains inconditionnaly certain bands of {@linkplain #image}. All other bands (if any) are
 * discarded without any further processing.
 *
 * @param bands the bands to retain.
 * @return this {@link ImageWorker}.
 * @see #getNumBands
 * @see #retainFirstBand
 * @see BandSelectDescriptor
 */
public final ImageWorker retainBands(final int[] bands) {
  // ParameterBlock creation
  ParameterBlock pb = new ParameterBlock();
  pb.setSource(image, 0);
  pb.set(bands, 0);
  image = JAI.create("BandSelect", pb, getRenderingHints());
  return this;
}

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

/**
 * Returns the {@linkplain #getRenderedImage rendered image} as a rendered operation.
 *
 * @return The rendered operation.
 * @see #getRenderedImage
 * @see #getPlanarImage
 * @see #getImageAsROI
 */
public final RenderedOp getRenderedOperation() {
  final RenderedImage image = getRenderedImage();
  if (image instanceof RenderedOp) {
    return (RenderedOp) image;
  }
  // Creating a parameter block
  ParameterBlock pb = new ParameterBlock();
  pb.setSource(image, 0);
  // Executing the operation
  return JAI.create("Null", pb, getRenderingHints());
}

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

/**
 * Takes one rendered or renderable image and an array of double constants, and multiplies every
 * pixel of the same band of the source by the constant from the corresponding array entry. See
 * JAI {@link MultiplyConstDescriptor} for details.
 *
 * @param inValues The constants to be multiplied.
 * @return this {@link ImageWorker}.
 * @see MultiplyConstDescriptor
 */
public final ImageWorker multiplyConst(double[] inValues) {
  ParameterBlock pb = new ParameterBlock();
  pb.setSource(image, 0);
  if (JAIExt.isJAIExtOperation(OPERATION_CONST_OP_NAME)) {
    prepareOpConstOperation(Operator.MULTIPLY, inValues, pb, roi, nodata, true);
    image = JAI.create(OPERATION_CONST_OP_NAME, pb, getRenderingHints());
  } else {
    image = JAI.create("MultiplyConst", pb, getRenderingHints());
  }
  // image = MultiplyConstDescriptor.create(image, inValues, getRenderingHints());
  invalidateStatistics();
  return this;
}

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

/**
 * Takes one rendered or renderable image and an array of integer constants, and performs a
 * bit-wise logical "xor" between every pixel in the same band of the source and the constant
 * from the corresponding array entry. See JAI {@link XorConstDescriptor} for details.
 *
 * @see XorConstDescriptor
 */
public final ImageWorker xorConst(int[] values) {
  ParameterBlock pb = new ParameterBlock();
  pb.setSource(image, 0);
  if (JAIExt.isJAIExtOperation(OPERATION_CONST_OP_NAME)) {
    double[] valuesD = new double[values.length];
    for (int i = 0; i < values.length; i++) {
      valuesD[i] = values[i];
    }
    prepareOpConstOperation(Operator.XOR, valuesD, pb, roi, nodata, true);
    image = JAI.create(OPERATION_CONST_OP_NAME, pb, getRenderingHints());
  } else {
    image = JAI.create("XorConst", pb, getRenderingHints());
  }
  // image = XorConstDescriptor.create(image, values, getRenderingHints());
  invalidateStatistics();
  return this;
}

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

/**
 * Takes two rendered or renderable source images, and subtract form each pixel the related
 * value of the second image, each one from each source image of the corresponding position and
 * band. See JAI {@link AddDescriptor} for details.
 *
 * @param renderedImage the {@link RenderedImage} to be subtracted to this {@link ImageWorker}.
 * @return this {@link ImageWorker}.
 * @see SubtractDescriptor
 */
public final ImageWorker subtract(final RenderedImage renderedImage) {
  ParameterBlock pb = new ParameterBlock();
  pb.setSource(image, 0);
  pb.setSource(renderedImage, 1);
  if (JAIExt.isJAIExtOperation(ALGEBRIC_OP_NAME)) {
    prepareAlgebricOperation(Operator.SUBTRACT, pb, roi, nodata, true);
    image = JAI.create(ALGEBRIC_OP_NAME, pb, getRenderingHints());
  } else {
    image = JAI.create("Subtract", pb, getRenderingHints());
  }
  invalidateStatistics();
  return this;
}

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

/**
 * Takes two rendered or renderable source images, and myltiply form each pixel the related
 * value of the second image, each one from each source image of the corresponding position and
 * band. See JAI {@link MultiplyDescriptor} for details.
 *
 * @param renderedImage the {@link RenderedImage} to be multiplied to this {@link ImageWorker}.
 * @return this {@link ImageWorker}.
 * @see MultiplyDescriptor
 */
public final ImageWorker multiply(RenderedImage renderedImage) {
  ParameterBlock pb = new ParameterBlock();
  pb.setSource(image, 0);
  pb.setSource(renderedImage, 1);
  if (JAIExt.isJAIExtOperation(ALGEBRIC_OP_NAME)) {
    prepareAlgebricOperation(Operator.MULTIPLY, pb, roi, nodata, true);
    image = JAI.create(ALGEBRIC_OP_NAME, pb, getRenderingHints());
  } else {
    image = JAI.create("Multiply", pb, getRenderingHints());
  }
  invalidateStatistics();
  return this;
}

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

/**
 * Takes two rendered or renderable source images, and do an OR for each pixel images, each one
 * from each source image of the corresponding position and band. See JAI {@link AddDescriptor}
 * for details.
 *
 * @param renderedImage the {@link RenderedImage} to be subtracted to this {@link ImageWorker}.
 * @return this {@link ImageWorker}.
 * @see SubtractDescriptor
 */
public final ImageWorker or(final RenderedImage renderedImage) {
  ParameterBlock pb = new ParameterBlock();
  pb.setSource(image, 0);
  pb.setSource(renderedImage, 1);
  if (JAIExt.isJAIExtOperation(ALGEBRIC_OP_NAME)) {
    prepareAlgebricOperation(Operator.OR, pb, roi, nodata, true);
    image = JAI.create(ALGEBRIC_OP_NAME, pb, getRenderingHints());
  } else {
    image = JAI.create("Or", pb, getRenderingHints());
  }
  invalidateStatistics();
  return this;
}

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

/**
 * Takes two rendered or renderable source images, and adds every pair of pixels, one from each
 * source image of the corresponding position and band. See JAI {@link AddDescriptor} for
 * details.
 *
 * @param renderedImage the {@link RenderedImage} to be added to this {@link ImageWorker}.
 * @return this {@link ImageWorker}.
 * @see AddDescriptor
 */
public final ImageWorker addImage(final RenderedImage renderedImage) {
  ParameterBlock pb = new ParameterBlock();
  pb.setSource(image, 0);
  pb.setSource(renderedImage, 1);
  if (JAIExt.isJAIExtOperation(ALGEBRIC_OP_NAME)) {
    prepareAlgebricOperation(Operator.SUM, pb, roi, nodata, true);
    image = JAI.create(ALGEBRIC_OP_NAME, pb, getRenderingHints());
  } else {
    image = JAI.create("Add", pb, getRenderingHints());
  }
  // image = AddDescriptor.create(image, renderedImage, getRenderingHints());
  invalidateStatistics();
  return this;
}

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

/** Apply a rangeLookup operation on the underlying image. */
public ImageWorker rangeLookup(Object rangeLookup) {
  // ParameterBlock definition
  ParameterBlock pb = new ParameterBlock();
  pb.setSource(image, 0);
  pb.set(rangeLookup, 0);
  pb.set(roi, 2);
  if (roi != null) {
    if (background != null && background.length > 0) {
      pb.set(background[0], 1);
      // We must set the new NoData value
      setNoData(RangeFactory.create(background[0], background[0]));
    }
  }
  if (JAIExt.isJAIExtOperation("RLookup")) {
    image = JAI.create("RLookup", pb, getRenderingHints());
  } else {
    image = JAI.create("RangeLookup", pb, getRenderingHints());
  }
  return this;
}

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

ParameterBlock pb = new ParameterBlock();
if (vectorReference != null) {
  pb.addSource(vectorReference.getAsImage());
    handleMosaicThresholds(
        ROI_THRESHOLDS, rasterROIs.size() + (vectorReference != null ? 1 : 0)));
RenderedImage roiMosaic = JAI.create("Mosaic", pb, getRenderingHints());
return new ROI(roiMosaic);

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

ParameterBlock pb = new ParameterBlock();
pb.setSource(image, 0);
pb.set(bands, 0);
image = JAI.create("BandSelect", pb, getRenderingHints());

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

/** Warps the underlying using the provided Warp object. */
public ImageWorker colorIndex(ColorIndexer indexer) {
  ParameterBlock pb = new ParameterBlock();
  pb.setSource(image, 0); // The source image.
  pb.set(indexer, 0);
  pb.set(roi, 1);
  pb.set(nodata, 2);
  if (isNoDataNeeded()) {
    if (background != null && background.length > 0) {
      pb.set(background, 3);
    }
  }
  image = JAI.create("ColorIndexer", pb, getRenderingHints());
  return this;
}

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

/**
 * Formats the underlying image to the provided data type.
 *
 * @param dataType to be used for this {@link FormatDescriptor} operation.
 * @return this {@link ImageWorker}
 */
public final ImageWorker format(final int dataType) {
  ParameterBlock pb = new ParameterBlock();
  pb.setSource(image, 0); // The source image.
  pb.set(dataType, 0);
  image = JAI.create("Format", pb, getRenderingHints());
  setNoData(RangeFactory.convert(nodata, dataType));
  // All post conditions for this method contract.
  assert image.getSampleModel().getDataType() == dataType;
  return this;
}

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

/** Apply a rescale operation on the underlying image. */
public ImageWorker bandCombine(double[][] coeff) {
  // ParameterBlock definition
  ParameterBlock pb = new ParameterBlock();
  pb.setSource(image, 0);
  pb.set(coeff, 0);
  pb.set(roi, 1);
  pb.set(nodata, 2);
  if (isNoDataNeeded()) {
    if (background != null && background.length > 0) {
      pb.set(background[0], 3);
    }
  }
  image = JAI.create("BandCombine", pb, getRenderingHints());
  return this;
}

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

/** Warps the underlying raster using the provided Warp object. */
public ImageWorker warp(Warp warp, Interpolation interp) {
  ParameterBlock pb = new ParameterBlock();
  pb.setSource(image, 0); // The source image.
  pb.set(warp, 0);
  pb.set(interp, 1);
  pb.set(roi, 3);
  pb.set(nodata, 4);
  pb.set(background, 2);
  image = JAI.create("Warp", pb, getRenderingHints());
  updateROI(true, null);
  return this;
}

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

/**
 * Inverts the pixel values of the {@linkplain #image}.
 *
 * @see InvertDescriptor
 */
public final ImageWorker invert() {
  // ParameterBlock creation
  ParameterBlock pb = new ParameterBlock();
  pb.setSource(image, 0);
  if (JAIExt.isJAIExtOperation(ALGEBRIC_OP_NAME)) {
    pb.set(AlgebraDescriptor.Operator.INVERT, 0);
    pb.set(roi, 1);
    pb.set(nodata, 2);
    if (isNoDataNeeded()) {
      if (background != null && background.length > 0) {
        double dest = background[0];
        pb.set(dest, 3);
      }
    }
    image = JAI.create(ALGEBRIC_OP_NAME, pb, getRenderingHints());
  } else {
    image = JAI.create("Invert", pb, getRenderingHints());
  }
  invalidateStatistics();
  return this;
}

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

/** Apply a rescale operation on the underlying image. */
public ImageWorker rescale(double[] scale, double[] offset) {
  ParameterBlock pb = new ParameterBlock();
  pb.setSource(image, 0); // The source image.
  pb.set(scale, 0); // The per-band constants to multiply by.
  pb.set(offset, 1); // The per-band offsets to be added.
  pb.set(roi, 2); // ROI
  pb.set(nodata, 3); // NoData range
  if (isNoDataNeeded()) {
    if (background != null && background.length > 0) {
      pb.set(background[0], 5); // destination No Data value
    }
  }
  image = JAI.create("Rescale", pb, getRenderingHints());
  return this;
}

相关文章