Package javax.media.jai

Examples of javax.media.jai.WarpAffine


    double m11 = 1; // scale y
    double m02 = 0; // translation in x direction
    double m12 = 0; // translation in y direction
    AffineTransform transform = new AffineTransform(m00, m10, m01, m11,
        m02, m12);
    WarpAffine warp = new WarpAffine(transform);
    pb = new java.awt.image.renderable.ParameterBlock();
    pb.addSource(subImg);
    pb.add(warp);
    pb.add(interp);
    subImg = JAI.create("warp", pb);
View Full Code Here


    @Test
    public void testAdapter() {
        final AffineTransform atr = AffineTransform.getScaleInstance(0.25, 0.5);
        atr.translate(4, 2);
        final AffineTransform2D transform = new AffineTransform2D(atr);
        final WarpAffine        warp      = new WarpAffine       (atr);
        final WarpAdapter       adapter   = new WarpAdapter("test", transform);
        final Random            random    = new Random(-854734760285695284L);
        for (int i=0; i<200; i++) {
            Point2D source   = new Point2D.Double(random.nextDouble()*100, random.nextDouble()*100);
            Point2D expected = warp   .mapDestPoint(source);
            Point2D computed = adapter.mapDestPoint(source);
            assertEquals("X", expected.getX(), computed.getX(), 1E-5);
            assertEquals("Y", expected.getY(), computed.getY(), 1E-5);

            // Try inverse transform.
            expected = warp   .mapSourcePoint(source);
            computed = adapter.mapSourcePoint(source);
            assertEquals("X", expected.getX(), computed.getX(), 1E-5);
            assertEquals("Y", expected.getY(), computed.getY(), 1E-5);

            // Try warpPoint
            final float[] exp = warp   .warpPoint((int)source.getX(), (int)source.getY(), null);
            final float[] com = adapter.warpPoint((int)source.getX(), (int)source.getY(), null);
            assertEquals("X", exp[0], com[0], 1E-5);
            assertEquals("Y", exp[1], com[1], 1E-5);
        }
    }
View Full Code Here

            final float   preScaleY = scale( PRE_SCALE_Y, values);
            final float  postScaleX = scale(POST_SCALE_X, values);
            final float  postScaleY = scale(POST_SCALE_Y, values);
            final Warp warp;
            switch (degree) {
                case 1:  warp = new WarpAffine           (xCoeffs, yCoeffs, preScaleX, preScaleY, postScaleX, postScaleY); break;
                case 2:  warp = new WarpQuadratic        (xCoeffs, yCoeffs, preScaleX, preScaleY, postScaleX, postScaleY); break;
                case 3:  warp = new WarpCubic            (xCoeffs, yCoeffs, preScaleX, preScaleY, postScaleX, postScaleY); break;
                default: warp = new WarpGeneralPolynomial(xCoeffs, yCoeffs, preScaleX, preScaleY, postScaleX, postScaleY); break;
            }
            return new WarpTransform2D(warp, (Warp)null);
View Full Code Here

        final int h = originalImage.getHeight();

        // Getting parameters for doing a scale.
        final ParameterValueGroup param = processor.getOperation("Warp").getParameters();
        param.parameter("Source").setValue(coverage);
        param.parameter("warp").setValue(new WarpAffine(AffineTransform.getScaleInstance(2, 2)));
        param.parameter("Interpolation").setValue(interp);

        // Doing a first scale.
        final ImageLayout2 layout= new ImageLayout2(0,0,(int)(w / 2.0),(int)(h / 2.0));
        GridCoverage2D scaled = (GridCoverage2D) processor.doOperation(param, new Hints(JAI.KEY_IMAGE_LAYOUT,layout));
View Full Code Here

            } else {
                // interpolate coverage if requested and not nearest!!!!        
                final Operation operation = CoverageProcessor.getInstance().getOperation("Warp");
                final ParameterValueGroup parameters = operation.getParameters();
                parameters.parameter("Source").setValue(coverage);
                parameters.parameter("warp").setValue(new WarpAffine(AffineTransform.getScaleInstance(1, 1)));//identity
                parameters.parameter("interpolation").setValue(spatialInterpolation!=null?spatialInterpolation:InterpolationPolicy.getDefaultPolicy().getInterpolation());
                parameters.parameter( "backgroundValues").setValue(CoverageUtilities.getBackgroundValues(coverage));// TODO check and improve
                return (GridCoverage2D) CoverageProcessor.getInstance().doOperation(parameters,hints);
            }
        }
View Full Code Here

TOP

Related Classes of javax.media.jai.WarpAffine

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.