protected static ArrayList<DifferenceOfGaussianPeak<FloatType>> filterForROI( final Roi roi, final ArrayList<DifferenceOfGaussianPeak<FloatType>> peaks ) { if ( roi == null ) { return peaks; } else { final ArrayList<DifferenceOfGaussianPeak<FloatType>> peaksNew = new ArrayList<DifferenceOfGaussianPeak<FloatType>>(); for ( final DifferenceOfGaussianPeak<FloatType> peak : peaks ) if ( roi.contains( Math.round( peak.getSubPixelPosition( 0 ) ), Math.round( peak.getSubPixelPosition( 1 ) ) ) ) peaksNew.add( peak ); return peaksNew; } }
public static List<Point> applyRoiMask(Roi roi, List<Point> detections) { if(roi == null) { return detections; } else { for(int i = 0; i < detections.size();) { Point pt = detections.get(i); if(!roi.contains(pt.x.intValue() + roi.getBounds().x, pt.y.intValue() + roi.getBounds().y)) { detections.remove(i); } else { i++; } } return detections; } } }
public static void labelROI(Roi roi, ImageProcessor ip, int color){ Rectangle bounds = roi.getBounds(); for(int i=bounds.x;i<=bounds.x+bounds.width;i++){ for(int j=bounds.y;j<=bounds.y+bounds.height;j++){ if(roi.contains(i,j)) ip.set(i,j,color); } } }
/** * Returns true iff the specified Roi contains the desired x and y positions, * and is located at the given position (C, Z, T). */ private boolean containsPoint(Roi r, int[] position, double x, double y) { return r.getCPosition() == position[0] && r.getZPosition() == position[1] && r.getTPosition() == position[2] && r.contains((int) Math.floor(x), (int) Math.floor(y)); }
@Override public boolean test(final Localizable t) { return roi.contains(t.getIntPosition(0), t.getIntPosition(1)); }
public void mouseReleased(ImagePlus imp, MouseEvent e) { ImageCanvas ic = imp.getCanvas(); int sx = e.getX(); int sy = e.getY(); int ox = ic.offScreenX(sx); int oy = ic.offScreenY(sy); Roi roi = imp.getRoi(); if (arrow!=null && !(roi!=null && (roi instanceof Arrow) && roi.contains(ox,oy))) { arrow.mouseReleased(e); e.consume(); } }
public void mouseReleased(ImagePlus imp, MouseEvent e) { ImageCanvas ic = imp.getCanvas(); int sx = e.getX(); int sy = e.getY(); int ox = ic.offScreenX(sx); int oy = ic.offScreenY(sy); Roi roi = imp.getRoi(); if (arrow!=null && !(roi!=null && (roi instanceof Arrow) && roi.contains(ox,oy))) { arrow.mouseReleased(e); e.consume(); } }
final double selectionContains() { int x = (int)Math.round(getFirstArg()); int y = (int)Math.round(getLastArg()); ImagePlus imp = getImage(); Roi roi = imp.getRoi(); if (roi==null) interp.error("Selection required"); return roi.contains(x,y)?1.0:0.0; }
final double selectionContains() { int x = (int)Math.round(getFirstArg()); int y = (int)Math.round(getLastArg()); ImagePlus imp = getImage(); Roi roi = imp.getRoi(); if (roi==null) interp.error("Selection required"); return roi.contains(x,y)?1.0:0.0; }
public void mouseDragged(ImagePlus imp, MouseEvent e) { ImageCanvas ic = imp.getCanvas(); int sx = e.getX(); int sy = e.getY(); int ox = ic.offScreenX(sx); int oy = ic.offScreenY(sy); Roi roi = imp.getRoi(); if (roi!=null && (roi instanceof Arrow) && roi.contains(ox,oy)) roi.mouseDragged(e); else if (arrow!=null) arrow.mouseDragged(e); e.consume(); }
public void mouseDragged(ImagePlus imp, MouseEvent e) { ImageCanvas ic = imp.getCanvas(); int sx = e.getX(); int sy = e.getY(); int ox = ic.offScreenX(sx); int oy = ic.offScreenY(sy); Roi roi = imp.getRoi(); if (roi!=null && (roi instanceof Arrow) && roi.contains(ox,oy)) roi.mouseDragged(e); else if (arrow!=null) arrow.mouseDragged(e); e.consume(); }
private boolean overOverlayLabel(int sx, int sy, int ox, int oy) { Overlay o = showAllOverlay; if (o==null) o = overlay; if (o==null || !o.isSelectable() || !o.getDrawLabels() || labelRects==null) return false; for (int i=o.size()-1; i>=0; i--) { if (labelRects!=null&&labelRects[i]!=null&&labelRects[i].contains(sx,sy)) { Roi roi = imp.getRoi(); if (roi==null || !roi.contains(ox,oy)) return true; else return false; } } return false; }
public void mousePressed(ImagePlus imp, MouseEvent e) { ImageCanvas ic = imp.getCanvas(); int sx = e.getX(); int sy = e.getY(); int ox = ic.offScreenX(sx); int oy = ic.offScreenY(sy); Roi roi = imp.getRoi(); int handle = roi!=null?roi.isHandle(ox, oy):-1; if (!(roi!=null && (roi instanceof Arrow) && (handle>=0||roi.contains(ox,oy)))) { arrow = new Arrow(sx, sy, imp); imp.setRoi(arrow, false); e.consume(); } }
private boolean overOverlayLabel(int sx, int sy, int ox, int oy) { Overlay o = showAllOverlay; if (o==null) o = overlay; if (o==null || !o.isSelectable() || !o.getDrawLabels() || labelRects==null) return false; for (int i=o.size()-1; i>=0; i--) { if (labelRects!=null&&labelRects[i]!=null&&labelRects[i].contains(sx,sy)) { Roi roi = imp.getRoi(); if (roi==null || !roi.contains(ox,oy)) return true; else return false; } } return false; }
public void mousePressed(ImagePlus imp, MouseEvent e) { ImageCanvas ic = imp.getCanvas(); int sx = e.getX(); int sy = e.getY(); int ox = ic.offScreenX(sx); int oy = ic.offScreenY(sy); Roi roi = imp.getRoi(); int handle = roi!=null?roi.isHandle(ox, oy):-1; if (!(roi!=null && (roi instanceof Arrow) && (handle>=0||roi.contains(ox,oy)))) { arrow = new Arrow(sx, sy, imp); imp.setRoi(arrow, false); e.consume(); } }
public boolean contains(int x, int y) { if (!super.contains(x, y)) return false; if (xSpline!=null) { FloatPolygon poly = new FloatPolygon(xSpline, ySpline, splinePoints); return poly.contains(x-this.x, y-this.y); } else if (xpf!=null) { FloatPolygon poly = new FloatPolygon(xpf, ypf, nPoints); return poly.contains(x-this.x, y-this.y); } else { Polygon poly = new Polygon(xp, yp, nPoints); return poly.contains(x-this.x, y-this.y); } }
public boolean contains(int x, int y) { if (!super.contains(x, y)) return false; if (xSpline!=null) { FloatPolygon poly = new FloatPolygon(xSpline, ySpline, splinePoints); return poly.contains(x-this.x, y-this.y); } else if (xpf!=null) { FloatPolygon poly = new FloatPolygon(xpf, ypf, nPoints); return poly.contains(x-this.x, y-this.y); } else { Polygon poly = new Polygon(xp, yp, nPoints); return poly.contains(x-this.x, y-this.y); } }
public static void threshold(Roi roi, int min, int max, ImageProcessor imageData, ImageProcessor labelData, int label) { mem = new Mem(labelData); Rectangle bounds = roi.getBounds(); for (int x = bounds.x; x <= bounds.x + bounds.width; x++) { for (int y = bounds.y; y <= bounds.y + bounds.height; y++) { if (roi.contains(x,y) && imageData.get(x, y) >= min && imageData.get(x, y) <= max) { mem.rememberPixel(x,y); labelData.set(x, y, label); } } } }
void getCursorLoc() { Variable x = getFirstVariable(); Variable y = getNextVariable(); Variable z = getNextVariable(); Variable flags = getLastVariable(); ImagePlus imp = getImage(); ImageCanvas ic = imp.getCanvas(); if (ic==null) return; Point p = ic.getCursorLoc(); x.setValue(p.x); y.setValue(p.y); z.setValue(imp.getCurrentSlice()-1); Roi roi = imp.getRoi(); flags.setValue(ic.getModifiers()+((roi!=null)&&roi.contains(p.x,p.y)?32:0)); }
void getCursorLoc() { Variable x = getFirstVariable(); Variable y = getNextVariable(); Variable z = getNextVariable(); Variable flags = getLastVariable(); ImagePlus imp = getImage(); ImageCanvas ic = imp.getCanvas(); if (ic==null) return; Point p = ic.getCursorLoc(); x.setValue(p.x); y.setValue(p.y); z.setValue(imp.getCurrentSlice()-1); Roi roi = imp.getRoi(); flags.setValue(ic.getModifiers()+((roi!=null)&&roi.contains(p.x,p.y)?32:0)); }