public static PolygonROI[][] splitAreaToPolygons(final AreaROI pathROI) { if (pathROI instanceof AWTAreaROI) return splitAreaToPolygons(new Area(((AWTAreaROI)pathROI).getShape())); else { logger.debug("Converting {} to {}", pathROI, AWTAreaROI.class.getSimpleName()); return splitAreaToPolygons(new Area(new AWTAreaROI(pathROI).getShape())); } // logger.error("Splitting non-AWT area ROIs not yet supported!"); // TODO: Support splitting non-AWT area ROIs! // return new PolygonROI[0][0]; }
@Override public ROI duplicate() { return new AWTAreaROI(shape, getC(), getZ(), getT()); }
@Override public TranslatableROI translate(double dx, double dy) { // Shift the bounds if (dx == 0 && dy == 0) return this; // Shift the region AffineTransform at = AffineTransform.getTranslateInstance(dx, dy); return new AWTAreaROI(new Path2D.Float(shape, at), getC(), getZ(), getT()); }
areaTemp.intersect(area); if (!areaTemp.isEmpty()) pathROI = new AWTAreaROI(areaTemp, parentROI.getC(), parentROI.getZ(), parentROI.getT());
tile = new AWTAreaROI(tileArea);
return new AWTAreaROI(area, c, z, t);
continue; double intersectionArea = new AWTAreaROI(temp).getArea(); double threshold = 0.1;
continue; double intersectionArea = new AWTAreaROI(temp).getArea(); double threshold = 0.1;
/** * * Create a simplified shape (fewer coordinates) using method based on Visvalingam’s Algorithm. * * See references: * https://hydra.hull.ac.uk/resources/hull:8338 * https://www.jasondavies.com/simplify/ * http://bost.ocks.org/mike/simplify/ * * @param polygon * @param areaThreshold * @return */ public static PathShape simplifyShape(PathShape shapeROI, double altitudeThreshold) { Shape shape = PathROIToolsAwt.getShape(shapeROI); Path2D path = shape instanceof Path2D ? (Path2D)shape : new Path2D.Float(shape); path = simplifyPath(path, altitudeThreshold); // Construct a new polygon return new AWTAreaROI(path, shapeROI.getC(), shapeROI.getZ(), shapeROI.getT()); }
return ((AWTAreaROI)roi).getShape(); } if (roi instanceof AreaROI) { return new AWTAreaROI((AreaROI)roi).getShape();