protected static int[] getXCoordinates(PolygonRoi roi) { try { Rectangle bounds = roi.getBounds(); int[] xp = (int[])xpField.get(roi); int[] result = new int[xp.length]; for (int i = 0; i < xp.length; i++) result[i] = xp[i] + bounds.x; return result; } catch (Exception e) { IJ.handleException(e); return null; } }
protected static int[] getYCoordinates(PolygonRoi roi) { try { Rectangle bounds = roi.getBounds(); int[] yp = (int[])ypField.get(roi); int[] result = new int[yp.length]; for (int i = 0; i < yp.length; i++) result[i] = yp[i] + bounds.y; return result; } catch (Exception e) { IJ.handleException(e); return null; } }
int[] xCoordinates = getXCoordinates(); int[] yCoordinates = getYCoordinates(); Rectangle r = getBounds(); int xbase = r.x; int ybase = r.y;
int[] xCoordinates = getXCoordinates(); int[] yCoordinates = getYCoordinates(); Rectangle r = getBounds(); int xbase = r.x; int ybase = r.y;
@Override public void mouseDragged(MouseEvent e) { if (activeHandle >= 0) { ImagePlus image = getImagePlus(e); Roi roi = image.getRoi(); if (roi != null) { if (roi instanceof PolygonRoi) { PolygonRoi polygonROI = (PolygonRoi)roi; Rectangle bounds = polygonROI.getBounds(); polygonROI.getXCoordinates()[activeHandle] = getOffscreenX(e) - bounds.x; polygonROI.getYCoordinates()[activeHandle] = getOffscreenY(e) - bounds.y; setRoi(image, polygonROI); } } } e.consume(); }
private void fillPolygon(ImageProcessor ip, Polygon p, boolean internContour) { PolygonRoi proi = new PolygonRoi(p, PolygonRoi.POLYGON); Rectangle r = proi.getBounds(); PolygonFiller pf = new PolygonFiller(); pf.setPolygon(proi.getXCoordinates(), proi.getYCoordinates(), proi.getNCoordinates()); ip.setRoi(r); ImageProcessor objectMask = pf.getMask(r.width, r.height); ip.fill(objectMask); if(!internContour){ ip.drawPolygon(p); } }
y = smooth(y, n); float[] curvature = getCurvature(x, y, n); Rectangle r = roi.getBounds(); double threshold = rodbard(length);
y = smooth(y, n); float[] curvature = getCurvature(x, y, n); Rectangle r = roi.getBounds(); double threshold = rodbard(length);
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); }
final int[] x = proi.getXCoordinates(), y = proi.getYCoordinates(); final Rectangle b = proi.getBounds(); final Polygon[] pols = new Polygon[proi.getNCoordinates() -1]; for (int i=0; i<pols.length; i++) {