/** Returns true if the roi is of closed shape type like an OvalRoi, ShapeRoi, a Roi rectangle, etc. */ static public final boolean isAreaROI(final Roi roi) { switch (roi.getType()) { case Roi.POLYLINE: case Roi.FREELINE: case Roi.LINE: case Roi.POINT: return false; } return true; }
private Roi simplifyShapeRoi(ShapeRoi sRoi) { //convert composite roi to simple roi if possible Roi[] rois = sRoi.getRois(); if (rois.length != 1) return sRoi; int type = rois[0].getType(); if (type==Roi.POLYGON || type==Roi.FREEROI) return rois[0]; else return sRoi; }
@Override public boolean supportedType(final Roi src) { // TextRoi and ImageRoi both have roi type of Rectangle return src.getType() == Roi.RECTANGLE && src.getCornerDiameter() == 0 && !(src instanceof ImageRoi) && !(src instanceof TextRoi); }
private Roi simplifyShapeRoi(ShapeRoi sRoi) { //convert composite roi to simple roi if possible Roi[] rois = sRoi.getRois(); if (rois.length != 1) return sRoi; int type = rois[0].getType(); if (type==Roi.POLYGON || type==Roi.FREEROI) return rois[0]; else return sRoi; }
public static void recordRoi(Roi roi) { if (roi==null) return; Polygon polygon = roi.getPolygon(); recordRoi(polygon, roi.getType()); }
void drawPreviousRoi(Graphics g) { if (previousRoi!=null && previousRoi!=this && previousRoi.modState!=NO_MODS) { if (type!=POINT && previousRoi.getType()==POINT && previousRoi.modState!=SUBTRACT_FROM_ROI) return; previousRoi.setImage(imp); previousRoi.draw(g); } }
double getSelectionType() { interp.getParens(); double type = -1; ImagePlus imp = getImage(); Roi roi = imp.getRoi(); if (roi!=null) type = roi.getType(); return type; }
@Override public void mouseReleased( final MouseEvent e ) { // here the ROI might have been modified, let's test for that final Roi roi = imp.getRoi(); if ( roi == null || roi.getType() != Roi.RECTANGLE ) return; while ( isComputing ) SimpleMultiThreading.threadWait( 10 ); updatePreview( ValueChange.ROI ); }
public void run(ImageProcessor ip) { measure(); Roi roi = imp.getRoi(); if (roi==null || roi.getType()!=Roi.POINT) displayResults(); if ((measurements&ADD_TO_OVERLAY)!=0) addRoiToOverlay(); }
public void mouseReleased(ImagePlus imp, MouseEvent e) { if (Recorder.record) { Roi roi = imp.getRoi(); int n = roi.getPolygon().npoints; if (n<=20 && roi.getType()!=Roi.LINE) Recorder.recordRoi(roi); else if (n>20) Recorder.recordString("// Selection has "+n+" points, too many to record.\n"); } }
void addPoint() { if (!(type==POINT && previousRoi.getType()==POINT)) { modState = NO_MODS; imp.draw(); return; } previousRoi.modState = NO_MODS; PointRoi p1 = (PointRoi)previousRoi; FloatPolygon poly = getFloatPolygon(); p1.addPoint(imp, poly.xpoints[0], poly.ypoints[0]); imp.setRoi(p1); }
public void run(ImageProcessor ip) { measure(); Roi roi = imp.getRoi(); if (roi==null || roi.getType()!=Roi.POINT) displayResults(); if ((measurements&ADD_TO_OVERLAY)!=0) addRoiToOverlay(); }
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(); }
/** Checks whether two rectangles are equal. */ public boolean equals(Object obj) { if (obj instanceof Roi) { Roi roi2 = (Roi)obj; if (type!=roi2.getType()) return false; if (!getBounds().equals(roi2.getBounds())) return false; if (getLength()!=roi2.getLength()) return false; return true; } else return false; }
/** Checks whether two rectangles are equal. */ public boolean equals(Object obj) { if (obj instanceof Roi) { Roi roi2 = (Roi)obj; if (type!=roi2.getType()) return false; if (!getBounds().equals(roi2.getBounds())) return false; if (getLength()!=roi2.getLength()) return false; return true; } else return false; }
public ImageProcessor rotateLine(ImagePlus imp, int width) { Roi roi = imp.getRoi(); if (roi==null || roi.getType()!=Roi.LINE) throw new IllegalArgumentException("Straight line selection expected"); Polygon p = ((Line)roi).getPoints(); imp.setRoi(new PolygonRoi(p.xpoints, p.ypoints, 2, Roi.POLYLINE)); ImageProcessor ip2 = imp.getBitDepth()==24?straightenRGB(imp, width):straightenLine(imp, width); imp.setRoi(roi); return ip2; }
public ImageProcessor rotateLine(ImagePlus imp, int width) { Roi roi = imp.getRoi(); if (roi==null || roi.getType()!=Roi.LINE) throw new IllegalArgumentException("Straight line selection expected"); Polygon p = ((Line)roi).getPoints(); imp.setRoi(new PolygonRoi(p.xpoints, p.ypoints, 2, Roi.POLYLINE)); ImageProcessor ip2 = imp.getBitDepth()==24?straightenRGB(imp, width):straightenLine(imp, width); imp.setRoi(roi); return ip2; }
public ImagePlus radreslice(ImagePlus imp) { ImagePlus imp2; Roi roi = imp.getRoi(); int roiType = roi!=null?roi.getType():0; Calibration origCal = imp.getCalibration(); imp2 = radslice(imp); imp2.setCalibration(imp.getCalibration()); Calibration cal = imp2.getCalibration(); cal.pixelDepth = origCal.pixelHeight; return imp2; }
public void mouseReleased(MouseEvent e) { super.mouseReleased(e); Roi roi = imp.getRoi(); if (roi!=null && roi.getType()==Roi.LINE) { Undo.setup(Undo.FILTER, imp); imp.getProcessor().snapshot(); roi.drawPixels(); imp.updateAndDraw(); imp.deleteRoi(); } }
public void mouseReleased(MouseEvent e) { super.mouseReleased(e); Roi roi = imp.getRoi(); if (roi!=null && roi.getType()==Roi.LINE) { Undo.setup(Undo.FILTER, imp); imp.getProcessor().snapshot(); roi.drawPixels(); imp.updateAndDraw(); imp.deleteRoi(); } }