Package javax.media.jai

Examples of javax.media.jai.ROI


      if (property == null ||
    property.equals(java.awt.Image.UndefinedProperty) ||
    !(property instanceof ROI)) {
    return null;
      }
      ROI srcROI = (ROI)property;

      // Determine the effective source bounds.
      Rectangle srcBounds = null;
      PlanarImage dst = op.getRendering();
      if(dst instanceof WarpOpImage && !((OpImage)dst).hasExtender(0)) {
    WarpOpImage warpIm = (WarpOpImage)dst;
    srcBounds =
        new Rectangle(src.getMinX() + warpIm.getLeftPadding(),
          src.getMinY() + warpIm.getTopPadding(),
          src.getWidth() - warpIm.getWidth() + 1,
          src.getHeight() - warpIm.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 scale factors
      float sx = 1.0F/pb.getIntParameter(1);
      float sy = 1.0F/pb.getIntParameter(2);

      // Create an equivalent transform.
      AffineTransform transform =
    new AffineTransform(sx, 0.0, 0.0, sy, 0, 0);

      // Create the scaled ROI.
      ROI dstROI = srcROI.transform(transform);

      // Retrieve the destination bounds.
      Rectangle dstBounds = op.getBounds();

      // 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;
  } else {
View Full Code Here


                !(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));
            }

            // Set the nearest neighbor interpolation object.
            Interpolation interpNN = interp instanceof InterpolationNearest ?
                interp :
                Interpolation.getInstance(Interpolation.INTERP_NEAREST);

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

            // Create the warped ROI.
            ROI dstROI = new ROI(JAI.create("warp", srcROI.getAsImage(),
                                            warp, interpNN));

            // Retrieve the destination bounds.
            Rectangle dstBounds = op.getBounds();

            // 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

            if (property == null ||
                property.equals(java.awt.Image.UndefinedProperty) ||
                !(property instanceof ROI)) {
                return null;
            }
            ROI srcROI = (ROI)property;

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

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

            // Retrieve the scale factors and translation values.
            double sx = pb.getDoubleParameter(0);
            double sy = pb.getDoubleParameter(1);

            // Create an equivalent transform.
            AffineTransform transform =
                new AffineTransform(sx, 0.0, 0.0, sy, 0, 0);

            // Create the scaled ROI.
            ROI dstROI = srcROI.transform(transform);

            // Retrieve the destination bounds.
            Rectangle dstBounds = op.getBounds();

            // 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;
        } else {
View Full Code Here

            if (property == null ||
                property.equals(java.awt.Image.UndefinedProperty) ||
                !(property instanceof ROI)) {
                return java.awt.Image.UndefinedProperty;
            }
            ROI srcROI = (ROI)property;

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

            // 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 translation values.
            float tx = pb.getFloatParameter(0);
            float ty = pb.getFloatParameter(1);

            // Create a transform representing the translation.
            AffineTransform transform =
                AffineTransform.getTranslateInstance((double) tx,
                                                     (double) ty);
            // Create the translated ROI.
            ROI dstROI = srcROI.transform(transform);

            // Retrieve the destination bounds.
            Rectangle dstBounds = op.getBounds();

            // 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

        ColorQuantizerType algorithm =
            (ColorQuantizerType)paramBlock.getObjectParameter(0);
        int maxColorNum = paramBlock.getIntParameter(1);
        int upperBound = paramBlock.getIntParameter(2);
        ROI roi= (ROI)paramBlock.getObjectParameter(3);
        int xPeriod = paramBlock.getIntParameter(4);
        int yPeriod = paramBlock.getIntParameter(5);

        // check if 3-band byte-type image
  SampleModel sm = source.getSampleModel();
View Full Code Here

            if (property == null ||
                property.equals(java.awt.Image.UndefinedProperty) ||
                !(property instanceof ROI)) {
                return java.awt.Image.UndefinedProperty;
            }
            ROI srcROI = (ROI)property;

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

            // 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());
            }

            // Set the nearest neighbor interpolation object.
            Interpolation interpNN = interp instanceof InterpolationNearest ?
                interp :
                Interpolation.getInstance(Interpolation.INTERP_NEAREST);

            // Retrieve the operation parameters.
            float sv = pb.getFloatParameter(0);
            EnumeratedParameter shearDir =
                (EnumeratedParameter)pb.getObjectParameter(1);
            float tx = pb.getFloatParameter(2);
            float ty = pb.getFloatParameter(3);

            // Create an equivalent transform.
            AffineTransform transform =
                new AffineTransform(1.0,
                                    shearDir == ShearDescriptor.SHEAR_VERTICAL ? sv : 0,
                                    shearDir == ShearDescriptor.SHEAR_HORIZONTAL ? sv : 0,
                                    1.0,
                                    shearDir == ShearDescriptor.SHEAR_HORIZONTAL ? tx : 0,
                                    shearDir == ShearDescriptor.SHEAR_VERTICAL ? ty : 0);

            // Create the sheared ROI.
            ROI dstROI = srcROI.transform(transform);

            // Retrieve the destination bounds.
            Rectangle dstBounds = op.getBounds();

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

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

            if (property == null ||
                property.equals(java.awt.Image.UndefinedProperty) ||
                !(property instanceof ROI)) {
                return java.awt.Image.UndefinedProperty;
            }
            ROI srcROI = (ROI)property;

            // 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 AffineTransform object.
            AffineTransform transform =
                (AffineTransform)pb.getObjectParameter(0);

            // Create the transformed ROI.
            ROI dstROI = srcROI.transform((AffineTransform)transform);

            // Retrieve the destination bounds.
            Rectangle dstBounds = op.getBounds();

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

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

/* 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);
/*    */
/* 62 */     int xStart = source.getMinX();
/* 63 */     int yStart = source.getMinY();
/*    */
/* 65 */     int maxWidth = source.getWidth();
/* 66 */     int maxHeight = source.getHeight();
/*    */
/* 68 */     if ((roi != null) && (!roi.contains(xStart, yStart, maxWidth, maxHeight)))
/*    */     {
/* 70 */       return null;
/*    */     }
/*    */
/* 74 */     if ((xPeriod != 1) || (yPeriod != 1)) {
View Full Code Here

/* 56 */     int yStart = src.getMinY();
/*    */
/* 58 */     int maxWidth = src.getWidth();
/* 59 */     int maxHeight = src.getHeight();
/*    */
/* 61 */     ROI roi = (ROI)args.getObjectParameter(0);
/* 62 */     int xPeriod = args.getIntParameter(1);
/* 63 */     int yPeriod = args.getIntParameter(2);
/* 64 */     int[] numBins = (int[])args.getObjectParameter(3);
/* 65 */     double[] lowValue = (double[])args.getObjectParameter(4);
/* 66 */     double[] highValue = (double[])args.getObjectParameter(5);
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(1);
/*     */
/*  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 */       AffineTransform transform = (AffineTransform)pb.getObjectParameter(0);
/*     */
/* 112 */       ROI dstROI = srcROI.transform(transform);
/*     */
/* 115 */       Rectangle dstBounds = op.getBounds();
/*     */
/* 119 */       if (!dstBounds.contains(dstROI.getBounds())) {
/* 120 */         dstROI = dstROI.intersect(new ROIShape(dstBounds));
/*     */       }
/*     */
/* 124 */       return dstROI;
/*     */     }
/*     */
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.