boolean isLineSelection() { return roi!=null && roi.isLine(); }
boolean isLineSelection() { return roi!=null && roi.isLine(); }
ImagePlus imp = WindowManager.getCurrentImage(); double lineLength = 0; Roi roi = imp.getRoi(); if (roi != null && roi.isLine()) { lineLength = roi.getLength(); }
public void updateWideLine(float width) { if (isLine()) { wideLine = true; setStrokeWidth(width); if (getStrokeColor()==null) { Color c = getColor(); setStrokeColor(new Color(c.getRed(),c.getGreen(),c.getBlue(), 77)); } } }
public void updateWideLine(float width) { if (isLine()) { wideLine = true; setStrokeWidth(width); if (getStrokeColor()==null) { Color c = getColor(); setStrokeColor(new Color(c.getRed(),c.getGreen(),c.getBlue(), 77)); } } }
/** Returns the coordinates of the pixels inside this ROI as an array of Points. * @see #getContainedFloatPoints() * @see #iterator() */ public Point[] getContainedPoints() { if (isLine()) { FloatPolygon p = getInterpolatedPolygon(); Point[] points = new Point[p.npoints]; for (int i=0; i<p.npoints; i++) points[i] = new Point((int)Math.round(p.xpoints[i]),(int)Math.round(p.ypoints[i])); return points; } ImageProcessor mask = getMask(); Rectangle bounds = getBounds(); ArrayList points = new ArrayList(); for (int y=0; y<bounds.height; y++) { for (int x=0; x<bounds.width; x++) { if (mask==null || mask.getPixel(x,y)!=0) points.add(new Point(this.x+x,this.y+y)); } } return (Point[])points.toArray(new Point[points.size()]); }
public Plot getPlot() { Roi roi = imp.getRoi(); if (roi==null || !(roi.isLine()||roi.getType()==Roi.RECTANGLE)) { if (firstTime) IJ.error("Plot Profile", "Line or rectangular selection required"); return null; } ProfilePlot pp = new ProfilePlot(imp, plotVertically); return pp.getPlot(); }
public Plot getPlot() { Roi roi = imp.getRoi(); if (roi==null || !(roi.isLine()||roi.getType()==Roi.RECTANGLE)) { if (firstTime) IJ.error("Plot Profile", "Line or rectangular selection required"); return null; } ProfilePlot pp = new ProfilePlot(imp, plotVertically); return pp.getPlot(); }
private void lineToArea(ImagePlus imp) { Roi roi = imp.getRoi(); if (roi==null || !roi.isLine()) {IJ.error("Line to Area", "Line selection required"); return;} Undo.setup(Undo.ROI, imp); Roi roi2 = lineToArea(roi); imp.setRoi(roi2); Roi.previousRoi = (Roi)roi.clone(); }
float[] getZAxisProfile(){ Roi roi = imp.getRoi(); if (roi!=null && roi.isLine()) { IJ.error("ZAxisProfiler", "This command does not work with line selections."); return null; } ImageProcessor ip = imp.getProcessor(); double minThreshold = ip.getMinThreshold(); double maxThreshold = ip.getMaxThreshold(); return getZAxisProfile(roi, minThreshold, maxThreshold); } //Adapted from ImageJ code by Wayne Rasband
private void lineToArea(ImagePlus imp) { Roi roi = imp.getRoi(); if (roi==null || !roi.isLine()) {IJ.error("Line to Area", "Line selection required"); return;} Undo.setup(Undo.ROI, imp); Roi roi2 = lineToArea(roi); imp.setRoi(roi2); Roi.previousRoi = (Roi)roi.clone(); }
RoiPointsIteratorMask() { if (isLine()) { Roi roi2 = Selection.lineToArea(Roi.this); mask = roi2.getMask(); bounds = roi2.getBounds(); xbase = roi2.x; ybase = roi2.y; } else { mask = getMask(); bounds = getBounds(); xbase = Roi.this.x; ybase = Roi.this.y; } n = bounds.width * bounds.height; findNext(0); // sets next }
public int setup(String arg, ImagePlus imp) { this.imp = imp; mainThread = Thread.currentThread(); if (imp==null) {IJ.noImage(); return DONE;} if (arg.equals("final")&&imp.getRoi()==null) { imp.getProcessor().resetMinAndMax(); imp.updateAndDraw(); return DONE; } IJ.resetEscape(); Roi roi = imp.getRoi(); isLineRoi= roi!=null && roi.isLine(); nSlices = imp.getStackSize(); if (imp.getStackSize()==1) flags |= PARALLELIZE_IMAGES; else flags |= PARALLELIZE_STACKS; imp.startTiming(); return flags; }
RoiPointsIteratorMask() { if (isLine()) { Roi roi2 = Selection.lineToArea(Roi.this); mask = roi2.getMask(); bounds = roi2.getBounds(); xbase = roi2.x; ybase = roi2.y; } else { mask = getMask(); bounds = getBounds(); xbase = Roi.this.x; ybase = Roi.this.y; } n = bounds.width * bounds.height; findNext(0); // sets next }
public int setup(String arg, ImagePlus imp) { this.imp = imp; mainThread = Thread.currentThread(); if (imp==null) {IJ.noImage(); return DONE;} if (arg.equals("final")&&imp.getRoi()==null) { imp.getProcessor().resetMinAndMax(); imp.updateAndDraw(); return DONE; } IJ.resetEscape(); Roi roi = imp.getRoi(); isLineRoi= roi!=null && roi.isLine(); nSlices = imp.getStackSize(); if (imp.getStackSize()==1) flags |= PARALLELIZE_IMAGES; else flags |= PARALLELIZE_STACKS; imp.startTiming(); return flags; }
public void run(String arg) { ImagePlus imp = IJ.getImage(); Roi roi = imp.getRoi(); if (roi==null || roi.isLine()) { IJ.error("Enlarge", "This command requires an area selection"); return; } double n = showDialog(imp, defaultDistance); if (n==Double.NaN) return; if (n>255) { IJ.error("Enlarge", "Cannot enlarge by more than 255 pixels"); return; } Roi roi2 = enlarge(roi, n); if (roi2!=null) { imp.setRoi(roi2); Roi.previousRoi = roi; defaultDistance = n; } }
public void run(String arg) { ImagePlus imp = IJ.getImage(); Roi roi = imp.getRoi(); if (roi==null || roi.isLine()) { IJ.error("Enlarge", "This command requires an area selection"); return; } double n = showDialog(imp, defaultDistance); if (n==Double.NaN) return; if (n>255) { IJ.error("Enlarge", "Cannot enlarge by more than 255 pixels"); return; } Roi roi2 = enlarge(roi, n); if (roi2!=null) { imp.setRoi(roi2); Roi.previousRoi = roi; defaultDistance = n; } }
void lineWidth() { int width = (int)IJ.getNumber("Line Width:", Line.getWidth()); if (width==IJ.CANCELED) return; Line.setWidth(width); LineWidthAdjuster.update(); ImagePlus imp = WindowManager.getCurrentImage(); if (imp!=null && imp.isProcessor()) { ImageProcessor ip = imp.getProcessor(); ip.setLineWidth(Line.getWidth()); Roi roi = imp.getRoi(); if (roi!=null && roi.isLine()) imp.draw(); } }
void lineWidth() { int width = (int)IJ.getNumber("Line Width:", Line.getWidth()); if (width==IJ.CANCELED) return; Line.setWidth(width); LineWidthAdjuster.update(); ImagePlus imp = WindowManager.getCurrentImage(); if (imp!=null && imp.isProcessor()) { ImageProcessor ip = imp.getProcessor(); ip.setLineWidth(Line.getWidth()); Roi roi = imp.getRoi(); if (roi!=null && roi.isLine()) imp.draw(); } }
/** Fills the ROI with the current fill/draw value. * @see #setColor(Color) * @see #setValue(double) * @see #fill(Roi) */ public void fill(Roi roi) { if (roi!=null && roi.isLine()) { if ((roi instanceof Line) && roi.getStrokeWidth()>1 && !(roi instanceof Arrow)) fillPolygon(roi.getPolygon()); else roi.drawPixels(this); return; } ImageProcessor m = getMask(); Rectangle r = getRoi(); setRoi(roi); fill(getMask()); setMask(m); setRoi(r); }