javax.media.jai.Warp Java Examples

The following examples show how to use javax.media.jai.Warp. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WarpOpImage.java    From geowave with Apache License 2.0 6 votes vote down vote up
public WarpOpImage(
    final RenderedImage source,
    final ImageLayout layout,
    final Map<?, ?> configuration,
    final boolean cobbleSources,
    final BorderExtender extender,
    final Interpolation interp,
    final Warp warp,
    final double[] backgroundValues,
    final ROI roi,
    final Range noData) {
  super(
      source,
      layout,
      configuration,
      cobbleSources,
      extender,
      interp,
      warp,
      backgroundValues,
      roi,
      noData);
}
 
Example #2
Source File: TestWarp.java    From libreveris with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new TestWarp object.
 */
public TestWarp (String path)
{
    srcImage = JAI.create("fileload", new ParameterBlock().add(path), null);
    //        srcImage = PictureLoader.loadImages(new File(path), null)
    //                                .get(1);
    //        srcImage = buildPattern(20, 10, 50, 50);
    dimension = new Dimension(srcImage.getWidth(), srcImage.getHeight());
    setPreferredSize(dimension);

    //        float[]        xCoeffs = new float[] { 0f, 1.25f, 0.04f };
    //        float[]        yCoeffs = new float[] { 0f, -0.02f, 1.5f };
    //        Warp           warp = new WarpAffine(xCoeffs, yCoeffs);
    //
    int            xStep = 500;
    int            xNumCells = 2;
    int            yStep = 500;
    int            yNumCells = 1;
    float[]        warpPositions = new float[] {
                                       -100f, 0f, 500f, 100f, 1000f, 0f, // top line
    0f, 500f, 500f, 500f, 1000f, 500f
                                   }; // bot line
    Warp           warp = new WarpGrid(
        0,
        xStep,
        xNumCells,
        0,
        yStep,
        yNumCells,
        warpPositions);
    ParameterBlock pb = new ParameterBlock();
    pb.addSource(invert(srcImage));
    pb.add(warp);
    pb.add(new InterpolationBilinear());
    dstImage = invert(JAI.create("warp", pb));
    ((PlanarImage) dstImage).getTiles();
}
 
Example #3
Source File: WarpRIF.java    From geowave with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance of warp operator according to the warp object and interpolation method.
 *
 * @param paramBlock The warp and interpolation objects.
 */
@Override
public RenderedImage create(final ParameterBlock paramBlock, final RenderingHints renderHints) {
  final Interpolation interp = (Interpolation) paramBlock.getObjectParameter(1);
  if ((interp instanceof InterpolationNearest)
      || (interp instanceof javax.media.jai.InterpolationNearest)) {
    // Get ImageLayout from renderHints if any.
    final ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);

    RenderedImage source = paramBlock.getRenderedSource(0);
    final Warp warp = (Warp) paramBlock.getObjectParameter(0);
    final double[] backgroundValues = (double[]) paramBlock.getObjectParameter(2);

    ROI roi = null;
    final Object roi_ = paramBlock.getObjectParameter(3);
    if (roi_ instanceof ROI) {
      roi = (ROI) roi_;
      final PlanarImage temp = PlanarImage.wrapRenderedImage(source);
      temp.setProperty("ROI", roi);
      source = temp;
    }
    Range noData = (Range) paramBlock.getObjectParameter(4);
    noData = RangeFactory.convert(noData, source.getSampleModel().getDataType());
    return new WarpNearestOpImage(
        source,
        renderHints,
        layout,
        warp,
        interp,
        roi,
        noData,
        backgroundValues);
  }
  return super.create(paramBlock, renderHints);
}
 
Example #4
Source File: WarpNearestOpImage.java    From geowave with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a WarpNearestOpImage.
 *
 * @param source The source image.
 * @param config RenderingHints used in calculations.
 * @param layout The destination image layout.
 * @param warp An object defining the warp algorithm.
 * @param interp An object describing the interpolation method.
 * @param roi input ROI object used.
 * @param noData NoData Range object used for checking if NoData are present.
 */
public WarpNearestOpImage(
    final RenderedImage source,
    final Map<?, ?> config,
    final ImageLayout layout,
    final Warp warp,
    final Interpolation interp,
    final ROI sourceROI,
    final Range noData,
    final double[] bkg) {
  super(
      source,
      layout,
      config,
      false,
      null, // extender not needed in
      // nearest-neighbor
      // interpolation
      interp,
      warp,
      bkg,
      sourceROI,
      noData);

  /*
   * If the source has IndexColorModel, override the default setting in OpImage. The dest shall
   * have exactly the same SampleModel and ColorModel as the source. Note, in this case, the
   * source should have an integral data type.
   */
  final ColorModel srcColorModel = source.getColorModel();
  if (srcColorModel instanceof IndexColorModel) {
    sampleModel = source.getSampleModel().createCompatibleSampleModel(tileWidth, tileHeight);
    colorModel = srcColorModel;
  }

  /*
   * Selection of a destinationNoData value for each datatype
   */
  final SampleModel sm = source.getSampleModel();
  // Source image data Type
  final int srcDataType = sm.getDataType();

  // Creation of a lookuptable containing the values to use for no data
  if ((srcDataType == DataBuffer.TYPE_BYTE) && hasNoData) {
    final int numBands = getNumBands();
    byteLookupTable = new byte[numBands][256];
    for (int b = 0; b < numBands; b++) {
      for (int i = 0; i < byteLookupTable[0].length; i++) {
        final byte value = (byte) i;
        if (noDataRange.contains(value)) {
          byteLookupTable[b][i] = (byte) backgroundValues[b];
        } else {
          byteLookupTable[b][i] = value;
        }
      }
    }
  }
}