/** Creates an Roi. */ public static Roi Roi(double x, double y, double width, double height) { return new Roi(x, y, width, height); }
/** Creates an Roi. */ public static Roi Roi(double x, double y, double width, double height) { return new Roi(x, y, width, height); }
/** Creates a rectangular selection. */ public void setRoi(Rectangle r) { setRoi(new Roi(r.x, r.y, r.width, r.height)); }
/** Creates a rectangular selection. */ public void setRoi(Rectangle r) { setRoi(new Roi(r.x, r.y, r.width, r.height)); }
private static Roi enlargeRectOrOval(Roi roi, int n) { Rectangle bounds = roi.getBounds(); bounds.x -= n; bounds.y -= n; bounds.width += 2*n; bounds.height += 2*n; if (bounds.width<=0 || bounds.height<=0) return roi; if (roi.getType()==Roi.RECTANGLE) return new Roi(bounds.x, bounds.y, bounds.width, bounds.height); else return new OvalRoi(bounds.x, bounds.y, bounds.width, bounds.height); }
private static Roi enlargeRectOrOval(Roi roi, int n) { Rectangle bounds = roi.getBounds(); bounds.x -= n; bounds.y -= n; bounds.width += 2*n; bounds.height += 2*n; if (bounds.width<=0 || bounds.height<=0) return roi; if (roi.getType()==Roi.RECTANGLE) return new Roi(bounds.x, bounds.y, bounds.width, bounds.height); else return new OvalRoi(bounds.x, bounds.y, bounds.width, bounds.height); }
@Override public Roi convert(final Box mask) { return new Roi(mask.realMin(0), mask.realMin(1), mask.sideLength(0), mask .sideLength(1)); }
private final static Roi createRoi(Box2D box) { // Coordinates of box, in pixel coordinates double xmin = box.getXMin(); double xmax = box.getXMax(); double ymin = box.getYMin(); double ymax = box.getYMax(); return new Roi(xmin, ymin, xmax - xmin, ymax - ymin); } }
/** Creates a subpixel resolution rectangular selection. */ public static void makeRectangle(double x, double y, double width, double height) { if (width<=0 || height<0) getImage().deleteRoi(); else getImage().setRoi(new Roi(x,y,width,height), !Interpreter.isBatchMode()); }
void invert(ImagePlus imp) { Roi roi = imp.getRoi(); if (roi==null || !roi.isArea()) {IJ.error("Inverse", "Area selection required"); return;} ShapeRoi s1, s2; if (roi instanceof ShapeRoi) s1 = (ShapeRoi)roi; else s1 = new ShapeRoi(roi); s2 = new ShapeRoi(new Roi(0,0, imp.getWidth(), imp.getHeight())); Undo.setup(Undo.ROI, imp); imp.setRoi(s1.xor(s2)); }
/** Creates a subpixel resolution rectangular selection. */ public static void makeRectangle(double x, double y, double width, double height) { if (width<=0 || height<0) getImage().deleteRoi(); else getImage().setRoi(new Roi(x,y,width,height), !Interpreter.isBatchMode()); }
void invert(ImagePlus imp) { Roi roi = imp.getRoi(); if (roi==null || !roi.isArea()) {IJ.error("Inverse", "Area selection required"); return;} ShapeRoi s1, s2; if (roi instanceof ShapeRoi) s1 = (ShapeRoi)roi; else s1 = new ShapeRoi(roi); s2 = new ShapeRoi(new Roi(0,0, imp.getWidth(), imp.getHeight())); Undo.setup(Undo.ROI, imp); imp.setRoi(s1.xor(s2)); }
private Roi createRectangleRoi(final RectangleOverlay overlay) { final RectangleRegionOfInterest region = overlay.getRegionOfInterest(); final int dims = region.numDimensions(); final double[] origin = new double[dims]; final double[] extent = new double[dims]; region.getOrigin(origin); region.getExtent(extent); final double x = origin[0], y = origin[1]; final double w = extent[0], h = extent[1]; final Roi roi = new Roi(x, y, w, h); assignPropertiesToRoi(roi, overlay); return roi; }
void updateRoiList(Rectangle rect) { if (gel==null) return; if (overlay==null) { overlay = new Overlay(); overlay.drawLabels(true); overlay.setLabelColor(Color.white); overlay.drawBackgrounds(true); } overlay.add(new Roi(rect.x, rect.y, rect.width, rect.height, null)); gel.setOverlay(overlay); }
void updateRoiList(Rectangle rect) { if (gel==null) return; if (overlay==null) { overlay = new Overlay(); overlay.drawLabels(true); overlay.setLabelColor(Color.white); overlay.drawBackgrounds(true); } overlay.add(new Roi(rect.x, rect.y, rect.width, rect.height, null)); gel.setOverlay(overlay); }
/** Creates a rectangular selection. Removes any existing selection if width or height are less than 1. */ public static void makeRectangle(int x, int y, int width, int height) { if (width<=0 || height<0) getImage().deleteRoi(); else { ImagePlus img = getImage(); if (Interpreter.isBatchMode()) img.setRoi(new Roi(x,y,width,height), false); else img.setRoi(x, y, width, height); } }
/** Creates a rectangular selection. Removes any existing selection if width or height are less than 1. */ public static void makeRectangle(int x, int y, int width, int height) { if (width<=0 || height<0) getImage().deleteRoi(); else { ImagePlus img = getImage(); if (Interpreter.isBatchMode()) img.setRoi(new Roi(x,y,width,height), false); else img.setRoi(x, y, width, height); } }
void toBoundingBox(ImagePlus imp) { Roi roi = imp.getRoi(); if (roi==null) { noRoi("To Bounding Box"); return; } Undo.setup(Undo.ROI, imp); Rectangle r = roi.getBounds(); imp.deleteRoi(); Roi roi2 = new Roi(r.x, r.y, r.width, r.height); transferProperties(roi, roi2); imp.setRoi(roi2); }
public void setRoi(Rectangle r) { if (null==r) { killRoi(); return; } killRoi(); this.roi = new Roi(r.x, r.y, r.width, r.height); this.roi.setImage(this); ImagePlus imp = patch[currentSlice-1].getProject().getLoader().fetchImagePlus(patch[currentSlice-1]); ImageProcessor ip = imp.getProcessor(); if (null != ip) { ip.setMask(null); ip.setRoi(r); } //draw(); // not needed }
private static ImagePlus segmentBridge(final ImagePlus bridge) { WekaSegmentation segmentator = new WekaSegmentation( bridge ); segmentator.addExample( 0, new Roi( 10, 10, 50, 50 ), 1 ); segmentator.addExample( 1, new Roi( 400, 400, 30, 30 ), 1 ); FastRandomForest rf = (FastRandomForest) segmentator.getClassifier(); rf.setSeed( 69 ); assertTrue( segmentator.trainClassifier() ); segmentator.applyClassifier( false ); return segmentator.getClassifiedImage(); }