Package javax.media.jai

Examples of javax.media.jai.Interpolation


        ///////////////////////////////////////////////////////////////////////
        //
        // Nearest neighbor interpolation and non-geophysics view.
        //
        ///////////////////////////////////////////////////////////////////////
        Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_NEAREST);
        scale(originallyIndexedCoverage      .view(PACKED), interp);
        scale(indexedCoverage                .view(PACKED), interp);
        scale(indexedCoverageWithTransparency.view(PACKED), interp);

        ///////////////////////////////////////////////////////////////////////
View Full Code Here


        ///////////////////////////////////////////////////////////////////////
        //
        // Nearest neighbor interpolation and non-geophysics view.
        //
        ///////////////////////////////////////////////////////////////////////
        Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_NEAREST);
        affine(originallyIndexedCoverage      .view(PACKED), interp);
        affine(indexedCoverage                .view(PACKED), interp);
        affine(indexedCoverageWithTransparency.view(PACKED), interp);

        ///////////////////////////////////////////////////////////////////////
View Full Code Here

    }
    catch (IllegalArgumentException e) {
      indexOfBorderExtenderParam=-1;
    }

    final Interpolation interpolation =(Interpolation) (indexOfInterpolationParam==-1?
          new InterpolationNearest():
            parameters.parameters.getObjectParameter("interpolation")); ;
    final BorderExtender borderExtender=
      (BorderExtender) (indexOfBorderExtenderParam!=-1?
          parameters.parameters.getObjectParameter("BorderExtender"):
View Full Code Here

            if ("Affine".equals(opName)) {
                ParameterBlock paramBlock = op.getParameterBlock();
                RenderedImage sSource = paramBlock.getRenderedSource(0);

                AffineTransform sTx = (AffineTransform) paramBlock.getObjectParameter(0);
                Interpolation sInterp = (Interpolation) paramBlock.getObjectParameter(1);
                double[] sBgValues = (double[]) paramBlock.getObjectParameter(2);

                if ((sInterp == interpolation && Arrays.equals(sBgValues, bgValues))) {
                    // we can replace it
                    AffineTransform concat = new AffineTransform(tx);
                    concat.concatenate(sTx);
                    tx = concat;
                    source = sSource;
                }
            } else if ("Scale".equals(opName)) {
                ParameterBlock paramBlock = op.getParameterBlock();
                RenderedImage sSource = paramBlock.getRenderedSource(0);

                float xScale = paramBlock.getFloatParameter(0);
                float yScale = paramBlock.getFloatParameter(1);
                float xTrans = paramBlock.getFloatParameter(2);
                float yTrans = paramBlock.getFloatParameter(3);
                Interpolation sInterp = (Interpolation) paramBlock.getObjectParameter(4);

                if (sInterp == interpolation) {
                    // we can replace it
                    AffineTransform concat = new AffineTransform(tx);
                    concat.concatenate(new AffineTransform(xScale, 0, 0, yScale, xTrans, yTrans));
View Full Code Here

    @Test
    public void testInterpolationNearest() {

        // make sure the class is registered and assigned
        Interpolation result = Converters.convert("InterpolationNearest", INTERPOLATION_CLASS);
        assertNotNull(result);
        assertSame(result.getClass(), InterpolationNearest.class);

        // test case sensiteveness
        assertNull(Converters.convert("Interpolationnearest", INTERPOLATION_CLASS));
        assertNull(Converters.convert("interpolationnearest", INTERPOLATION_CLASS));
        assertNull(Converters.convert("interpolatioNnearest", INTERPOLATION_CLASS));
View Full Code Here

    @Test
    public void testInterpolationBilinear() {

        // make sure the class is registered and assigned
        Interpolation result = Converters.convert("InterpolationBilinear(2)", INTERPOLATION_CLASS);
        assertNotNull(result);
        assertSame(result.getClass(), InterpolationBilinear.class);
        assertSame(result.getSubsampleBitsH(), 2);
        assertSame(result.getSubsampleBitsV(), 2);

        result = Converters.convert("InterpolationBilinear(4)", INTERPOLATION_CLASS);
        assertNotNull(result);
        assertSame(result.getClass(), InterpolationBilinear.class);
        assertSame(result.getSubsampleBitsH(), 4);
        assertSame(result.getSubsampleBitsV(), 4);

        result = Converters.convert("InterpolationBilinear", INTERPOLATION_CLASS);
        assertNotNull(result);
        assertSame(result.getClass(), InterpolationBilinear.class);
        assertSame(result.getSubsampleBitsH(), 8);
        assertSame(result.getSubsampleBitsV(), 8);

        // test case sensiteveness
        assertNull(Converters.convert("interpolationBilinear", INTERPOLATION_CLASS));
        assertNull(Converters.convert("Interpolationbilinear", INTERPOLATION_CLASS));
        assertNull(Converters.convert("interpolationbilinear", INTERPOLATION_CLASS));
View Full Code Here

    @Test
    public void testInterpolationBicubic() {

        // make sure the class is registered and assigned
        Interpolation result = Converters.convert("InterpolationBicubic(2)", INTERPOLATION_CLASS);
        assertNotNull(result);
        assertSame(result.getClass(), InterpolationBicubic.class);
        assertSame(result.getSubsampleBitsH(), 2);
        assertSame(result.getSubsampleBitsV(), 2);

        result = Converters.convert("InterpolationBicubic(4)", INTERPOLATION_CLASS);
        assertNotNull(result);
        assertSame(result.getClass(), InterpolationBicubic.class);
        assertSame(result.getSubsampleBitsH(), 4);
        assertSame(result.getSubsampleBitsV(), 4);

        result = Converters.convert("InterpolationBicubic", INTERPOLATION_CLASS);
        assertNull(result);

        // test case sensiteveness
View Full Code Here

    @Test
    public void testInterpolationBicubic2() {

        // make sure the class is registered and assigned
        Interpolation result = Converters.convert("InterpolationBicubic2(2)", INTERPOLATION_CLASS);
        assertNotNull(result);
        assertSame(result.getClass(), InterpolationBicubic2.class);
        assertSame(result.getSubsampleBitsH(), 2);
        assertSame(result.getSubsampleBitsV(), 2);

        result = Converters.convert("InterpolationBicubic2(4)", INTERPOLATION_CLASS);
        assertNotNull(result);
        assertSame(result.getClass(), InterpolationBicubic2.class);
        assertSame(result.getSubsampleBitsH(), 2);
        assertSame(result.getSubsampleBitsV(), 2);

        // missing subsamplebits
        result = Converters.convert("InterpolationBicubic2", INTERPOLATION_CLASS);
        assertNull(result);
View Full Code Here

        // Following constant is pixel size (in degrees).
        // This constant must be identical to the one defined in 'getRandomCoverage()'
        GridCoverage2D coverage = getRandomCoverage();
        final double PIXEL_SIZE = XAffineTransform.getScale((AffineTransform) ((GridGeometry2D)coverage.getGridGeometry()).getGridToCRS());
        coverage = coverage.view(ViewType.GEOPHYSICS);
        final Interpolation interpolation =  Interpolation.getInstance(Interpolation.INTERP_BILINEAR);
        coverage = Interpolator2D.create(coverage, new Interpolation[] {interpolation});
        final int  band = 0; // Band to test.
        double[] buffer = null;
        final BorderExtender be =  BorderExtender.createInstance(BorderExtender.BORDER_COPY);
        Rectangle  rectangle = PlanarImage.wrapRenderedImage(coverage.getRenderedImage()).getBounds();
        rectangle       = new Rectangle(rectangle.x,rectangle.y,rectangle.width+interpolation.getWidth(), rectangle.height+interpolation.getHeight());
        final Raster          data = PlanarImage.wrapRenderedImage(coverage.getRenderedImage()).getExtendedData(rectangle,be);
        final Envelope    envelope = coverage.getEnvelope();
        final GridEnvelope   range = coverage.getGridGeometry().getGridRange();
        final double          left = envelope.getMinimum(0);
        final double         upper = envelope.getMaximum(1);
        final Point2D.Double point = new Point2D.Double(); // Will maps to pixel upper-left corner
        for (int j=range.getSpan(1); j>=0;--j) {
            for (int i=range.getSpan(0); i>=0;--i) {
                point.x  = left  + PIXEL_SIZE*i;
                point.y  = upper - PIXEL_SIZE*j;
                buffer   = coverage.evaluate(point, buffer);
                double t = buffer[band];

                // Computes the expected value:
                double s00 = data.getSampleDouble(i+0, j+0, band);
                double s01 = data.getSampleDouble(i+0, j+1, band);
                double s10 = data.getSampleDouble(i+1, j+0, band);
                double s11 = data.getSampleDouble(i+1, j+1, band);
                double s = interpolation.interpolate(s00, s01, s10, s11, 0, 0);
                assertEquals(s, t, EPS);
            }
        }
    }
View Full Code Here

    public void testCoverageWithNearestInterp() throws MismatchedDimensionException,
            TransformException {
        // Execution of the RasterAsPointCollectionProcess setting hemisphere, scaleFactor and nearest interpolation
        boolean hemisphere = true;
        float scaleFactor = 2.0f;
        Interpolation interp = new InterpolationNearest();
        SimpleFeatureCollection collection = process.execute(coverage, null, scaleFactor, interp,
                hemisphere);
        // Check if the points are exactly as the number of pixel number
        Assert.assertEquals((int) (pixelNumber * scaleFactor * scaleFactor), collection.size());
        // Check if each Point Attribute contains the same values of the Input coverage
View Full Code Here

TOP

Related Classes of javax.media.jai.Interpolation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.