public void showPoint(BenesNamedPoint p) { if(imp.getWindow() == null) return; if(!p.set){ IJ.error("Point is not set yet"); return; } int slice = (int)(p.z / cal.pixelDepth); if(slice < 0) slice = 0; if(slice > imp.getStackSize()) slice = imp.getStackSize()-1; imp.setSlice(slice+1); Roi roi = new PointRoi((int)(p.x / cal.pixelWidth), (int)(p.y / cal.pixelHeight), imp); imp.setRoi(roi); }
public void setCoordinates(PointRoi points1, PointRoi points2) { Rectangle r1 = points1.getBounds(); Rectangle r2 = points2.getBounds(); setCoordinates(points1.getXCoordinates(), points1.getYCoordinates(), r1.x, r1.y, points2.getXCoordinates(), points2.getYCoordinates(), r2.x, r2.y, points1.getNCoordinates()); }
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); }
@Override public Iterable<RealLocalizable> points() { final List<RealLocalizable> pts = new ArrayList<>(); final float[] x = points.getContainedFloatPoints().xpoints; final float[] y = points.getContainedFloatPoints().ypoints; final int numPoints = points.getNCoordinates(); for (int i = 0; i < numPoints; i++) { pts.add(new AbstractRealLocalizable(new double[] { x[i], y[i] }) {}); } return pts; }
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"); }
rt.addValue("X", 0.0); rt.addValue("Y", 0.0); if (imp.getStackSize()>1) rt.addValue("Slice", 0.0); return; FloatPolygon p = roi.getFloatPolygon(); ImageProcessor ip = imp.getProcessor(); Calibration cal = imp.getCalibration(); double x = p.xpoints[0]; double y = p.ypoints[0]; rt.addValue("Y", cal.getY(y, imp.getHeight())); int position = roi.getPosition(); if (imp.isHyperStack() || imp.isComposite()) { int channel = imp.getChannel(); rt.addValue("Slice", position); int[] info = roi.getCounterInfo(); if (info!=null) { rt.addValue("Counter", info[0]);
final Roi roi = displayImage.getRoi(); if( roi == null && null == RoiManager.getInstance() || null != RoiManager.getInstance() && new ImageStack( inputImage.getWidth(), inputImage.getHeight() ); ImageProcessor[] markerSlice = new ImageProcessor[ inputImage.getImageStackSize() ]; if( selectedRoi.isArea() ) markerSlice[ 0 ].fill( selectedRoi ); else else if( roi.isArea() ) markerSlice[0].fill( roi ); else int[] xpoints = roi.getPolygon().xpoints; int[] ypoints = roi.getPolygon().ypoints; markerSlice[ ((PointRoi) roi).getPointPosition( i ) -1 ].draw( new PointRoi( xpoints[i], ypoints[i] ) );
final int bitDepth = mask.getBitDepth(); new ImageStack( mask.getWidth(), mask.getHeight() ); ImageProcessor[] markerSlice = new ImageProcessor[ mask.getImageStackSize() ]; for( int n=0; n<mask.getImageStackSize(); n++ ) int[] xpoints = roi.getPolygon().xpoints; int[] ypoints = roi.getPolygon().ypoints; markerSlice[ ((PointRoi) roi).getPointPosition( i ) -1 ].draw( new PointRoi( xpoints[i], ypoints[i] ) ); int slice = manager.getSliceNumber( manager.getName( i ) ); if( selectedRoi.isArea() ) markerSlice[ slice-1 ].fill( selectedRoi ); else
xyVector=new Vector(); if (imp!=null) roi = imp.getRoi(); int x = offset % width; int y = offset / width; if (roi==null || roi.contains(x, y)) xyVector.addElement(new int[] {x, y}); PointRoi points = new PointRoi(xpoints, ypoints, npoints); if (npoints<15 && points.getSize()<3) points.setSize(3); if (npoints==1) points.setSize(4); imp.setRoi(points); int measurements = Analyzer.getMeasurements(); if ((measurements&Measurements.LABELS)!=0) { String s = imp.getTitle(); String roiName = roi!=null?roi.getName():null; if (roiName!=null) s += ":"+roiName;
@Override final protected void setHandles() { final int[] x = new int[]{ imp.getWidth() / 4, 3 * imp.getWidth() / 4 }; final int[] y = new int[]{ imp.getHeight() / 2, imp.getHeight() / 2 }; p = new Point[]{ new Point( new double[]{ x[ 0 ], y[ 0 ] } ), new Point( new double[]{ x[ 1 ], y[ 1 ] } ) }; q = new Point[]{ p[ 0 ].clone(), p[ 1 ].clone() }; m.add( new PointMatch( p[ 0 ], q[ 0 ] ) ); m.add( new PointMatch( p[ 1 ], q[ 1 ] ) ); handles = new PointRoi( x, y, 2 ); imp.setRoi( handles ); }
FloatPolygon p = roi.getFloatPolygon(); ImagePlus imp2 = isRedirectImage()?getRedirectImageOrStack(imp):null; if (imp2==null) imp2 = imp; ImageStack stack = null; if (imp2.getStackSize()>1) stack = imp2.getStack(); PointRoi pointRoi = roi instanceof PointRoi?(PointRoi)roi:null; for (int i=0; i<p.npoints; i++) { int position = 0; if (pointRoi!=null) position = pointRoi.getPointPosition(i); ImageProcessor ip = null; if (stack!=null && position>0 && position<=stack.size()) ip = stack.getProcessor(position); else ip = imp2.getProcessor(); ip.setRoi((int)p.xpoints[i], (int)p.ypoints[i], 1, 1); ImageStatistics stats = ImageStatistics.getStatistics(ip, measurements, imp2.getCalibration()); PointRoi point = new PointRoi(p.xpoints[i], p.ypoints[i]); point.setPosition(position); if (pointRoi!=null && pointRoi.getNCounters()>1) { int[] counters = pointRoi.getCounters(); if (counters!=null && i<counters.length) { int counter = counters[i]&0xff; int count = pointRoi.getCount(counter); int[] info = new int[2]; info[0] = counter; info[1] = count; point.setCounterInfo(info);
return; } else img.show(); } else if (arg.equalsIgnoreCase("image")) { interactiveMode = true; final int depth = img.getNSlices(); is3D = depth > 1; z = img.getZ(); channel = img.getC(); if (roi != null && roi.getType() == Roi.LINE) { } else if (roi != null && roi.getType() == Roi.POINT) { final Rectangle rect = point.getBounds(); x = rect.x; y = rect.y; multipointCount = point.getCount(point.getCounter()); if (multipointCount > 1) { primaryBranches = multipointCount - 1;
xyVector=new Vector(); if (imp!=null) roi = imp.getRoi(); int x = offset % width; int y = offset / width; if (roi==null || roi.contains(x, y)) xyVector.addElement(new int[] {x, y}); Roi points = new PointRoi(xpoints, ypoints, npoints); ((PointRoi)points).setShowLabels(false); imp.setRoi(points); int measurements = Analyzer.getMeasurements(); if ((measurements&Measurements.LABELS)!=0) { String s = imp.getTitle(); String roiName = roi!=null?roi.getName():null; if (roiName!=null) s += ":"+roiName;
@Override final protected void setHandles() { final Roi currentRoi = imp.getRoi(); int[] x; int[] y; if (currentRoi instanceof PolygonRoi && ((PolygonRoi)currentRoi).getNCoordinates() == 4 ) { x = currentRoi.getPolygon().xpoints; y = currentRoi.getPolygon().ypoints; } else { x = new int[]{ imp.getWidth() / 4, 3 * imp.getWidth() / 4, 3 * imp.getWidth() / 4, imp.getWidth() / 4 }; y = new int[]{ imp.getHeight() / 4, imp.getHeight() / 4, 3 * imp.getHeight() / 4, 3 * imp.getHeight() / 4 }; } p = new Point[]{ new Point( new double[]{ x[ 0 ], y[ 0 ] } ), new Point( new double[]{ x[ 1 ], y[ 1 ] } ), new Point( new double[]{ x[ 2 ], y[ 2 ] } ), new Point( new double[]{ x[ 3 ], y[ 3 ] } ) }; q = new Point[]{ p[ 0 ].clone(), p[ 1 ].clone(), p[ 2 ].clone(), p[ 3 ].clone() }; m.add( new PointMatch( p[ 0 ], q[ 0 ] ) ); m.add( new PointMatch( p[ 1 ], q[ 1 ] ) ); m.add( new PointMatch( p[ 2 ], q[ 2 ] ) ); m.add( new PointMatch( p[ 3 ], q[ 3 ] ) ); handles = new PointRoi( x, y, 4 ); imp.setRoi( handles ); }
for (int i=0; i<ids.length; i++) { ImagePlus imp = WindowManager.getImage(ids[i]); Roi roi = imp.getRoi(); if (null != roi && roi instanceof PointRoi) all.add(imp); int i=0; for (Iterator it = all.iterator(); it.hasNext(); ) titles[i++] = ((ImagePlus)it.next()).getTitle(); String current = WindowManager.getCurrentImage().getTitle(); gd.addChoice("source image", titles, current.equals(titles[0]) ? titles[1] : titles[0]); gd.addChoice("target image", titles, current); PointRoi points2 = (PointRoi)target.getRoi(); if (points1.getNCoordinates() != points2.getNCoordinates()) { IJ.showMessage("Unequal number of points!"); return;
ResultsTable results = Analyzer.getResultsTable(); gd.addCheckbox("inferSelectionFromParticles", imp.getRoi() == null && results != null && results.getColumnIndex("XM") != ResultsTable.COLUMN_NOT_FOUND); Calibration calib = imp.getCalibration(); int xCol = results.getColumnIndex("XM"); int yCol = results.getColumnIndex("YM"); calib.yOrigin); imp.setRoi(new PointRoi(xInt, yInt, x.length)); if (roi != null) roi.setImage(imp);
/** Creates a point selection using floating point coordinates. */ public static void makePoint(double x, double y) { ImagePlus img = getImage(); Roi roi = img.getRoi(); if (shiftKeyDown() && roi!=null && roi.getType()==Roi.POINT) { Polygon p = roi.getPolygon(); p.addPoint((int)Math.round(x), (int)Math.round(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)); }
int x = point.getX().intValue(); int y = point.getY().intValue(); roi = new PointRoi(x, y); int h = rectangle.getHeight().intValue(); roi = new Roi(x, y, w, h); roiLabel = shapeObject.getID(); roi.setName(roiLabel); if (imp.getNChannels() > 1) { c++; if (imp.getNSlices() > 1) { z++; if (imp.getNFrames() > 1) { t++; if (z == 0) z = 1; if (imp.getNChannels() == 1 && imp.getNSlices() == 1) { roi.setPosition(t); } else if (imp.getNChannels() == 1 && imp.getNFrames() == 1) { roi.setPosition(z);
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 ); }
if (roi instanceof ShapeRoi) return rotateShape((ShapeRoi)roi, -theta, xcenter, ycenter); FloatPolygon poly = roi.getFloatPolygon(); int type = roi.getType(); if (type==Roi.LINE) { Line line = (Line)roi; roi2 = new Line(poly.xpoints[0], poly.ypoints[0], poly.xpoints[1], poly.ypoints[1]); else if (type==Roi.POINT) roi2 = new PointRoi(poly.xpoints, poly.ypoints,poly.npoints); else { if (type==Roi.RECTANGLE) roi2 = new PolygonRoi(poly.xpoints, poly.ypoints,poly.npoints, type); roi2.setStrokeColor(roi.getStrokeColor()); if (roi.getStroke()!=null) roi2.setStroke(roi.getStroke());