Package javax.media.jai

Examples of javax.media.jai.ROI


/* 53 */     if (!MediaLibAccessor.isMediaLibCompatible(args)) {
/* 54 */       return null;
/*    */     }
/*    */
/* 57 */     RenderedImage source = args.getRenderedSource(0);
/* 58 */     ROI roi = (ROI)args.getObjectParameter(0);
/* 59 */     int xPeriod = args.getIntParameter(1);
/* 60 */     int yPeriod = args.getIntParameter(2);
/* 61 */     boolean saveLocations = ((Boolean)args.getObjectParameter(3)).booleanValue();
/* 62 */     int maxRuns = args.getIntParameter(4);
/*    */
/* 64 */     int xStart = source.getMinX();
/* 65 */     int yStart = source.getMinY();
/*    */
/* 67 */     int maxWidth = source.getWidth();
/* 68 */     int maxHeight = source.getHeight();
/*    */
/* 70 */     if ((roi != null) && (!roi.contains(xStart, yStart, maxWidth, maxHeight)))
/*    */     {
/* 72 */       return null;
/*    */     }
/*    */
/* 75 */     return new MlibExtremaOpImage(source, roi, xStart, yStart, xPeriod, yPeriod, saveLocations, maxRuns);
View Full Code Here


/*  87 */       Object property = src.getProperty("ROI");
/*  88 */       if ((property == null) || (property.equals(Image.UndefinedProperty)) || (!(property instanceof ROI)))
/*     */       {
/*  91 */         return null;
/*     */       }
/*  93 */       ROI srcROI = (ROI)property;
/*     */
/*  96 */       Rectangle srcBounds = null;
/*  97 */       PlanarImage dst = op.getRendering();
/*  98 */       if (((dst instanceof WarpOpImage)) && (!((OpImage)dst).hasExtender(0))) {
/*  99 */         WarpOpImage warpIm = (WarpOpImage)dst;
/* 100 */         srcBounds = new Rectangle(src.getMinX() + warpIm.getLeftPadding(), src.getMinY() + warpIm.getTopPadding(), src.getWidth() - warpIm.getWidth() + 1, src.getHeight() - warpIm.getHeight() + 1);
/*     */       }
/*     */       else
/*     */       {
/* 106 */         srcBounds = new Rectangle(src.getMinX(), src.getMinY(), src.getWidth(), src.getHeight());
/*     */       }
/*     */
/* 113 */       if (!srcBounds.contains(srcROI.getBounds())) {
/* 114 */         srcROI = srcROI.intersect(new ROIShape(srcBounds));
/*     */       }
/*     */
/* 118 */       float sx = 1.0F / pb.getIntParameter(1);
/* 119 */       float sy = 1.0F / pb.getIntParameter(2);
/*     */
/* 122 */       AffineTransform transform = new AffineTransform(sx, 0.0D, 0.0D, sy, 0.0D, 0.0D);
/*     */
/* 126 */       ROI dstROI = srcROI.transform(transform);
/*     */
/* 129 */       Rectangle dstBounds = op.getBounds();
/*     */
/* 132 */       if (!dstBounds.contains(dstROI.getBounds())) {
/* 133 */         dstROI = dstROI.intersect(new ROIShape(dstBounds));
/*     */       }
/*     */
/* 137 */       return dstROI;
/*     */     }
/* 139 */     return null;
View Full Code Here

