public FloatPolygon getFloatPolygon() { Roi[] rois = getRois(); if (rois!=null && rois.length==1) return rois[0].getFloatPolygon(); else return super.getFloatPolygon(); }
public FloatPolygon getFloatPolygon() { Roi[] rois = getRois(); if (rois!=null && rois.length==1) return rois[0].getFloatPolygon(); else return super.getFloatPolygon(); }
public double[] getContourCentroid() { double xC=0, yC=0, lSum=0, x, y, dx, dy, l; FloatPolygon poly = getFloatPolygon(); int nPoints = poly.npoints; int n2 = nPoints-1; for (int n1=0; n1<nPoints; n1++){ dx = poly.xpoints[n1] - poly.xpoints[n2]; dy = poly.ypoints[n1] - poly.ypoints[n2]; x = poly.xpoints[n2] + dx/2.0; y = poly.ypoints[n2] + dy/2.0; l = Math.sqrt(dx*dx + dy*dy); xC += x*l; yC += y*l; lSum += l; n2 = n1; } xC /= lSum; yC /= lSum; return new double[]{xC, yC}; }
public double[] getContourCentroid() { double xC=0, yC=0, lSum=0, x, y, dx, dy, l; FloatPolygon poly = getFloatPolygon(); int nPoints = poly.npoints; int n2 = nPoints-1; for (int n1=0; n1<nPoints; n1++){ dx = poly.xpoints[n1] - poly.xpoints[n2]; dy = poly.ypoints[n1] - poly.ypoints[n2]; x = poly.xpoints[n2] + dx/2.0; y = poly.ypoints[n2] + dy/2.0; l = Math.sqrt(dx*dx + dy*dy); xC += x*l; yC += y*l; lSum += l; n2 = n1; } xC /= lSum; yC /= lSum; return new double[]{xC, yC}; }
/** Returns, as a FloatPolygon, an interpolated version of * this selection with points spaced 'interval' pixels apart. * If 'smooth' is true, traced and freehand selections are * first smoothed using a 3 point running average. */ public FloatPolygon getInterpolatedPolygon(double interval, boolean smooth) { FloatPolygon p = (this instanceof Line)?((Line)this).getFloatPoints():getFloatPolygon(); return getInterpolatedPolygon(p, interval, smooth); }
/** Returns, as a FloatPolygon, an interpolated version of * this selection with points spaced 'interval' pixels apart. * If 'smooth' is true, traced and freehand selections are * first smoothed using a 3 point running average. */ public FloatPolygon getInterpolatedPolygon(double interval, boolean smooth) { FloatPolygon p = (this instanceof Line)?((Line)this).getFloatPoints():getFloatPolygon(); return getInterpolatedPolygon(p, interval, smooth); }
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); }
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); }
String ls = System.getProperty("line.separator"); if (roi.subPixelResolution()) { FloatPolygon p = roi.getFloatPolygon(); for (int i=0; i<p.npoints; i++) pw.print(IJ.d2s((p.xpoints[i])*cal.pixelWidth,4) + "\t" + IJ.d2s((p.ypoints[i])*cal.pixelHeight,4) + ls);
String ls = System.getProperty("line.separator"); if (roi.subPixelResolution()) { FloatPolygon p = roi.getFloatPolygon(); for (int i=0; i<p.npoints; i++) pw.print(IJ.d2s((p.xpoints[i])*cal.pixelWidth,4) + "\t" + IJ.d2s((p.ypoints[i])*cal.pixelHeight,4) + ls);
private String getSplineAnchors(Roi roi) { Variable xCoordinates = getFirstArrayVariable(); Variable yCoordinates = getLastArrayVariable(); Variable[] xa=null, ya=null; FloatPolygon fp = null; if (roi instanceof PolygonRoi) fp = ((PolygonRoi)roi).getNonSplineFloatPolygon(); else fp = roi.getFloatPolygon(); if (fp!=null) { xa = new Variable[fp.npoints]; ya = new Variable[fp.npoints]; for (int i=0; i<fp.npoints; i++) xa[i] = new Variable(fp.xpoints[i]); for (int i=0; i<fp.npoints; i++) ya[i] = new Variable(fp.ypoints[i]); } xCoordinates.setArray(xa); yCoordinates.setArray(ya); return null; }
private String getSplineAnchors(Roi roi) { Variable xCoordinates = getFirstArrayVariable(); Variable yCoordinates = getLastArrayVariable(); Variable[] xa=null, ya=null; FloatPolygon fp = null; if (roi instanceof PolygonRoi) fp = ((PolygonRoi)roi).getNonSplineFloatPolygon(); else fp = roi.getFloatPolygon(); if (fp!=null) { xa = new Variable[fp.npoints]; ya = new Variable[fp.npoints]; for (int i=0; i<fp.npoints; i++) xa[i] = new Variable(fp.xpoints[i]); for (int i=0; i<fp.npoints; i++) ya[i] = new Variable(fp.ypoints[i]); } xCoordinates.setArray(xa); yCoordinates.setArray(ya); return null; }
private RectangleOverlay createRectangleOverlay(final Roi roi) { final RectangleOverlay overlay = new RectangleOverlay(getContext()); final RectangleRegionOfInterest region = overlay.getRegionOfInterest(); final FloatPolygon poly = roi.getFloatPolygon(); final Double bounds = poly.getFloatBounds(); region.setOrigin(bounds.x, 0); region.setOrigin(bounds.y, 1); region.setExtent(bounds.width, 0); region.setExtent(bounds.height, 1); assignPropertiesToOverlay(overlay, roi); return overlay; }
private EllipseOverlay createEllipseOverlay(final Roi roi) { final EllipseOverlay overlay = new EllipseOverlay(getContext()); final EllipseRegionOfInterest region = overlay.getRegionOfInterest(); final FloatPolygon poly = roi.getFloatPolygon(); final Double bounds = poly.getFloatBounds(); final double radiusX = bounds.width / 2.0; final double radiusY = bounds.height / 2.0; region.setOrigin(bounds.x + radiusX, 0); region.setOrigin(bounds.y + radiusY, 1); region.setRadius(radiusX, 0); region.setRadius(radiusY, 1); assignPropertiesToOverlay(overlay, roi); return overlay; }
/** Defines a non-rectangular region of interest that will consist of a rectangular ROI and a mask. After processing, call <code>reset(mask)</code> to restore non-masked pixels. Here is an example: <pre> ip.setRoi(new OvalRoi(50, 50, 100, 50)); ip.fill(); ip.reset(ip.getMask()); </pre> The example assumes <code>snapshot()</code> has been called, which is the case for code executed in the <code>run()</code> method of plugins that implement the <code>PlugInFilter</code> interface. @see ij.ImagePlus#getRoi */ public void setRoi(Roi roi) { if (roi==null) resetRoi(); else { if (roi instanceof PointRoi && ((PointRoi)roi).getNCoordinates()==1) { setMask(null); FloatPolygon p = roi.getFloatPolygon(); setRoi((int)p.xpoints[0], (int)p.ypoints[0], 1, 1); } else { setMask(roi.getMask()); setRoi(roi.getBounds()); } } }
/** Defines a non-rectangular region of interest that will consist of a rectangular ROI and a mask. After processing, call <code>reset(mask)</code> to restore non-masked pixels. Here is an example: <pre> ip.setRoi(new OvalRoi(50, 50, 100, 50)); ip.fill(); ip.reset(ip.getMask()); </pre> The example assumes <code>snapshot()</code> has been called, which is the case for code executed in the <code>run()</code> method of plugins that implement the <code>PlugInFilter</code> interface. @see ij.ImagePlus#getRoi */ public void setRoi(Roi roi) { if (roi==null) resetRoi(); else { if (roi instanceof PointRoi && ((PointRoi)roi).getNCoordinates()==1) { setMask(null); FloatPolygon p = roi.getFloatPolygon(); setRoi((int)p.xpoints[0], (int)p.ypoints[0], 1, 1); } else { setMask(roi.getMask()); setRoi(roi.getBounds()); } } }
public FloatPolygon getFloatPolygon() { if (cornerDiameter>0) { ImageProcessor ip = getMask(); Roi roi2 = (new ThresholdToSelection()).convert(ip); if (roi2!=null) { roi2.setLocation(x, y); return roi2.getFloatPolygon(); } } if (subPixelResolution() && bounds!=null) { float[] xpoints = new float[4]; float[] ypoints = new float[4]; xpoints[0] = (float)bounds.x; ypoints[0] = (float)bounds.y; xpoints[1] = (float)(bounds.x+bounds.width); ypoints[1] = (float)bounds.y; xpoints[2] = (float)(bounds.x+bounds.width); ypoints[2] = (float)(bounds.y+bounds.height); xpoints[3] = (float)bounds.x; ypoints[3] = (float)(bounds.y+bounds.height); return new FloatPolygon(xpoints, ypoints); } else { Polygon p = getPolygon(); return new FloatPolygon(toFloat(p.xpoints), toFloat(p.ypoints), p.npoints); } }
public FloatPolygon getFloatPolygon() { if (cornerDiameter>0) { ImageProcessor ip = getMask(); Roi roi2 = (new ThresholdToSelection()).convert(ip); if (roi2!=null) { roi2.setLocation(x, y); return roi2.getFloatPolygon(); } } if (subPixelResolution() && bounds!=null) { float[] xpoints = new float[4]; float[] ypoints = new float[4]; xpoints[0] = (float)bounds.x; ypoints[0] = (float)bounds.y; xpoints[1] = (float)(bounds.x+bounds.width); ypoints[1] = (float)bounds.y; xpoints[2] = (float)(bounds.x+bounds.width); ypoints[2] = (float)(bounds.y+bounds.height); xpoints[3] = (float)bounds.x; ypoints[3] = (float)(bounds.y+bounds.height); return new FloatPolygon(xpoints, ypoints); } else { Polygon p = getPolygon(); return new FloatPolygon(toFloat(p.xpoints), toFloat(p.ypoints), p.npoints); } }
void listCoordinates(Roi roi) { if (roi==null) return; boolean allIntegers = true; FloatPolygon fp = roi.getFloatPolygon();
ya[1] = new Variable(line.y2d); } else { FloatPolygon fp = roi.getFloatPolygon(); if (fp!=null) { xa = new Variable[fp.npoints];