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(); }
public void mark(int slice, int distance) { image.setPosition(slice); if (distance < 0) { unmark(); return; } PolygonRoi roi = rois[slice - 1]; if (roi == null) { image.killRoi(); return; } image.setRoi(roi); roi = (PolygonRoi)roi.clone(); roi.fitSplineForStraightening(); if (distance >= roi.getNCoordinates()) { unmark(); return; } Rectangle bounds = roi.getBounds(); int x = roi.getXCoordinates()[distance] + bounds.x; int y = roi.getYCoordinates()[distance] + bounds.y; Overlay overlay = new Overlay(new OvalRoi(x - 10, y - 10, 21, 21)); image.setOverlay(overlay); }
int n = roi.getNCoordinates(); double len = roi.getLength(); roi.fitSplineForStraightening(); if (roi.getNCoordinates()<2) return null;
int n = roi.getNCoordinates(); double len = roi.getLength(); roi.fitSplineForStraightening(); if (roi.getNCoordinates()<2) return null;