/*    */
/* 74 */     ColorQuantizerType algorithm = (ColorQuantizerType)paramBlock.getObjectParameter(0);
/*    */
/* 76 */     int maxColorNum = paramBlock.getIntParameter(1);
/* 77 */     int upperBound = paramBlock.getIntParameter(2);
/* 78 */     ROI roi = (ROI)paramBlock.getObjectParameter(3);
/* 79 */     int xPeriod = paramBlock.getIntParameter(4);
/* 80 */     int yPeriod = paramBlock.getIntParameter(5);
/*    */
/* 83 */     SampleModel sm = source.getSampleModel();
/* 84 */     if ((sm.getNumBands() != 3) && (sm.getDataType() == 0)) {
View Full Code Here

/*  74 */       Object property = src.getProperty("ROI");
/*  75 */       if ((property == null) || (property.equals(Image.UndefinedProperty)) || (!(property instanceof ROI)))
/*     */       {
/*  78 */         return Image.UndefinedProperty;
/*     */       }
/*  80 */       ROI srcROI = (ROI)property;
/*     */
/*  83 */       Interpolation interp = (Interpolation)pb.getObjectParameter(2);
/*     */
/*  86 */       Rectangle srcBounds = null;
/*  87 */       PlanarImage dst = op.getRendering();
/*  88 */       if (((dst instanceof GeometricOpImage)) && (((GeometricOpImage)dst).getBorderExtender() == null))
/*     */       {
/*  90 */         srcBounds = new Rectangle(src.getMinX() + interp.getLeftPadding(), src.getMinY() + interp.getTopPadding(), src.getWidth() - interp.getWidth() + 1, src.getHeight() - interp.getHeight() + 1);
/*     */       }
/*     */       else
/*     */       {
/*  96 */         srcBounds = new Rectangle(src.getMinX(), src.getMinY(), src.getWidth(), src.getHeight());
/*     */       }
/*     */
/* 103 */       if (!srcBounds.contains(srcROI.getBounds())) {
/* 104 */         srcROI = srcROI.intersect(new ROIShape(srcBounds));
/*     */       }
/*     */
/* 108 */       float tx = pb.getFloatParameter(0);
/* 109 */       float ty = pb.getFloatParameter(1);
/*     */
/* 112 */       AffineTransform transform = AffineTransform.getTranslateInstance(tx, ty);
/*     */
/* 116 */       ROI dstROI = srcROI.transform(transform);
/*     */
/* 119 */       Rectangle dstBounds = op.getBounds();
/*     */
/* 122 */       if (!dstBounds.contains(dstROI.getBounds())) {
/* 123 */         dstROI = dstROI.intersect(new ROIShape(dstBounds));
/*     */       }
/*     */
/* 127 */       return dstROI;
/*     */     }
/*     */
View Full Code Here

