Package com.lightcrafts.mediax.jai

Examples of com.lightcrafts.mediax.jai.ROIShape


            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


            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

    }

    protected synchronized void train() {
        PlanarImage source = getSourceImage(0);
        if (roi == null)
            roi = new ROIShape(source.getBounds());

        // Cycle throw all source tiles.
        int minTileX = source.getMinTileX();
        int maxTileX = source.getMaxTileX();
        int minTileY = source.getMinTileY();
View Full Code Here

                // from source renderable coordinates to destination
                // rendered coordinates.
                at.preConcatenate(renderContext.getTransform());

                // Create an ROI in destination rendered space.
                ROIShape roi = new ROIShape(at.createTransformedShape(rgn));

                // Create a TiledImage to contain the masked result.
                TiledImage ti = new TiledImage(rendering.getMinX(),
                                               rendering.getMinY(),
                                               rendering.getWidth(),
                                               rendering.getHeight(),
                                               rendering.getTileGridXOffset(),
                                               rendering.getTileGridYOffset(),
                                               rendering.getSampleModel(),
                                               rendering.getColorModel());

                // Set the TiledImage data source to the rendering.
                ti.set(rendering, roi);

                // Create a constant-valued image for the background.
                pb = new ParameterBlock();
                pb.add((float)ti.getWidth());
                pb.add((float)ti.getHeight());
                Byte[] bandValues =
                    new Byte[ti.getSampleModel().getNumBands()];
                for(int b = 0; b < bandValues.length; b++) {
                    bandValues[b] = new Byte((byte)255);
                }
                pb.add(bandValues);

                ImageLayout il = new ImageLayout();
                il.setSampleModel(ti.getSampleModel());
                RenderingHints rh = new RenderingHints(JAI.KEY_IMAGE_LAYOUT,
                                                       il);

                PlanarImage constImage = JAI.create("constant", pb, rh);

                // Compute a complement ROI.
                ROI complementROI =
                    (new ROIShape(ti.getBounds())).subtract(roi);;

                // Fill the background.
                int maxTileY = ti.getMaxTileY();
                int maxTileX = ti.getMaxTileX();
                for(int j = ti.getMinTileY(); j <= maxTileY; j++) {
                    for(int i = ti.getMinTileX(); i <= maxTileX; i++) {
                        if(!roi.intersects(ti.getTileRect(i, j))) {
                            ti.setData(constImage.getTile(i, j),
                                       complementROI);
                        }
                    }
                }
View Full Code Here

TOP

Related Classes of com.lightcrafts.mediax.jai.ROIShape

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.