protected Polygon getPolygon(int sliceIndex) { PolygonRoi roi = rois[sliceIndex]; if (roi.isSplineFit()) { roi = (PolygonRoi)roi.clone(); roi.removeSplineFit(); } return roi.getPolygon(); }
protected static Polygon getPolygon(Roi[] rois, int sliceIndex) { if (rois[sliceIndex] == null || !(rois[sliceIndex] instanceof PolygonRoi)) return null; PolygonRoi roi = (PolygonRoi)rois[sliceIndex]; if (roi.isSplineFit()) { roi = (PolygonRoi)roi.clone(); roi.removeSplineFit(); } return roi.getPolygon(); }
protected PolygonRoi flipROI(PolygonRoi roi) { if (roi.isSplineFit()) { roi = (PolygonRoi)roi.clone(); roi.removeSplineFit(); } Polygon polygon = roi.getPolygon(); for (int i = 0; i < polygon.npoints / 2; i++) { int dummy = polygon.xpoints[i]; polygon.xpoints[i] = polygon.xpoints[polygon.npoints - 1 - i]; polygon.xpoints[polygon.npoints - 1 - i] = dummy; dummy = polygon.ypoints[i]; polygon.ypoints[i] = polygon.ypoints[polygon.npoints - 1 - i]; polygon.ypoints[polygon.npoints - 1 - i] = dummy; } return new PolygonRoi(polygon, roi.getType()); }
public void deleteHandle(double ox, double oy) { if (imp==null) return; if (nPoints<=1) { imp.deleteRoi(); return; } boolean splineFit = xSpline!=null; if (splineFit) removeSplineFit(); FloatPolygon points = getFloatPolygon(); int pointToDelete = getClosestPoint(ox, oy, points); if (pointToDelete>=0) { deletePoint(pointToDelete); if (splineFit) fitSpline(splinePoints); imp.draw(); } }
public void deleteHandle(double ox, double oy) { if (imp==null) return; if (nPoints<=1) { imp.deleteRoi(); return; } boolean splineFit = xSpline!=null; if (splineFit) removeSplineFit(); FloatPolygon points = getFloatPolygon(); int pointToDelete = getClosestPoint(ox, oy, points); if (pointToDelete>=0) { deletePoint(pointToDelete); if (splineFit) fitSpline(splinePoints); imp.draw(); } }
public void itemStateChanged(ItemEvent e) { boolean selected = e.getStateChange()==ItemEvent.SELECTED; ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null) {checkbox.setState(false); return;}; Roi roi = imp.getRoi(); int type = roi!=null?roi.getType():null; if (roi==null || !(roi instanceof PolygonRoi) || type==Roi.FREEROI || type==Roi.FREELINE || type==Roi.ANGLE) { checkbox.setState(false); return; }; PolygonRoi poly = (PolygonRoi)roi; boolean splineFit = poly.isSplineFit(); if (selected && !splineFit) { poly.fitSpline(); Prefs.splineFitLines = true; imp.draw(); } else if (!selected && splineFit) { poly.removeSplineFit(); Prefs.splineFitLines = false; imp.draw(); } }
public void itemStateChanged(ItemEvent e) { boolean selected = e.getStateChange()==ItemEvent.SELECTED; ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null) {checkbox.setState(false); return;}; Roi roi = imp.getRoi(); int type = roi!=null?roi.getType():null; if (roi==null || !(roi instanceof PolygonRoi) || type==Roi.FREEROI || type==Roi.FREELINE || type==Roi.ANGLE) { checkbox.setState(false); return; }; PolygonRoi poly = (PolygonRoi)roi; boolean splineFit = poly.isSplineFit(); if (selected && !splineFit) { poly.fitSpline(); Prefs.splineFitLines = true; imp.draw(); } else if (!selected && splineFit) { poly.removeSplineFit(); Prefs.splineFitLines = false; imp.draw(); } }
void fitSpline() { Roi roi = imp.getRoi(); if (roi==null) {noRoi("Spline"); return;} int type = roi.getType(); boolean segmentedSelection = type==Roi.POLYGON||type==Roi.POLYLINE; if (!(segmentedSelection||type==Roi.FREEROI||type==Roi.TRACED_ROI||type==Roi.FREELINE)) {IJ.error("Spline Fit", "Polygon or polyline selection required"); return;} if (roi instanceof EllipseRoi) return; PolygonRoi p = (PolygonRoi)roi; Undo.setup(Undo.ROI, imp); if (!segmentedSelection && p.getNCoordinates()>3) { if (p.subPixelResolution()) p = trimFloatPolygon(p, p.getUncalibratedLength()); else p = trimPolygon(p, p.getUncalibratedLength()); } String options = Macro.getOptions(); if (options!=null && options.indexOf("straighten")!=-1) p.fitSplineForStraightening(); else if (options!=null && options.indexOf("remove")!=-1) p.removeSplineFit(); else p.fitSpline(); imp.draw(); LineWidthAdjuster.update(); }
void fitSpline() { Roi roi = imp.getRoi(); if (roi==null) {noRoi("Spline"); return;} int type = roi.getType(); boolean segmentedSelection = type==Roi.POLYGON||type==Roi.POLYLINE; if (!(segmentedSelection||type==Roi.FREEROI||type==Roi.TRACED_ROI||type==Roi.FREELINE)) {IJ.error("Spline Fit", "Polygon or polyline selection required"); return;} if (roi instanceof EllipseRoi) return; PolygonRoi p = (PolygonRoi)roi; Undo.setup(Undo.ROI, imp); if (!segmentedSelection && p.getNCoordinates()>3) { if (p.subPixelResolution()) p = trimFloatPolygon(p, p.getUncalibratedLength()); else p = trimPolygon(p, p.getUncalibratedLength()); } String options = Macro.getOptions(); if (options!=null && options.indexOf("straighten")!=-1) p.fitSplineForStraightening(); else if (options!=null && options.indexOf("remove")!=-1) p.removeSplineFit(); else p.fitSpline(); imp.draw(); LineWidthAdjuster.update(); }
roi.exitConstructingMode(); if (roi.isSplineFit()) roi.removeSplineFit(); int type = roi.getType(); int n = roi.getNCoordinates(); roi.removeSplineFit(); else imp.draw();
roi.exitConstructingMode(); if (roi.isSplineFit()) roi.removeSplineFit(); int type = roi.getType(); int n = roi.getNCoordinates(); roi.removeSplineFit(); else imp.draw();
else { rois[i].removeSplineFit(); ImagePlus dummy = new ImagePlus("dummy", stack.getProcessor(i + 1)); dummy.setRoi(rois[i]);
else { rois[i].removeSplineFit(); ImagePlus dummy = new ImagePlus("dummy", stack.getProcessor(i + 1)); dummy.setRoi(rois[i]);