Class ROIs

java.lang.Object
qupath.lib.roi.ROIs

public class ROIs extends Object
This class consists exclusively of static methods that operate on or return regions of interest (ROIs).

These methods should be used rather than constructors for individual ROI types.

  • Constructor Details

    • ROIs

      public ROIs()
  • Method Details

    • createEmptyROI

      public static ROI createEmptyROI()
      Create an 'empty' ROI with no length or area on the default image plane.

      The only guarantee is that it will return isEmpty() == true

      Returns:
    • createRectangleROI

      public static ROI createRectangleROI(double x, double y, double width, double height, ImagePlane plane)
      Create a rectangle ROI defined by its bounding box.
      Parameters:
      x - x coordinate of the top left of the rectangle
      y - y coordinate of the top left of the rectangle
      width - width of the rectangle
      height - height of the rectangle
      plane - the image plane where the rectangle should be located
      Returns:
      a new rectangle ROI
    • createRectangleROI

      public static ROI createRectangleROI(double x, double y, double width, double height)
      Create a rectangle ROI defined by its bounding box on the default image plane.
      Parameters:
      x - x coordinate of the top left of the rectangle
      y - y coordinate of the top left of the rectangle
      width - width of the rectangle
      height - height of the rectangle
      Returns:
      a new rectangle ROI
      Since:
      v0.6.0
      See Also:
    • createRectangleROI

      public static ROI createRectangleROI(ImageRegion region)
      Create a rectangle ROI that matches an ImageRegion.
      Parameters:
      region - an image region defining the rectangle location
      Returns:
      a new rectangle ROI
    • createEllipseROI

      public static ROI createEllipseROI(double x, double y, double width, double height, ImagePlane plane)
      Create an ellipse ROI defined by its bounding box.
      Parameters:
      x - x coordinate of the top left of the ellipse bounding box
      y - y coordinate of the top left of the ellipse bounding box
      width - width of the ellipse bounding box
      height - height of the ellipse bounding box
      plane - the image plane where the rectangle should be located
      Returns:
      a new ellipse ROI
    • createEllipseROI

      public static ROI createEllipseROI(double x, double y, double width, double height)
      Create an ellipse ROI defined by its bounding box on the default image plane.
      Parameters:
      x - x coordinate of the top left of the ellipse bounding box
      y - y coordinate of the top left of the ellipse bounding box
      width - width of the ellipse bounding box
      height - height of the ellipse bounding box
      Returns:
      a new ellipse ROI
      Since:
      v0.6.0
      See Also:
    • createEllipseROI

      public static ROI createEllipseROI(ImageRegion region)
      Create an ellipse ROI defined by its bounding box.
      Parameters:
      region - an image region defining the ellipse location
      Returns:
      a new ellipse ROI
    • createLineROI

      public static ROI createLineROI(double x, double y, double x2, double y2, ImagePlane plane)
      Create a line ROI with start and end coordinates.
      Parameters:
      x - the start x coordinate
      y - the start y coordinate
      x2 - the end x coordinate
      y2 - the end y coordinate
      plane - the plane containing the ROI
      Returns:
      a new line ROI
    • createLineROI

      public static ROI createLineROI(double x, double y, double x2, double y2)
      Create a line ROI with start and end coordinates on the default image plane.
      Parameters:
      x - the start x coordinate
      y - the start y coordinate
      x2 - the end x coordinate
      y2 - the end y coordinate
      Returns:
      a new line ROI
      Since:
      v0.6.0
      See Also:
    • createLineROI

      public static ROI createLineROI(double x, double y, ImagePlane plane)
      Create a ROI representing a line with zero length.
      Parameters:
      x - the start and end x coordinate
      y - the start and end y coordinate
      plane - the plane containing the ROI
      Returns:
      a new line ROI
    • createPointsROI

      public static ROI createPointsROI(ImagePlane plane)
      Create an empty points ROI.
      Parameters:
      plane - the plane that should contain the ROI
      Returns:
      a new points ROI
    • createPointsROI

      public static ROI createPointsROI()
      Create an empty points ROI on the default image plane.
      Returns:
      a new points ROI
      Since:
      v0.6.0
      See Also:
    • createPointsROI

      public static ROI createPointsROI(double x, double y, ImagePlane plane)
      Create a points ROI containing a single point.
      Parameters:
      x - x coordinate of the point
      y - y coordinate of the point
      plane - the plane that should contain the ROI
      Returns:
      a new point ROI
    • createPointsROI

      public static ROI createPointsROI(double x, double y)
      Create a points ROI containing a single point on the default image plane.
      Parameters:
      x - x coordinate of the point
      y - y coordinate of the point
      Returns:
      a new point ROI
      Since:
      v0.6.0
      See Also:
    • createPointsROI

      public static ROI createPointsROI(List<? extends Point2> points, ImagePlane plane)
      Create a points ROI from a list of points.
      Parameters:
      points - a list of points to include
      plane - the image plane containing the ROI
      Returns:
      a new points ROI
    • createPointsROI

      public static ROI createPointsROI(List<? extends Point2> points)
      Create a points ROI from a list of points on the default image plane.
      Parameters:
      points - a list of points to include
      Returns:
      a new points ROI
      Since:
      v0.6.0
      See Also:
    • createPointsROI

      public static ROI createPointsROI(double[] x, double[] y, ImagePlane plane) throws IllegalArgumentException
      Create a points ROI from an array of x and y coordinates.
      Parameters:
      x - x coordinates for the points
      y - y coordinates for the points
      plane - the image plane to contain the ROI
      Returns:
      a new points ROI
      Throws:
      IllegalArgumentException - if x and y have a different length
    • createPointsROI

      public static ROI createPointsROI(double[] x, double[] y) throws IllegalArgumentException
      Create a points ROI from an array of x and y coordinates on the default image plane.
      Parameters:
      x - x coordinates for the points
      y - y coordinates for the points
      Returns:
      a new points ROI
      Throws:
      IllegalArgumentException - if x and y have a different length
      Since:
      v0.6.0
      See Also:
    • createPolygonROI

      public static PolygonROI createPolygonROI(List<? extends Point2> points, ImagePlane plane)
      Create a closed polygon ROI from a list of points.
      Parameters:
      points - the vertices of the polygon
      plane - the plane containing the ROI
      Returns:
      a new polygon ROI
    • createPolygonROI

      public static PolygonROI createPolygonROI(List<? extends Point2> points)
      Create a closed polygon ROI from a list of points on the default image plane.
      Parameters:
      points - the vertices of the polygon
      Returns:
      a new polygon ROI
      Since:
      v0.6.0
      See Also:
    • createPolygonROI

      public static ROI createPolygonROI(double[] x, double[] y, ImagePlane plane) throws IllegalArgumentException
      Create a polygon ROI from an array of x and y coordinates.
      Parameters:
      x - x coordinates of the polygon vertices
      y - y coordinates of the polygon vertices
      plane - the plane containing the ROI
      Returns:
      a new polygon ROI
      Throws:
      IllegalArgumentException - if x and y have a different length
    • createPolygonROI

      public static ROI createPolygonROI(double[] x, double[] y) throws IllegalArgumentException
      Create a polygon ROI from an array of x and y coordinates on the default image plane
      Parameters:
      x - x coordinates of the polygon vertices
      y - y coordinates of the polygon vertices
      Returns:
      a new polygon ROI
      Throws:
      IllegalArgumentException - if x and y have a different length
      Since:
      v0.6.0
      See Also:
    • createPolygonROI

      public static PolygonROI createPolygonROI(double x, double y, ImagePlane plane)
      Create an empty, closed polygon ROI consisting of a single point.
      Parameters:
      x - x coordinate for the only polygon point
      y - y coordinate for the only polygon point
      plane - the image plane containing the ROI
      Returns:
      a new polygon ROI
    • createPolygonROI

      public static PolygonROI createPolygonROI(double x, double y)
      Create an empty, closed polygon ROI consisting of a single point on the default image plane.
      Parameters:
      x - x coordinate for the only polygon point
      y - y coordinate for the only polygon point
      Returns:
      a new polygon ROI
      Since:
      v0.6.0
      See Also:
    • createPolylineROI

      public static PolylineROI createPolylineROI(List<? extends Point2> points, ImagePlane plane)
      Create a polyline ROI from a list of points.
      Parameters:
      points - the vertices of the polyline
      plane - the plane containing the ROI
      Returns:
      a new polyline ROI
    • createPolylineROI

      public static PolylineROI createPolylineROI(List<? extends Point2> points)
      Create a polyline ROI from a list of points on the default image plane.
      Parameters:
      points - the vertices of the polyline
      Returns:
      a new polyline ROI
      Since:
      v0.6.0
      See Also:
    • createPolylineROI

      public static PolylineROI createPolylineROI(double x, double y, ImagePlane plane)
      Create an empty polyline ROI consisting of a single point.
      Parameters:
      x - x coordinate of the point
      y - y coordinate of the point
      plane - the image plane containing the ROI
      Returns:
      a new polyline ROI
    • createPolylineROI

      public static PolylineROI createPolylineROI(double x, double y)
      Create an empty polyline ROI consisting of a single point on the default iamge plane.
      Parameters:
      x - x coordinate of the point
      y - y coordinate of the point
      Returns:
      a new polyline ROI
      Since:
      v0.6.0
      See Also:
    • createPolylineROI

      public static ROI createPolylineROI(double[] x, double[] y, ImagePlane plane) throws IllegalArgumentException
      Create a polyline ROI from an array of x and y coordinates.
      Parameters:
      x - x coordinates of the polyline vertices
      y - y coordinates of the polyline vertices
      Returns:
      a new polygon ROI
      Throws:
      IllegalArgumentException - if x and y have a different length
    • createPolylineROI

      public static ROI createPolylineROI(double[] x, double[] y) throws IllegalArgumentException
      Create a polyline ROI from an array of x and y coordinates on the default image plane.
      Parameters:
      x - x coordinates of the polyline vertices
      y - y coordinates of the polyline vertices
      Returns:
      a new polygon ROI
      Throws:
      IllegalArgumentException - if x and y have a different length
      Since:
      v0.6.0
      See Also:
    • createAreaROI

      @Deprecated public static ROI createAreaROI(Shape shape, ImagePlane plane)
      Deprecated.
      v0.6.0, use RoiTools.getShapeROI(Shape, ImagePlane, double) instead. This method does not necessarily give the expected results for shapes that do not represent an area.
      Create an area ROI representing a 2D shape.

      The resulting ROI may consist of multiple disconnected regions, possibly containing holes.

      Parameters:
      shape - the shape for the ROI
      plane - the plane that should contain the ROI
      Returns:
      a new ROI representing the shape