/** Returns a copy of this PointRoi. */ public synchronized Object clone() { PointRoi r = (PointRoi)super.clone(); if (counters!=null) { r.counters = new short[counters.length]; for (int i=0; i<counters.length; i++) r.counters[i] = counters[i]; } if (positions!=null) { r.positions = new short[positions.length]; for (int i=0; i<positions.length; i++) r.positions[i] = positions[i]; } if (counts!=null) { r.counts = new int[counts.length]; for (int i=0; i<counts.length; i++) r.counts[i] = counts[i]; } return r; }
/** Returns a copy of this PointRoi. */ public synchronized Object clone() { PointRoi r = (PointRoi)super.clone(); if (counters!=null) { r.counters = new short[counters.length]; for (int i=0; i<counters.length; i++) r.counters[i] = counters[i]; } if (positions!=null) { r.positions = new short[positions.length]; for (int i=0; i<positions.length; i++) r.positions[i] = positions[i]; } if (counts!=null) { r.counts = new int[counts.length]; for (int i=0; i<counts.length; i++) r.counts[i] = counts[i]; } return r; }
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()); }
protected static float[] getProfile(ImageProcessor ip, PolygonRoi roi, boolean fitSpline, int lineWidth) { if (fitSpline && !roi.isSplineFit()) { roi = (PolygonRoi)roi.clone(); roi.fitSpline(); } ImagePlus dummy = new ImagePlus("dummy", ip); dummy.setRoi(roi); Straightener straightener = new Straightener(); ip = straightener.straightenLine(dummy, lineWidth); int w = ip.getWidth(); float[] result = new float[w]; // need to average explicitely for (int j = 0; j < w; j++) { float value = ip.getf(j, 0); for (int k = 1; k < lineWidth; k++) value += ip.getf(j, k); result[j] = value / lineWidth; } return result; } }
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); }