Package com.lightcrafts.mediax.jai

Examples of com.lightcrafts.mediax.jai.ROI


           dataType == DataBuffer.TYPE_DOUBLE) {
            return null;
        }

        // Return null if ROI is non-null and not equals to source bounds.
        ROI roi = (ROI)args.getObjectParameter(0);
        if(roi != null &&
           !roi.equals(new Rectangle(src.getMinX(), src.getMinY(),
                                     src.getWidth(), src.getHeight()))) {
            return null;
        }

        // Get the non-ROI parameters.
View Full Code Here


        if (!MediaLibAccessor.isMediaLibCompatible(args)) {
            return null;
        }

  RenderedImage source = args.getRenderedSource(0);
  ROI roi = (ROI)args.getObjectParameter(0);
        int xPeriod = args.getIntParameter(1);
        int yPeriod = args.getIntParameter(2);
  boolean saveLocations = ((Boolean)args.getObjectParameter(3)).booleanValue();
  int maxRuns = args.getIntParameter(4);
 
        int xStart = source.getMinX()// default values
        int yStart = source.getMinY();

        int maxWidth = source.getWidth();
        int maxHeight = source.getHeight();

  if (roi != null &&
      !roi.contains(xStart, yStart, maxWidth, maxHeight)) {
      return null;
  }

        return new MlibExtremaOpImage(source,
              roi,
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

            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(3);

            // 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 and rotation angle.
      double xorig = (double)pb.getFloatParameter(0);
      double yorig = (double)pb.getFloatParameter(1);
            double angle = (double)pb.getFloatParameter(2);

            // Create an transform representing the rotation.
            AffineTransform transform =
        AffineTransform.getRotateInstance(angle, xorig, yorig);

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

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

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

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

            if(roiProperty == null ||
               roiProperty == java.awt.Image.UndefinedProperty ||
               !(roiProperty instanceof ROI)) {
                return java.awt.Image.UndefinedProperty;
            }
            ROI roi = (ROI)roiProperty;

            // Determine the effective destination bounds.
            Rectangle dstBounds = null;
            PlanarImage dst = op.getRendering();
            if(dst instanceof AreaOpImage &&
               ((AreaOpImage)dst).getBorderExtender() == null) {
                AreaOpImage aoi = (AreaOpImage)dst;
                dstBounds =
                    new Rectangle(aoi.getMinX() + aoi.getLeftPadding(),
                                  aoi.getMinY() + aoi.getTopPadding(),
                                  aoi.getWidth() -
                                  aoi.getLeftPadding() -
                                  aoi.getRightPadding(),
                                  aoi.getHeight() -
                                  aoi.getTopPadding() -
                                  aoi.getBottomPadding());
            } else {
                dstBounds = dst.getBounds();
            }

            // If necessary, clip the ROI to the destination bounds.
            // XXX Is this desirable?
            if(!dstBounds.contains(roi.getBounds())) {
                roi = roi.intersect(new ROIShape(dstBounds));
            }

            return roi;
        }
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;
            }

            /// This should really create a proper AffineTransform
            /// and transform the ROI with it to avoid forcing
            /// ROI.getAsImage to be called.

            // Retrieve the transpose type and create a nearest neighbor
            // Interpolation object.
            TransposeType transposeType =
                (TransposeType)pb.getObjectParameter(0);
            Interpolation interp =
                Interpolation.getInstance(Interpolation.INTERP_NEAREST);

            // Return the transposed ROI.
            return new ROI(JAI.create("transpose", srcROI.getAsImage(),
                                      transposeType));
        }

        return java.awt.Image.UndefinedProperty;
    }
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(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

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

            // 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.
            float sx = pb.getFloatParameter(0);
            float sy = pb.getFloatParameter(1);
            float tx = pb.getFloatParameter(2);
            float ty = pb.getFloatParameter(3);

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

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

TOP

Related Classes of com.lightcrafts.mediax.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.