Class RoiUtils

java.lang.Object
imagingbook.common.ij.RoiUtils

public class RoiUtils extends Object
This class defines static ROI-related utility methods to interface with ImageJ.
Version:
2022/09/22
  • Method Details

    • getOutlinePointsInt

      public static Pnt2d[] getOutlinePointsInt(Roi roi)
      Retrieves the outline of the specified ROI as an array of Pnt2d points with int coordinates. Note that unless the ROI is of type PolygonRoi or PointRoi only the corner points of the bounding box are returned. Interpolated contour points are returned for a instance of OvalRoi.
      Parameters:
      roi - the ROI
      Returns:
      the ROI's polygon coordinates
    • getOutlinePointsFloat

      public static Pnt2d[] getOutlinePointsFloat(Roi roi)
      Retrieves the outline of the specified ROI as an array of Pnt2d points with double coordinates. Returned coordinates are measured relative to the pixel center, e.g., (5.0, 3.0) is assumed to be in the middle of pixel (5, 3). This method retrieves ROI points with Roi.getFloatPolygon() but applies type-dependent correction for consistent point rendering.
      Parameters:
      roi - the Roi
      Returns:
      the ROI's outline coordinates
    • getPoints

      public static Pnt2d[] getPoints(FloatPolygon poly, double offset)
      Extracts the points of an ImageJ FloatPolygon.
      Parameters:
      poly - the original polygon
      offset - x/y offset to add to coordinates (typically -0.5 for "area ROIs")
      Returns:
      the polygon's vertex points
    • getPoints

      public static Pnt2d[] getPoints(FloatPolygon poly)
      Extracts the points of an ImageJ FloatPolygon. Calls getPoints(FloatPolygon, double) with zero offset.
      Parameters:
      poly - the original polygon
      Returns:
      the polygon's vertex points
    • toPointRoi

      public static PointRoi toPointRoi(Pnt2d[] points)
      Converts an array of 2D points (of type Pnt2d) to a PointRoi instance.
      Parameters:
      points - v
      Returns:
      a PointRoi instance