Package qupath.lib.roi
Class PointsROI
java.lang.Object
qupath.lib.roi.PointsROI
- All Implemented Interfaces:
Serializable
,ROI
ROI representing a collection of 2D points (distinct x,y coordinates).
- Author:
- Pete Bankhead
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface qupath.lib.roi.interfaces.ROI
ROI.RoiType
-
Method Summary
Modifier and TypeMethodDescriptionboolean
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
getArea()
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
getC()
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.Default implementation using JTS.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.getNearest
(double x, double y, double maxDist) Identify the closest point within a specified distance to coordinates x,y - or null if no points are found.int
Default implementation, callsROI.getAllPoints()
and then caches the result.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.getShape()
It is not possible to convert a PointROI to a java.awt.Shape.double
Calculate the solidity, defined as ROI area / convex hull area.int
getT()
Get time point index.int
getZ()
Get z-stack slice index.boolean
isArea()
Returns true if this ROI encloses an area.boolean
isEmpty()
A Points ROI is empty if it contains no points (*not* if its bounds have no width or height...boolean
isLine()
Returns true if this ROI consists of line segments and does not enclose an area.boolean
isPoint()
Returns true if this ROI represents distinct (unconnected) points.protected void
scale
(double scaleX, double scaleY, double originX, double originY) Create a scaled version of this ROI.toString()
translate
(double dx, double dy) Create a translated version of this ROI.protected void
updateBounds
(double x, double y) updatePlane
(ImagePlane plane) Create a new ROI defining the same region on a differentImagePlane
.
-
Method Details
-
getCentroidX
public double getCentroidX()Description copied from interface:ROI
Returns the x coordinate for the ROI centroid.- Specified by:
getCentroidX
in interfaceROI
- Returns:
-
getCentroidY
public double getCentroidY()Description copied from interface:ROI
Returns the y coordinate for the ROI centroid.- Specified by:
getCentroidY
in interfaceROI
- Returns:
-
getNearest
Identify the closest point within a specified distance to coordinates x,y - or null if no points are found.- Parameters:
x
-y
-maxDist
-- Returns:
-
recomputeBounds
protected void recomputeBounds() -
updateBounds
protected void updateBounds(double x, double y) -
isEmpty
public boolean isEmpty()A Points ROI is empty if it contains no points (*not* if its bounds have no width or height... since this would occur for a single-point ROI). -
getRoiName
Description copied from interface:ROI
Get a String representation of the kind of ROI we have, e.g. "Rectangle", "Ellipse", "Polygon"- Specified by:
getRoiName
in interfaceROI
- Returns:
-
toString
-
getNumPoints
public int getNumPoints()Default implementation, callsROI.getAllPoints()
and then caches the result. Subclasses may override for efficiency.- Specified by:
getNumPoints
in interfaceROI
- Returns:
-
getAllPoints
Description copied from interface:ROI
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.
- Specified by:
getAllPoints
in interfaceROI
- Returns:
-
scale
Description copied from interface:ROI
Create a scaled version of this ROI. Coordinates are multiplied by the given scaling factors, while the original ROI is unchanged.- Specified by:
scale
in interfaceROI
- Parameters:
scaleX
- horizontal scale valuescaleY
- vertical scale valueoriginX
- value subtracted from each x-ordinate prior to scaling, and added back afterwardsoriginY
- value subtracted from each y-ordinate prior to scaling, and added back afterwards- Returns:
- See Also:
-
duplicate
Deprecated.Description copied from interface:ROI
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.
-
getConvexHull
Default implementation using JTS. Subclasses may replace this with a more efficient implementation.- Specified by:
getConvexHull
in interfaceROI
- Returns:
-
getBoundsX
public double getBoundsX()Description copied from interface:ROI
Returns the x coordinate for the top left of the ROI bounding box.- Specified by:
getBoundsX
in interfaceROI
- Returns:
-
getBoundsY
public double getBoundsY()Description copied from interface:ROI
Returns the y coordinate for the top left of the ROI bounding box.- Specified by:
getBoundsY
in interfaceROI
- Returns:
-
getBoundsWidth
public double getBoundsWidth()Description copied from interface:ROI
Returns the width of the ROI bounding box.- Specified by:
getBoundsWidth
in interfaceROI
- Returns:
-
getBoundsHeight
public double getBoundsHeight()Description copied from interface:ROI
Returns the height of the ROI bounding box.- Specified by:
getBoundsHeight
in interfaceROI
- Returns:
-
getShape
It is not possible to convert a PointROI to a java.awt.Shape. throws UnsupportedOperationException- Specified by:
getShape
in interfaceROI
- Returns:
- Throws:
UnsupportedOperationException
-
getRoiType
Description copied from interface:ROI
Get the RoiType, used to distinguish between points, lines and areas.- Specified by:
getRoiType
in interfaceROI
- Returns:
-
updatePlane
Description copied from interface:ROI
Create a new ROI defining the same region on a differentImagePlane
. The original ROI is unchanged.- Specified by:
updatePlane
in interfaceROI
- Parameters:
plane
- the new plane to use- Returns:
-
translate
Description copied from interface:ROI
Create a translated version of this ROI. The original ROI is unchanged. -
getArea
public double getArea()Description copied from interface:ROI
Get the area of this ROI. For lines and points this returns 0. -
getScaledArea
public double getScaledArea(double pixelWidth, double pixelHeight) Description copied from interface:ROI
Get scaled area of the ROI, for use with calibrated pixel sizes.- Specified by:
getScaledArea
in interfaceROI
- Parameters:
pixelWidth
-pixelHeight
-- Returns:
- See Also:
-
contains
public boolean contains(double x, double y) Description copied from interface:ROI
Test is the ROI contains specified x, y coordinates. Only Area ROIs can return true, i.e. whereROI.isArea()
returns true. All other ROIs (points, lines) return false. -
getLength
public double getLength()Description copied from interface:ROI
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
-
getScaledLength
public double getScaledLength(double pixelWidth, double pixelHeight) Description copied from interface:ROI
Get the scaled length, for use with calibrated pixel sizes.- Specified by:
getScaledLength
in interfaceROI
- Parameters:
pixelWidth
-pixelHeight
-- Returns:
- See Also:
-
getImagePlane
Description copied from interface:ROI
Get the ImagePlane, which contains the values for c, z and t in a single object.- Specified by:
getImagePlane
in interfaceROI
- Returns:
-
getZ
public int getZ()Description copied from interface:ROI
Get z-stack slice index.Default is 0 if the image it relates to is not a z-stack.
-
getT
public int getT()Description copied from interface:ROI
Get time point index.Default is 0 if the image it relates to is not a time series.
-
getC
public int getC()Description copied from interface:ROI
Get channel index, or -1 if the ROI relates to all available channels.(This is not currently used, but may be in the future)
-
isLine
public boolean isLine()Description copied from interface:ROI
Returns true if this ROI consists of line segments and does not enclose an area. -
isArea
public boolean isArea()Description copied from interface:ROI
Returns true if this ROI encloses an area. -
isPoint
public boolean isPoint()Description copied from interface:ROI
Returns true if this ROI represents distinct (unconnected) points. -
getGeometry
Description copied from interface:ROI
Returns a org.locationtech.jts.geom.Geometry object.- Specified by:
getGeometry
in interfaceROI
- Returns:
-
getSolidity
public double getSolidity()Description copied from interface:ROI
Calculate the solidity, defined as ROI area / convex hull area. Returns Double.NaN if the ROI does not represent an area.- Specified by:
getSolidity
in interfaceROI
- Returns:
-