/*  73 */       Object property = src.getProperty("ROI");
/*  74 */       if ((property == null) || (property.equals(Image.UndefinedProperty)) || (!(property instanceof ROI)))
/*     */       {
/*  77 */         return Image.UndefinedProperty;
/*     */       }
/*  79 */       ROI srcROI = (ROI)property;
/*     */
/*  82 */       Rectangle srcBounds = new Rectangle(src.getMinX(), src.getMinY(), src.getWidth(), src.getHeight());
/*     */
/*  88 */       if (!srcBounds.contains(srcROI.getBounds())) {
/*  89 */         srcROI = srcROI.intersect(new ROIShape(srcBounds));
/*     */       }
/*     */
/*  93 */       float sx = pb.getFloatParameter(0);
/*  94 */       float sy = pb.getFloatParameter(1);
/*     */
/*  97 */       AffineTransform transform = new AffineTransform(sx, 0.0D, 0.0D, sy, 0.0D, 0.0D);
/*     */
/* 101 */       ROI dstROI = srcROI.transform(transform);
/*     */
/* 104 */       Rectangle dstBounds = op.getBounds();
/*     */
/* 107 */       if (!dstBounds.contains(dstROI.getBounds())) {
/* 108 */         dstROI = dstROI.intersect(new ROIShape(dstBounds));
/*     */       }
/*     */
/* 112 */       return dstROI;
/*     */     }
/*     */
View Full Code Here

      //
      // /////////////////////////////////////////////////////////////////////
      final RenderedImage image = getSWAN();
      if (TestData.isInteractiveTest())
          ImageIOUtilities.visualize(image, "testSWANLOGARITHMIC");
      final RenderedOp statistics = ExtremaDescriptor.create(image, new ROI(new ImageWorker(image).binarize(0).getRenderedImage()),
          new Integer(1), new Integer(1), Boolean.FALSE, new Integer(1),
          null);
      final double[] minimum=(double[]) statistics.getProperty("minimum");
      final double[] maximum=(double[]) statistics.getProperty("maximum");
     
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(
View Full Code Here

        this.numBands = sampleModel.getNumBands();
       
        this.filterSize = filterSize;
       
        // Save the ROI array.
        ROI thresholdRoi = null;
        if (sourceROI != null){           
            RenderedImage image = inputRI;
            if (threshold != Integer.MAX_VALUE){
                if (numBands == 3) {
                    image = BandCombineDescriptor.create(image, RGB_TO_GRAY_MATRIX, null);
                } else {
                        //do we have transparency
                        //combination matrix
                       
                        final double fillValue = tr == Transparency.OPAQUE ? 1.0/numBands : 1.0/(numBands-1);
                       
                        final double[][] matrix = new double[1][numBands + 1];
                        for (int i=0; i < numBands; i++) {
                                matrix[0][i] = fillValue;
                        }
   
                        image = BandCombineDescriptor.create(image, matrix, null);
                }
                    thresholdRoi = new ROI(image, threshold);
                    thresholdRoi = thresholdRoi.intersect(sourceROI);
            }
        }
       
        // Copy the background values per the specification.
        this.backgroundValues = new double[numBands];
View Full Code Here

            // ROI
            //
            // we need to add its roi in order to avoid problems with the mosaics sources overlapping
            final Rectangle bounds = PlanarImage.wrapRenderedImage(granule).getBounds();
            Geometry mask = JTS.toGeometry(new Envelope(bounds.getMinX(), bounds.getMaxX(), bounds.getMinY(), bounds.getMaxY()));
            ROI imageROI = new ROIGeometry(mask);           
            if (footprintBehavior.handleFootprints()){

               
                // get the real footprint
                final ROI footprint = result.getFootprint();
                if (footprint != null) {
                    if (imageROI.contains(footprint.getBounds2D().getBounds())) {
                        imageROI = footprint;
                    } else {
                        imageROI = imageROI.intersect(footprint);
                    }
                }
View Full Code Here

                    throw new NullPointerException("The list of MosaicElements contains one element but it's null");
                }
                PAMDataset pamDataset = in.pamDataset;
   
                // the roi is exactly equal to the image
                ROI roi = in.roi;
                if (roi != null) {
                    Rectangle bounds = Utils.toRectangle(roi.getAsShape());
                    if(bounds!=null){
                        RenderedImage mosaic = in.source;
                        Rectangle imageBounds = PlanarImage.wrapRenderedImage(mosaic).getBounds();
                        if (imageBounds.equals(bounds)) {
   
                            // do we need to crop? (image is bigger than requested?)
                            if (!rasterBounds.contains(imageBounds)) {
                                // we have to crop
                                XRectangle2D.intersect(imageBounds, rasterBounds, imageBounds);
   
                                if (imageBounds.isEmpty()) {
                                    // return back a constant image
                                    return null;
                                }
                                // crop
                                ImageWorker iw = new ImageWorker(mosaic);
                                iw.setRenderingHints(localHints);
                                iw.crop(imageBounds.x, imageBounds.y, imageBounds.width, imageBounds.height);
                                mosaic = iw.getRenderedImage();
                                imageBounds = PlanarImage.wrapRenderedImage(mosaic).getBounds();
                            }
   
                            // and, do we need to add a BORDER around the image?
                            if (!imageBounds.contains(rasterBounds)) {
                                mosaic = MergeBehavior.FLAT
                                        .process(
                                                new RenderedImage[] { mosaic },
                                                backgroundValues,
                                                sourceThreshold,
                                                (hasAlpha || doInputTransparency) ? new PlanarImage[] { in.alphaChannel }: new PlanarImage[] { null },
                                                new ROI[] { in.roi },
                                                request.isBlend() ? MosaicDescriptor.MOSAIC_TYPE_BLEND: MosaicDescriptor.MOSAIC_TYPE_OVERLAY,
                                                localHints);
                                roi=roi.add(new ROIGeometry(JTS.toGeometry(new ReferencedEnvelope(rasterBounds, null))));
                                if (footprintBehavior!=FootprintBehavior.None) {
                                    // Adding globalRoi to the output
                                    RenderedOp rop = (RenderedOp) mosaic;
                                    rop.setProperty("ROI", in.roi);
                                }
                            }
   
                        // add to final list
                        return new MosaicElement(in.alphaChannel, roi, mosaic, pamDataset);
                    }
                }
            }
            }

            // === do the mosaic as usual
            // prepare sources for the mosaic operation
            final RenderedImage[] sources = new RenderedImage[size];
            final PlanarImage[] alphas = new PlanarImage[size];
            ROI[] rois = new ROI[size];
            final PAMDataset[] pams = new PAMDataset[size];
            int realROIs=0;
            for (int i = 0; i < size; i++) {
                final MosaicElement mosaicElement = inputs.get(i);
                sources[i] = mosaicElement.source;
                alphas[i] = mosaicElement.alphaChannel;
                rois[i] = mosaicElement.roi;
                pams[i] = mosaicElement.pamDataset;

                // compose the overall ROI if needed
                if (mosaicElement.roi != null) {
                    realROIs++;
                }
            }
            if (realROIs == 0){
                rois = null;
            }


            // execute mosaic
            final RenderedImage mosaic =
                mergeBehavior.process(
                        sources,
                        backgroundValues,
                        sourceThreshold,
                        (hasAlpha || doInputTransparency) ? alphas : null,
                        rois,
                        request.isBlend() ? MosaicDescriptor.MOSAIC_TYPE_BLEND: MosaicDescriptor.MOSAIC_TYPE_OVERLAY,
                        localHints);
           
            ROI overallROI = mosaicROIs(rois);
            if (footprintBehavior != FootprintBehavior.None) {
                // Adding globalRoi to the output
                RenderedOp rop = (RenderedOp) mosaic;               
                rop.setProperty("ROI", overallROI);
            }
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.