Package javax.media.jai

Examples of javax.media.jai.ROI


                !(property instanceof ROI)) {
                return java.awt.Image.UndefinedProperty;
            }

            // Return undefined also if source ROI is empty.
            ROI srcROI = (ROI)property;
            if (srcROI.getBounds().isEmpty()) {
                return java.awt.Image.UndefinedProperty;
            }

            // Retrieve the Interpolation object.
            Interpolation interp = (Interpolation)pb.getObjectParameter(1);

            // Determine the effective source bounds.
            Rectangle srcBounds = null;
            PlanarImage dst = op.getRendering();
            if (dst instanceof GeometricOpImage &&
                ((GeometricOpImage)dst).getBorderExtender() == null) {
                srcBounds =
                    new Rectangle(src.getMinX() + interp.getLeftPadding(),
                                  src.getMinY() + interp.getTopPadding(),
                                  src.getWidth() - interp.getWidth() + 1,
                                  src.getHeight() - interp.getHeight() + 1);
            } else {
                srcBounds = new Rectangle(src.getMinX(),
                     src.getMinY(),
                     src.getWidth(),
                     src.getHeight());
            }

            // If necessary, clip the ROI to the effective source bounds.
            if(!srcBounds.contains(srcROI.getBounds())) {
                srcROI = srcROI.intersect(new ROIShape(srcBounds));
            }

            // Retrieve the Warp object.
            Warp warp = (Warp)pb.getObjectParameter(0);

            // Setting constant image to be warped as a ROI
            Rectangle dstBounds = op.getBounds();
           
            // Setting layout of the constant image
            ImageLayout2 layout = new ImageLayout2();
            int minx = (int) srcBounds.getMinX();
            int miny = (int) srcBounds.getMinY();
            int w = (int) srcBounds.getWidth();
            int h = (int) srcBounds.getHeight();
            layout.setMinX(minx);
            layout.setMinY(miny);
            layout.setWidth(w);
            layout.setHeight(h);
            RenderingHints hints = op.getRenderingHints();
            hints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout));
           
            final PlanarImage constantImage = ConstantDescriptor.create(new Float(w), new Float(h), new Byte[]{(byte)255}, hints);
           
            PlanarImage roiImage = null;
           
            // Make sure to specify tileCache, tileScheduler, tileRecyclier, by cloning hints.
            RenderingHints warpingHints = op.getRenderingHints();
            warpingHints.remove(JAI.KEY_IMAGE_LAYOUT);
           
            // Creating warped roi by the same way (Warp, Interpolation, source ROI) we warped the
            // input image.
            final ParameterBlock paramBlk = new ParameterBlock();
            paramBlk.addSource(constantImage);
            paramBlk.add(warp);
            paramBlk.add(interp);
            paramBlk.add(null);
            paramBlk.add(srcROI);

            // force in the image layout, this way we get exactly the same
            // as the affine we're eliminating
            Hints localHints = new Hints(op.getRenderingHints());
            localHints.remove(JAI.KEY_IMAGE_LAYOUT);
            ImageLayout il = new ImageLayout();
            il.setMinX(dstBounds.x);
            il.setMinY(dstBounds.y);
            il.setWidth(dstBounds.width);
            il.setHeight(dstBounds.height);
            localHints.put(JAI.KEY_IMAGE_LAYOUT, il);
            roiImage = JAI.create("Warp", paramBlk, localHints);
            ROI dstROI = new ROI(roiImage, 1);

            // If necessary, clip the warped ROI to the destination bounds.
            if(!dstBounds.contains(dstROI.getBounds())) {
                dstROI = dstROI.intersect(new ROIShape(dstBounds));
            }

            // Return the warped and possibly clipped ROI.
            return dstROI;
        }
View Full Code Here


                            .getParameters();
                    param.parameter("Source").setValue(gridCoverage2D);
                    param.parameter("Envelope").setValue(new GeneralEnvelope(bbox));
                    final GridCoverage2D cropped = (GridCoverage2D) processor.doOperation(param);

                    ROI roi = null;
                    final int numGeometries = geometry.getNumGeometries();
                    for (int i = 0; i < numGeometries; i++) {
                        Geometry geometryN = geometry.getGeometryN(i);
                        java.awt.Polygon awtPolygon = toAWTPolygon((Polygon) geometryN,
                                worldToGridTransform);
                        if (roi == null) {
                            roi = new ROIShape(awtPolygon);
                        } else {
                            ROI newRoi = new ROIShape(awtPolygon);
                            roi.add(newRoi);
                        }
                    }

                    final Statistic[] statistis = statisticsSet.toArray(new Statistic[statisticsSet
View Full Code Here

     * @see #getPlanarImage
     * @see #getRenderedOperation
     */
    public final ROI getImageAsROI() {
        binarize();
        return new ROI(getRenderedImage());
    }
View Full Code Here

        // Ensure equal images inside ROI. This requires cropping the images
       
        // World to grid transform for mapping the ROI in the Raster apsce
        MathTransform2D tr = coverage1.getGridGeometry().getCRSToGrid2D(PixelOrientation.UPPER_LEFT);
        // ROI object inthe Raster Space
        ROI roi = new ROIGeometry(JTS.transform(geo, tr));
        // This ROI is a Rectangle so we can get its bounds
        Rectangle roiBounds = roi.getBounds();
        // Crop the source image with the ROI Bounds
        RenderedImage cropSrc = CropDescriptor.create(srcImg1, (float)roiBounds.x,
            (float)roiBounds.y, (float)roiBounds.width, (float)roiBounds.height, null);
       
        // Coverage Crop for the final coverages
View Full Code Here

    private void ensureNoDataOutside(GridCoverage2D coverage, Geometry geom)
            throws MismatchedDimensionException, TransformException {
        // World to Grid transform used to project the Geometry to the RasterSpace
        MathTransform w2g = coverage.getGridGeometry().getCRSToGrid2D(PixelOrientation.UPPER_LEFT);
        // ROI in raster space
        ROI roi = new ROIGeometry(JTS.transform(geom, w2g));
        // Approximate bounds by expanding them by one (coordinates are taken with a 0.5 offset)
        Rectangle rect = roi.getBounds();
        rect.grow(1, 1);
        // No data value to use
        double nodata = CoverageUtilities.getBackgroundValues(coverage)[0];

        // Cycle on the image Bounds in order to search if No Data are present
View Full Code Here

               
                at.setToTranslation(-0.5, -0.5);
                simplifiedGeometry.apply(at);
               
                // build a shape using a fast point in polygon wrapper
                ROI roi = new ROIGeometry(simplifiedGeometry, false);

                // run the stats via JAI
                Statistic[] reqStatsArr = new Statistic[] { Statistic.MAX, Statistic.MIN,
                        Statistic.RANGE, Statistic.MEAN, Statistic.SDEV, Statistic.SUM };
                final ZonalStatsOpImage zsOp = new ZonalStatsOpImage(cropped.getRenderedImage(),
View Full Code Here

TOP

Related Classes of javax.media.jai.ROI

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.