public void setDrawOffset(boolean drawOffset) { this.drawOffset = drawOffset && subPixelResolution(); }
public void setDrawOffset(boolean drawOffset) { this.drawOffset = drawOffset && subPixelResolution(); }
/** Returns the length of this line selection after smoothing using a 3-point running average.*/ double getSmoothedLineLength() { if (subPixelResolution() && xpf!=null) return getFloatSmoothedLineLength(); double length = 0.0; double w2 = 1.0; double h2 = 1.0; double dx, dy; if (imp!=null) { Calibration cal = imp.getCalibration(); w2 = cal.pixelWidth*cal.pixelWidth; h2 = cal.pixelHeight*cal.pixelHeight; } dx = (xp[0]+xp[1]+xp[2])/3.0-xp[0]; dy = (yp[0]+yp[1]+yp[2])/3.0-yp[0]; length += Math.sqrt(dx*dx*w2+dy*dy*h2); for (int i=1; i<nPoints-2; i++) { dx = (xp[i+2]-xp[i-1])/3.0; // = (x[i]+x[i+1]+x[i+2])/3-(x[i-1]+x[i]+x[i+1])/3 dy = (yp[i+2]-yp[i-1])/3.0; // = (y[i]+y[i+1]+y[i+2])/3-(y[i-1]+y[i]+y[i+1])/3 length += Math.sqrt(dx*dx*w2+dy*dy*h2); } dx = xp[nPoints-1]-(xp[nPoints-3]+xp[nPoints-2]+xp[nPoints-1])/3.0; dy = yp[nPoints-1]-(yp[nPoints-3]+yp[nPoints-2]+yp[nPoints-1])/3.0; length += Math.sqrt(dx*dx*w2+dy*dy*h2); return length; }
/** Returns the length of this line selection after smoothing using a 3-point running average.*/ double getSmoothedLineLength() { if (subPixelResolution() && xpf!=null) return getFloatSmoothedLineLength(); double length = 0.0; double w2 = 1.0; double h2 = 1.0; double dx, dy; if (imp!=null) { Calibration cal = imp.getCalibration(); w2 = cal.pixelWidth*cal.pixelWidth; h2 = cal.pixelHeight*cal.pixelHeight; } dx = (xp[0]+xp[1]+xp[2])/3.0-xp[0]; dy = (yp[0]+yp[1]+yp[2])/3.0-yp[0]; length += Math.sqrt(dx*dx*w2+dy*dy*h2); for (int i=1; i<nPoints-2; i++) { dx = (xp[i+2]-xp[i-1])/3.0; // = (x[i]+x[i+1]+x[i+2])/3-(x[i-1]+x[i]+x[i+1])/3 dy = (yp[i+2]-yp[i-1])/3.0; // = (y[i]+y[i+1]+y[i+2])/3-(y[i-1]+y[i]+y[i+1])/3 length += Math.sqrt(dx*dx*w2+dy*dy*h2); } dx = xp[nPoints-1]-(xp[nPoints-3]+xp[nPoints-2]+xp[nPoints-1])/3.0; dy = yp[nPoints-1]-(yp[nPoints-3]+yp[nPoints-2]+yp[nPoints-1])/3.0; length += Math.sqrt(dx*dx*w2+dy*dy*h2); return length; }
/** Returns the perimeter of this ROI after smoothing using a 3-point running average.*/ double getSmoothedPerimeter() { if (subPixelResolution() && xpf!=null) return getFloatSmoothedPerimeter(); double length = getSmoothedLineLength(); double w2=1.0, h2=1.0; if (imp!=null) { Calibration cal = imp.getCalibration(); w2 = cal.pixelWidth*cal.pixelWidth; h2 = cal.pixelHeight*cal.pixelHeight; } double dx = xp[nPoints-1]-xp[0]; double dy = yp[nPoints-1]-yp[0]; length += Math.sqrt(dx*dx*w2+dy*dy*h2); return length; }
/** Returns the perimeter of this ROI after smoothing using a 3-point running average.*/ double getSmoothedPerimeter() { if (subPixelResolution() && xpf!=null) return getFloatSmoothedPerimeter(); double length = getSmoothedLineLength(); double w2=1.0, h2=1.0; if (imp!=null) { Calibration cal = imp.getCalibration(); w2 = cal.pixelWidth*cal.pixelWidth; h2 = cal.pixelHeight*cal.pixelHeight; } double dx = xp[nPoints-1]-xp[0]; double dy = yp[nPoints-1]-yp[0]; length += Math.sqrt(dx*dx*w2+dy*dy*h2); return length; }
startXD = subPixelResolution()?ic.offScreenXD(sx):x; startYD = subPixelResolution()?ic.offScreenYD(sy):y; if (subPixelResolution()) { setLocation(ic.offScreenXD(sx), ic.offScreenYD(sy)); xpf = new float[maxPoints]; if (lineWidth>1 && isLine()) updateWideLine(lineWidth); drawOffset = subPixelResolution();
startXD = subPixelResolution()?ic.offScreenXD(sx):x; startYD = subPixelResolution()?ic.offScreenYD(sy):y; if (subPixelResolution()) { setLocation(ic.offScreenXD(sx), ic.offScreenYD(sy)); xpf = new float[maxPoints]; if (lineWidth>1 && isLine()) updateWideLine(lineWidth); drawOffset = subPixelResolution();
oldX=x; oldY=y; oldWidth=width; oldHeight=height; if (subPixelResolution()) resetBoundingRect(); return;
oldX=x; oldY=y; oldWidth=width; oldHeight=height; if (subPixelResolution()) resetBoundingRect(); return;
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(); }
protected void moveHandle(int sx, int sy) { if (clipboard!=null) return; int ox = ic.offScreenX(sx); int oy = ic.offScreenY(sy); if (xpf!=null) { double offset = getOffset(-0.5); double xbase = getXBase(); double ybase = getYBase(); xpf[activeHandle] = (float)(ic.offScreenXD(sx)-xbase+offset); ypf[activeHandle] = (float)(ic.offScreenYD(sy)-ybase+offset); } else { xp[activeHandle] = ox-x; yp[activeHandle] = oy-y; } if (xSpline!=null) { fitSpline(splinePoints); imp.draw(); } else { if (!subPixelResolution() || (type==POINT&&nPoints==1)) resetBoundingRect(); if (type==POINT && width==0 && height==0) {width=1; height=1;} updateClipRectAndDraw(); } String angle = type==ANGLE?getAngleAsString():""; IJ.showStatus(imp.getLocationAsString(ox,oy) + angle); }
protected void moveHandle(int sx, int sy) { if (clipboard!=null) return; int ox = ic.offScreenX(sx); int oy = ic.offScreenY(sy); if (xpf!=null) { double offset = getOffset(-0.5); double xbase = getXBase(); double ybase = getYBase(); xpf[activeHandle] = (float)(ic.offScreenXD(sx)-xbase+offset); ypf[activeHandle] = (float)(ic.offScreenYD(sy)-ybase+offset); } else { xp[activeHandle] = ox-x; yp[activeHandle] = oy-y; } if (xSpline!=null) { fitSpline(splinePoints); imp.draw(); } else { if (!subPixelResolution() || (type==POINT&&nPoints==1)) resetBoundingRect(); if (type==POINT && width==0 && height==0) {width=1; height=1;} updateClipRectAndDraw(); } String angle = type==ANGLE?getAngleAsString():""; IJ.showStatus(imp.getLocationAsString(ox,oy) + angle); }