/** * Creates an ImageJ 1.x {@link PointRoi} and wraps it as an ImgLib2 * {@link RealPointCollection}. * * @param x x coordinate of the point * @param y y coordinate of the point */ public PointRoiWrapper(final double x, final double y) { points = new PointRoi(x, y); }
/** * Creates an ImageJ 1.x {@link PointRoi} and wraps it as an ImgLib2 * {@link RealPointCollection}. * * @param x x coordinate of the point * @param y y coordinate of the point */ public PointRoiWrapper(final int x, final int y) { points = new PointRoi(x, y); }
/** * Creates an ImageJ 1.x {@link PointRoi} and wraps it as an ImgLib2 * {@link RealPointCollection}. * * @param x x coordinates of the points * @param y y coordinates of the points */ public PointRoiWrapper(final float[] x, final float[] y) { points = new PointRoi(x, y); }
/** * Creates an ImageJ 1.x {@link PointRoi} and wraps it as an ImgLib2 * {@link RealPointCollection}. * * @param polygon {@link Polygon} whose vertices will be the points contained * in this collection */ public PointRoiWrapper(final Polygon polygon) { points = new PointRoi(polygon); }
/** * Creates an ImageJ 1.x {@link PointRoi} and wraps it as an ImgLib2 * {@link RealPointCollection}. * * @param x x coordinates of the points * @param y y coordinates of the points * @param numPoints total number of points in the collection */ public PointRoiWrapper(final int[] x, final int[] y, final int numPoints) { this.points = new PointRoi(x, y, numPoints); }
/** * Creates an ImageJ 1.x {@link PointRoi} and wraps it as an ImgLib2 * {@link RealPointCollection}. * * @param polygon {@link FloatPolygon} whose vertices will be the points * contained in this collection */ public PointRoiWrapper(final FloatPolygon polygon) { points = new PointRoi(polygon); }
/** * Creates an ImageJ 1.x {@link PointRoi} and wraps it as an ImgLib2 * {@link RealPointCollection}. * * @param x x coordinates of the points * @param y y coordinates of the points * @param numPoints total number of points in the collection */ public PointRoiWrapper(final float[] x, final float[] y, final int numPoints) { this.points = new PointRoi(x, y, numPoints); }
private void updateRoi() { final int[] x = new int[ hooks.size() ]; final int[] y = new int[ hooks.size() ]; for ( int i = 0; i < hooks.size(); ++ i ) { final double[] l = hooks.get( i ).getW(); x[ i ] = ( int )l[ 0 ]; y[ i ] = ( int )l[ 1 ]; } handles = new PointRoi( x, y, hooks.size() ); imp.setRoi( handles ); }
final protected void updateRoi() { final int[] x = new int[ hooks.size() ]; final int[] y = new int[ hooks.size() ]; for ( int i = 0; i < hooks.size(); ++ i ) { final double[] l = hooks.get( i ).getW(); x[ i ] = ( int )l[ 0 ]; y[ i ] = ( int )l[ 1 ]; } handles = new PointRoi( x, y, hooks.size() ); imp.setRoi( handles ); }
final protected void updateRoi() { final int[] x = new int[ hooks.size() ]; final int[] y = new int[ hooks.size() ]; for ( int i = 0; i < hooks.size(); ++ i ) { final double[] l = hooks.get( i ).getW(); x[ i ] = ( int )l[ 0 ]; y[ i ] = ( int )l[ 1 ]; } handles = new PointRoi( x, y, hooks.size() ); imp.setRoi( handles ); }
private Roi createPointRoi(final PointOverlay overlay) { List<double[]> points = overlay.getPoints(); float[] xPts = new float[points.size()]; float[] yPts = new float[points.size()]; for (int i = 0; i < points.size(); i++) { double[] pt = points.get(i); xPts[i] = (float) pt[0]; yPts[i] = (float) pt[1]; } PointRoi roi = new PointRoi(xPts, yPts, points.size()); assignPropertiesToRoi(roi, overlay); return roi; }
private void updateRoi() { final int[] x = new int[ hooks.size() ]; final int[] y = new int[ hooks.size() ]; for ( int i = 0; i < hooks.size(); ++ i ) { final double[] l = hooks.get( i ).getW(); x[ i ] = ( int )l[ 0 ]; y[ i ] = ( int )l[ 1 ]; } handles = new PointRoi( x, y, hooks.size() ); imp.setRoi( handles ); }
void setRoi(ImagePlus imp) { int count = x.length; int[] x1 = new int[count]; int[] y1 = new int[count]; for (int i = 0; i < count; i++) { x1[i] = (int)Math.round(x[i]); y1[i] = (int)Math.round(y[i]); } PointRoi roi = new PointRoi(x1, y1, count); imp.setRoi(roi); imp.updateAndDraw(); }
@Override public PointRoi convert(final PointMask mask) { return new PointRoi(mask.getDoublePosition(0), mask.getDoublePosition(1)); }
@Override public PointRoi convert(final RealPointCollection<RealLocalizable> mask) { final Iterator<RealLocalizable> points = mask.points().iterator(); RealLocalizable point = points.next(); final PointRoi pointRoi = new PointRoi(point.getDoublePosition(0), point .getDoublePosition(1)); while (points.hasNext()) { point = points.next(); pointRoi.addPoint(point.getDoublePosition(0), point.getDoublePosition(1)); } return pointRoi; }
/** Subtract the points that intersect the specified ROI and return the result. Returns null if there are no resulting points. */ public PointRoi subtractPoints(Roi roi) { Polygon points = getPolygon(); Polygon poly = roi.getPolygon(); Polygon points2 = new Polygon(); for (int i=0; i<points.npoints; i++) { if (!poly.contains(points.xpoints[i], points.ypoints[i])) points2.addPoint(points.xpoints[i], points.ypoints[i]); } if (points2.npoints==0) return null; else return new PointRoi(points2.xpoints, points2.ypoints, points2.npoints); }
protected PointRoi toROI() { float[] profile = image.profiles[slice - 1]; int[] x = peaks.buildArray(); int[] xValues = new int[x.length]; int[] yValues = new int[x.length]; for (int i = 0; i < x.length; i++) { xValues[i] = image.distance2x(x[i]); yValues[i] = image.intensity2y(image.get(slice, x[i])); } return new PointRoi(xValues, yValues, x.length); }
public void addCenter() { final PointRoi cRoi = new PointRoi(centerRawX, centerRawY); cRoi.setPointType(1); cRoi.setStrokeColor(baseColor); cRoi.setProperty(TYPE, CENTER); setROIposition(cRoi, channel, centerRawZ, frame, hyperStack); overlay.add(cRoi, "center"); }
private Roi createPointRoi(final PolygonOverlay overlay) { PolygonRegionOfInterest region = overlay.getRegionOfInterest(); int nPoints = region.getVertexCount(); float[] xPts = new float[nPoints]; float[] yPts = new float[nPoints]; for (int i = 0; i < nPoints; i++) { RealLocalizable vertex = region.getVertex(i); xPts[i] = vertex.getFloatPosition(0); yPts[i] = vertex.getFloatPosition(1); } PointRoi roi = new PointRoi(xPts, yPts, nPoints); assignPropertiesToRoi(roi, overlay); return roi; }
/** Creates a point selection using integer coordinates.. */ public static void makePoint(int x, int y) { ImagePlus img = getImage(); Roi roi = img.getRoi(); if (shiftKeyDown() && roi!=null && roi.getType()==Roi.POINT) { Polygon p = roi.getPolygon(); p.addPoint(x, y); img.setRoi(new PointRoi(p.xpoints, p.ypoints, p.npoints)); IJ.setKeyUp(KeyEvent.VK_SHIFT); } else if (altKeyDown() && roi!=null && roi.getType()==Roi.POINT) { ((PolygonRoi)roi).deleteHandle(x, y); IJ.setKeyUp(KeyEvent.VK_ALT); } else img.setRoi(new PointRoi(x, y)); }