public Polygon getConvexHull() { return getPolygon(); }
public Polygon getConvexHull() { return getPolygon(); }
public Polygon getPolygon() { Roi[] rois = getRois(); if (rois!=null && rois.length==1) return rois[0].getPolygon(); else return super.getPolygon(); }
public Polygon getPolygon() { Roi[] rois = getRois(); if (rois!=null && rois.length==1) return rois[0].getPolygon(); else return super.getPolygon(); }
public static void recordRoi(Roi roi) { if (roi==null) return; Polygon polygon = roi.getPolygon(); recordRoi(polygon, roi.getType()); }
ShapeRoi getCircularRoi(int x, int y, int width) { if (poly==null) { Roi roi = new OvalRoi(x-width/2, y-width/2, width, width); poly = roi.getPolygon(); for (int i=0; i<poly.npoints; i++) { poly.xpoints[i] -= x; poly.ypoints[i] -= y; } } return new ShapeRoi(x, y, poly); }
ShapeRoi getCircularRoi(int x, int y, int width) { if (poly==null) { Roi roi = new OvalRoi(x-width/2, y-width/2, width, width); poly = roi.getPolygon(); for (int i=0; i<poly.npoints; i++) { poly.xpoints[i] -= x; poly.ypoints[i] -= y; } } return new ShapeRoi(x, y, poly); }
public static void recordRoi(Roi roi) { if (roi==null) return; Polygon polygon = roi.getPolygon(); recordRoi(polygon, roi.getType()); }
/** Subtract the points that intersect the specified ROI and return the result. Returns null if there are no resulting points. */ public PointRoi subtractPoints(Roi roi) { Polygon points = getPolygon(); Polygon poly = roi.getPolygon(); Polygon points2 = new Polygon(); for (int i=0; i<points.npoints; i++) { if (!poly.contains(points.xpoints[i], points.ypoints[i])) points2.addPoint(points.xpoints[i], points.ypoints[i]); } if (points2.npoints==0) return null; else return new PointRoi(points2.xpoints, points2.ypoints, points2.npoints); }
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"); } }
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"); } }
/** * @deprecated * replaced by ImageProcessor.fill(Roi) */ public void fill(ImageProcessor ip) { ip.setColor(Toolbar.getForegroundColor()); if (isLineSelection()) { if (isStraightLine() && roi.getStrokeWidth()>1 && !(roi instanceof Arrow)) ip.fillPolygon(roi.getPolygon()); else roi.drawPixels(ip); } else ip.fill(); // fill with foreground color }
/** Creates a point selection using floating point coordinates. */ public static void makePoint(double x, double y) { ImagePlus img = getImage(); Roi roi = img.getRoi(); if (shiftKeyDown() && roi!=null && roi.getType()==Roi.POINT) { Polygon p = roi.getPolygon(); p.addPoint((int)Math.round(x), (int)Math.round(y)); img.setRoi(new PointRoi(p.xpoints, p.ypoints, p.npoints)); IJ.setKeyUp(KeyEvent.VK_SHIFT); } else if (altKeyDown() && roi!=null && roi.getType()==Roi.POINT) { ((PolygonRoi)roi).deleteHandle(x, y); IJ.setKeyUp(KeyEvent.VK_ALT); } else img.setRoi(new PointRoi(x, y)); }
/** * @deprecated * replaced by ImageProcessor.fill(Roi) */ public void fill(ImageProcessor ip) { ip.setColor(Toolbar.getForegroundColor()); if (isLineSelection()) { if (isStraightLine() && roi.getStrokeWidth()>1 && !(roi instanceof Arrow)) ip.fillPolygon(roi.getPolygon()); else roi.drawPixels(ip); } else ip.fill(); // fill with foreground color }
public void clear(ImageProcessor ip) { ip.setColor(Toolbar.getBackgroundColor()); if (isLineSelection()) { if (isStraightLine() && roi.getStrokeWidth()>1) ip.fillPolygon(roi.getPolygon()); else roi.drawPixels(); } else if (roi!=null && roi instanceof TextRoi) ((TextRoi)roi).clear(ip); else ip.fill(); // fill with background color ip.setColor(Toolbar.getForegroundColor()); }
void measureAngle(Roi roi) { if (rt.size()>0) { if (!IJ.isResultsWindow()) reset(); int index = rt.getColumnIndex("Angle"); if (index<0 || !rt.columnExists(index)) { clearSummary(); rt.update(measurements, imp, roi); } } ImageProcessor ip = imp.getProcessor(); ip.setRoi(roi.getPolygon()); ImageStatistics stats = new ImageStatistics(); saveResults(stats, roi); }
void measureAngle(Roi roi) { if (rt.size()>0) { if (!IJ.isResultsWindow()) reset(); int index = rt.getColumnIndex("Angle"); if (index<0 || !rt.columnExists(index)) { clearSummary(); rt.update(measurements, imp, roi); } } ImageProcessor ip = imp.getProcessor(); ip.setRoi(roi.getPolygon()); ImageStatistics stats = new ImageStatistics(); saveResults(stats, roi); }
public void clear(ImageProcessor ip) { ip.setColor(Toolbar.getBackgroundColor()); if (isLineSelection()) { if (isStraightLine() && roi.getStrokeWidth()>1) ip.fillPolygon(roi.getPolygon()); else roi.drawPixels(); } else if (roi!=null && roi instanceof TextRoi) ((TextRoi)roi).clear(ip); else ip.fill(); // fill with background color ip.setColor(Toolbar.getForegroundColor()); }
Roi convertLineToPolygon(Roi roi, ImageProcessor ip) { if (roi==null) return null; ip.resetRoi(); ip.setColor(0); ip.fill(); ip.setColor(255); if (roi.getType()==Roi.LINE && roi.getStrokeWidth()>1) ip.fillPolygon(roi.getPolygon()); else roi.drawPixels(ip); //new ImagePlus("ip", ip.duplicate()).show(); ip.setThreshold(255, 255, ImageProcessor.NO_LUT_UPDATE); ThresholdToSelection tts = new ThresholdToSelection(); return tts.convert(ip); }
/** Creates a point selection using integer coordinates.. */ public static void makePoint(int x, int y) { ImagePlus img = getImage(); Roi roi = img.getRoi(); if (shiftKeyDown() && roi!=null && roi.getType()==Roi.POINT) { Polygon p = roi.getPolygon(); p.addPoint(x, y); img.setRoi(new PointRoi(p.xpoints, p.ypoints, p.npoints)); IJ.setKeyUp(KeyEvent.VK_SHIFT); } else if (altKeyDown() && roi!=null && roi.getType()==Roi.POINT) { ((PolygonRoi)roi).deleteHandle(x, y); IJ.setKeyUp(KeyEvent.VK_ALT); } else img.setRoi(new PointRoi(x, y)); }