/** * Returns a {@linkplain ROI Region Of Interest} built from the current {@linkplain * #getRenderedImage image}. If the image is multi-bands, then this method first computes an * estimation of its {@linkplain #intensity intensity}. Next, this method {@linkplain * #binarize() binarize} the image and constructs a {@link ROI} from the result. * * @return The image as a region of interest. * @see #getRenderedImage * @see #getPlanarImage * @see #getRenderedOperation */ public final ROI getImageAsROI() { binarize(); return new ROI(getRenderedImage()); }
/** * Post processes a blank image response, eventually making it transparent * * @param finalImage * @return */ public RenderedImage postProcessBlankResponse(RenderedImage finalImage, RenderingHints hints) { // prepare a ROI made of only zeroes ImageLayout layout = new ImageLayout( finalImage.getMinX(), finalImage.getMinY(), finalImage.getWidth(), finalImage.getHeight()); RenderedOp roi = ConstantDescriptor.create( (float) finalImage.getWidth(), (float) finalImage.getHeight(), new Byte[] {0}, new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout)); ImageWorker iw = new ImageWorker(finalImage); iw.setROI(new ROI(roi)); return iw.getRenderedImage(); } }
ROI_THRESHOLDS, rasterROIs.size() + (vectorReference != null ? 1 : 0))); RenderedImage roiMosaic = JAI.create("Mosaic", pb, getRenderingHints()); return new ROI(roiMosaic);
/** * Stop gap measure to get a ROI that can scale up to massive images, until ROIGeometry gets * fixed to be a good ROIShape replacement * * @param theGeom * @return */ private static ROI getAsROI(Geometry theGeom) { org.locationtech.jts.geom.Envelope env = theGeom.getEnvelopeInternal(); int x = (int) Math.floor(env.getMinX()); int y = (int) Math.floor(env.getMinY()); int w = (int) Math.ceil(env.getMaxX()) - x; int h = (int) Math.ceil(env.getMaxY()) - y; ParameterBlockJAI pb = new ParameterBlockJAI("VectorBinarize"); pb.setParameter("minx", x); pb.setParameter("miny", y); pb.setParameter("width", w); pb.setParameter("height", h); pb.setParameter("geometry", PreparedGeometryFactory.prepare(theGeom)); pb.setParameter("antiAliasing", true); RenderedImage roiImage = JAI.create("VectorBinarize", pb, null); return new ROI(roiImage); } }
input.getMinY(), input.getMinY() + input.getHeight()); ROI roi = new ROI(new ROIGeometry(JTS.toGeometry(env)).getAsImage()); PlanarImage pi = PlanarImage.wrapRenderedImage(input); pi.setProperty("ROI", roi);
ROI dstROI = new ROI(roiImage, 1);
PlanarImage.wrapRenderedImage(new WarpRIF().create(paramBlk, localHints)); ROI dstROI = new ROI(roiImage, 1);
/** * Returns a ROI for the validMask, if the a validMask is used. * Check before calling this method if a validMask is used. * * @return the ROI for the valid mask */ private synchronized ROI getValidMaskROI() { if (validMaskROI == null) { synchronized (this) { if (validMaskROI == null) { validMaskROI = new ROI(getValidMaskImage()); } } } return validMaskROI; }
@Override public int[][] getAsBitmask(int x, int y, int width, int height, int[][] mask) { // go the cheap way, only TiledImage seems to be using this method ROI roiImage = new ROI(getAsImage()); return roiImage.getAsBitmask(x, y, width, height, mask); }
@Override public int[][] getAsBitmask(int x, int y, int width, int height, int[][] mask) { // go the cheap way, only TiledImage seems to be using this method ROI roiImage = new ROI(getAsImage()); return roiImage.getAsBitmask(x, y, width, height, mask); }
/** * Returns a {@linkplain ROI Region Of Interest} built from the current * {@linkplain #getRenderedImage image}. If the image is multi-bands, then this method first * computes an estimation of its {@linkplain #intensity intensity}. Next, this method * {@linkplain #binarize() binarize} the image and constructs a {@link ROI} from the result. * * @return The image as a region of interest. * * @see #getRenderedImage * @see #getPlanarImage * @see #getRenderedOperation */ public final ROI getImageAsROI() { binarize(); return new ROI(getRenderedImage()); }
/** * Returns a {@linkplain ROI Region Of Interest} built from the current * {@linkplain #getRenderedImage image}. If the image is multi-bands, then this method first * computes an estimation of its {@linkplain #intensity intensity}. Next, this method * {@linkplain #binarize() binarize} the image and constructs a {@link ROI} from the result. * * @see #getRenderedImage * @see #getPlanarImage * @see #getRenderedOperation */ public final ROI getImageAsROI() { binarize(); return new ROI(getRenderedImage()); }
/** * Returns a ROI based on a binary image, 256x256, white in the left half, black in the right half * @return */ ROI createLeftRightROIImage() { // half image ROI, left and right BufferedImage bi = new BufferedImage(256, 256, BufferedImage.TYPE_BYTE_BINARY); Graphics2D graphics = bi.createGraphics(); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, 128, 256); graphics.dispose(); ROI roiImage = new ROI(bi); return roiImage; }
ImageWorker w = new ImageWorker(image) .setROI(new ROI(new ImageWorker(image).binarize(0).getRenderedImage()));
@Override public LinkedList getAsRectangleList(int x, int y, int width, int height) { Rectangle rect = new Rectangle(x, y, width, height); if (!intersects(rect)) { // no overlap return null; } else if (theGeom.getGeometry().isRectangle()) { // simple case, the geometry is a rectangle to start with Envelope env = theGeom.getGeometry().getEnvelopeInternal(); Envelope intersection = env.intersection(new Envelope(x, x + width, y, y + width)); int rx = (int) Math.round(intersection.getMinX()); int ry = (int) Math.round(intersection.getMinY()); int rw = (int) Math.round(intersection.getMaxX() - rx); int rh = (int) Math.round(intersection.getMaxY() - ry); LinkedList result = new LinkedList(); result.add(new Rectangle(rx, ry, rw, rh)); return result; } else { // we cannot force the base class to use our image, but // we can create a ROI around it ROI roiImage = new ROI(getAsImage()); return roiImage.getAsRectangleList(x, y, width, height); } }
@Override public LinkedList getAsRectangleList(int x, int y, int width, int height) { Rectangle rect = new Rectangle(x, y, width, height); if (!intersects(rect)) { // no overlap return null; } else if (theGeom.getGeometry().isRectangle()) { // simple case, the geometry is a rectangle to start with Envelope env = theGeom.getGeometry().getEnvelopeInternal(); Envelope intersection = env.intersection(new Envelope(x, x + width, y, y + width)); int rx = (int) Math.round(intersection.getMinX()); int ry = (int) Math.round(intersection.getMinY()); int rw = (int) Math.round(intersection.getMaxX() - rx); int rh = (int) Math.round(intersection.getMaxY() - ry); LinkedList result = new LinkedList(); result.add(new Rectangle(rx, ry, rw, rh)); return result; } else { // we cannot force the base class to use our image, but // we can create a ROI around it ROI roiImage = new ROI(getAsImage()); return roiImage.getAsRectangleList(x, y, width, height); } }
@Test public void srcValueWithROI() throws Exception { String src = "dest = src;"; TiledImage srcImg = createSequenceImage(); RenderedImage triangleImage = createTriangleImage(); srcImg.setProperty("ROI", new ROI(triangleImage)); Evaluator evaluator = new Evaluator() { public double eval(double val) { return x > y ? val : Double.NaN; } }; imageParams = new HashMap<>(); imageParams.put("dest", Jiffle.ImageRole.DEST); imageParams.put("src", Jiffle.ImageRole.SOURCE); // test the direct runtime Jiffle jiffle = new Jiffle(src, imageParams); directRuntimeInstance = jiffle.getRuntimeInstance(); directRuntimeInstance.setSourceImage("src", srcImg); TiledImage destImg = ImageUtilities.createConstantImage( srcImg.getMinX(), srcImg.getMinY(), srcImg.getWidth(), srcImg.getHeight(), 0.0); directRuntimeInstance.setDestinationImage("dest", destImg); directRuntimeInstance.evaluateAll(null); assertImage(srcImg, destImg, evaluator); }
int roiThreshold) { ROI roi = new ROI(image, roiThreshold); ParameterBlock pb = new ParameterBlock();
int roiThreshold) { ROI roi = new ROI(image, roiThreshold); ParameterBlock pb = new ParameterBlock();