Interface ROI

All Known Implementing Classes:
AreaROI, EllipseROI, GeometryROI, LineROI, PointsROI, PolygonROI, PolylineROI, RectangleROI

public interface ROI
Base interface for defining regions of interest (ROIs) within QuPath.

In general, anything that returns a coordinate should be defined in terms of pixels from the top left of the full-resolution image.

Author:
Pete Bankhead
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Enum representing the major different types of ROI.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(double x, double y)
    Test is the ROI contains specified x, y coordinates.
    Deprecated.
    Get a list of points representing the vertices of the ROI.
    double
    Get the area of this ROI.
    double
    Returns the height of the ROI bounding box.
    double
    Returns the width of the ROI bounding box.
    double
    Returns the x coordinate for the top left of the ROI bounding box.
    double
    Returns the y coordinate for the top left of the ROI bounding box.
    int
    Get channel index, or -1 if the ROI relates to all available channels.
    double
    Returns the x coordinate for the ROI centroid.
    double
    Returns the y coordinate for the ROI centroid.
    Get a ROI representing the convex hull of this ROI.
    Returns a org.locationtech.jts.geom.Geometry object.
    Get the ImagePlane, which contains the values for c, z and t in a single object.
    double
    Get ROI length.
    int
    Get the number of points, as would be returned by getAllPoints().
    Get a String representation of the kind of ROI we have, e.g.
    Get the RoiType, used to distinguish between points, lines and areas.
    double
    getScaledArea(double pixelWidth, double pixelHeight)
    Get scaled area of the ROI, for use with calibrated pixel sizes.
    double
    getScaledLength(double pixelWidth, double pixelHeight)
    Get the scaled length, for use with calibrated pixel sizes.
    Returns a java.awt.Shape representing this ROI, if possible.
    double
    Calculate the solidity, defined as ROI area / convex hull area.
    int
    Get time point index.
    int
    Get z-stack slice index.
    boolean
    Returns true if this ROI encloses an area.
    boolean
    Returns true if the ROI bounds have zero width and height.
    boolean
    Returns true if this ROI consists of line segments and does not enclose an area.
    boolean
    Returns true if this ROI represents distinct (unconnected) points.
    default ROI
    scale(double scaleX, double scaleY)
    Create a scaled version of this ROI.
    scale(double scaleX, double scaleY, double originX, double originY)
    Create a scaled version of this ROI.
    translate(double dx, double dy)
    Create a translated version of this ROI.
    Create a new ROI defining the same region on a different ImagePlane.
  • Method Details

    • getRoiName

      String getRoiName()
      Get a String representation of the kind of ROI we have, e.g. "Rectangle", "Ellipse", "Polygon"
      Returns:
    • getC

      int getC()
      Get channel index, or -1 if the ROI relates to all available channels.

      (This is not currently used, but may be in the future)

      Returns:
    • getT

      int getT()
      Get time point index.

      Default is 0 if the image it relates to is not a time series.

      Returns:
    • getZ

      int getZ()
      Get z-stack slice index.

      Default is 0 if the image it relates to is not a z-stack.

      Returns:
    • getImagePlane

      ImagePlane getImagePlane()
      Get the ImagePlane, which contains the values for c, z and t in a single object.
      Returns:
    • getCentroidX

      double getCentroidX()
      Returns the x coordinate for the ROI centroid.
      Returns:
    • getCentroidY

      double getCentroidY()
      Returns the y coordinate for the ROI centroid.
      Returns:
    • getBoundsX

      double getBoundsX()
      Returns the x coordinate for the top left of the ROI bounding box.
      Returns:
    • getBoundsY

      double getBoundsY()
      Returns the y coordinate for the top left of the ROI bounding box.
      Returns:
    • getBoundsWidth

      double getBoundsWidth()
      Returns the width of the ROI bounding box.
      Returns:
    • getBoundsHeight

      double getBoundsHeight()
      Returns the height of the ROI bounding box.
      Returns:
    • getAllPoints

      List<Point2> getAllPoints()
      Get a list of points representing the vertices of the ROI.

      This is only really well-defined for ROIs where a single set of vertices represents the shape completely; the expected output for a ROI that contains holes or disconnected regions is (currently) undefined.

      Returns:
    • getNumPoints

      int getNumPoints()
      Get the number of points, as would be returned by getAllPoints().
      Returns:
    • isEmpty

      boolean isEmpty()
      Returns true if the ROI bounds have zero width and height.
      Returns:
    • duplicate

      @Deprecated ROI duplicate()
      Deprecated.
      Create a duplicate of the ROI.

      This method is deprecated, since ROIs are (or are moving towards being) immutable... making it pointless to duplicate them.

      Returns:
    • getShape

      Shape getShape()
      Returns a java.awt.Shape representing this ROI, if possible.

      Note that PointROI throws an UnsupportedOperationException as it cannot adequately be represented by a Shape object.

      Returns:
    • getGeometry

      Geometry getGeometry()
      Returns a org.locationtech.jts.geom.Geometry object.
      Returns:
    • getRoiType

      ROI.RoiType getRoiType()
      Get the RoiType, used to distinguish between points, lines and areas.
      Returns:
    • isLine

      boolean isLine()
      Returns true if this ROI consists of line segments and does not enclose an area.
      Returns:
    • isArea

      boolean isArea()
      Returns true if this ROI encloses an area.
      Returns:
    • isPoint

      boolean isPoint()
      Returns true if this ROI represents distinct (unconnected) points.
      Returns:
    • translate

      ROI translate(double dx, double dy)
      Create a translated version of this ROI. The original ROI is unchanged.
      Parameters:
      dx - horizontal translation
      dy - vertical translation
      Returns:
    • scale

      ROI scale(double scaleX, double scaleY, double originX, double originY)
      Create a scaled version of this ROI. Coordinates are multiplied by the given scaling factors, while the original ROI is unchanged.
      Parameters:
      scaleX - horizontal scale value
      scaleY - vertical scale value
      originX - value subtracted from each x-ordinate prior to scaling, and added back afterwards
      originY - value subtracted from each y-ordinate prior to scaling, and added back afterwards
      Returns:
      See Also:
    • scale

      default ROI scale(double scaleX, double scaleY)
      Create a scaled version of this ROI. Coordinates are multiplied by the given scaling factors, while the original ROI is unchanged. The scaling uses 0,0 as the origin.
      Parameters:
      scaleX - horizontal scale value
      scaleY - vertical scale value
      Returns:
      See Also:
    • getArea

      double getArea()
      Get the area of this ROI. For lines and points this returns 0.
      Returns:
      See Also:
    • getScaledArea

      double getScaledArea(double pixelWidth, double pixelHeight)
      Get scaled area of the ROI, for use with calibrated pixel sizes.
      Parameters:
      pixelWidth -
      pixelHeight -
      Returns:
      See Also:
    • getLength

      double getLength()
      Get ROI length. This is defined as
      • perimeter in the case of area ROIs
      • total length of line segments in the case of line or polyline ROIs
      • 0 in the case of point ROIs
      Returns:
      See Also:
    • getScaledLength

      double getScaledLength(double pixelWidth, double pixelHeight)
      Get the scaled length, for use with calibrated pixel sizes.
      Parameters:
      pixelWidth -
      pixelHeight -
      Returns:
      See Also:
    • getConvexHull

      ROI getConvexHull()
      Get a ROI representing the convex hull of this ROI. This should be the smallest convex shape that contains all the ROI points.
      Returns:
    • getSolidity

      double getSolidity()
      Calculate the solidity, defined as ROI area / convex hull area. Returns Double.NaN if the ROI does not represent an area.
      Returns:
    • contains

      boolean contains(double x, double y)
      Test is the ROI contains specified x, y coordinates. Only Area ROIs can return true, i.e. where isArea() returns true. All other ROIs (points, lines) return false.
      Parameters:
      x -
      y -
      Returns:
    • updatePlane

      ROI updatePlane(ImagePlane plane)
      Create a new ROI defining the same region on a different ImagePlane. The original ROI is unchanged.
      Parameters:
      plane - the new plane to use
      Returns: