Package qupath.lib.roi
Class RectangleROI
java.lang.Object
qupath.lib.roi.RectangleROI
- All Implemented Interfaces:
Serializable,ROI
ROI representing a square or rectangle (unrotated).
- Author:
- Pete Bankhead
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface qupath.lib.roi.interfaces.ROI
ROI.RoiType -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(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.doublegetArea()Get the area of this ROI.doubleReturns the height of the ROI bounding box.doubleReturns the width of the ROI bounding box.doubleReturns the x coordinate for the top left of the ROI bounding box.doubleReturns the y coordinate for the top left of the ROI bounding box.intgetC()Get channel index, or -1 if the ROI relates to all available channels.doubleReturns the x coordinate for the ROI centroid.doubleReturns 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.doubleGet ROI length.intReturns 4 (since the rectangle is defined by its bounding box).Get a String representation of the kind of ROI we have, e.g.Get the RoiType, used to distinguish between points, lines and areas.doublegetScaledArea(double pixelWidth, double pixelHeight) Get scaled area of the ROI, for use with calibrated pixel sizes.doublegetScaledLength(double pixelWidth, double pixelHeight) Get the scaled length, for use with calibrated pixel sizes.getShape()Returns a java.awt.Shape representing this ROI, if possible.doubleCalculate the solidity, defined as ROI area / convex hull area.intgetT()Get time point index.intgetZ()Get z-stack slice index.booleanisArea()Returns true if this ROI encloses an area.booleanisEmpty()True if the bounding box has zero areabooleanisLine()Returns true if this ROI consists of line segments and does not enclose an area.booleanisPoint()Returns true if this ROI represents distinct (unconnected) points.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.updatePlane(ImagePlane plane) Create a new ROI defining the same region on a differentImagePlane.
-
Field Details
-
x
protected double x -
y
protected double y -
x2
protected double x2 -
y2
protected double y2
-
-
Method Details
-
contains
public boolean contains(double x, double y) Description copied from interface:ROITest 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. -
getRoiName
Description copied from interface:ROIGet a String representation of the kind of ROI we have, e.g. "Rectangle", "Ellipse", "Polygon"- Specified by:
getRoiNamein interfaceROI- Returns:
-
getNumPoints
public int getNumPoints()Returns 4 (since the rectangle is defined by its bounding box).- Specified by:
getNumPointsin interfaceROI- Returns:
-
getScaledArea
public double getScaledArea(double pixelWidth, double pixelHeight) Description copied from interface:ROIGet scaled area of the ROI, for use with calibrated pixel sizes.- Specified by:
getScaledAreain interfaceROI- Returns:
- See Also:
-
getScaledLength
public double getScaledLength(double pixelWidth, double pixelHeight) Description copied from interface:ROIGet the scaled length, for use with calibrated pixel sizes.- Specified by:
getScaledLengthin interfaceROI- Returns:
- See Also:
-
duplicate
Deprecated.Description copied from interface:ROICreate a duplicate of the ROI.This method is deprecated, since ROIs are (or are moving towards being) immutable... making it pointless to duplicate them.
-
getAllPoints
Description copied from interface:ROIGet 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:
getAllPointsin interfaceROI- Returns:
-
getShape
Description copied from interface:ROIReturns 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.
-
translate
Description copied from interface:ROICreate a translated version of this ROI. The original ROI is unchanged. -
getConvexHull
Default implementation using JTS. Subclasses may replace this with a more efficient implementation.- Specified by:
getConvexHullin interfaceROI- Returns:
-
getRoiType
Description copied from interface:ROIGet the RoiType, used to distinguish between points, lines and areas.- Specified by:
getRoiTypein interfaceROI- Returns:
-
updatePlane
Description copied from interface:ROICreate a new ROI defining the same region on a differentImagePlane. The original ROI is unchanged.- Specified by:
updatePlanein interfaceROI- Parameters:
plane- the new plane to use- Returns:
-
scale
Description copied from interface:ROICreate a scaled version of this ROI. Coordinates are multiplied by the given scaling factors, while the original ROI is unchanged.- Specified by:
scalein 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:
-
getCentroidX
public double getCentroidX()Description copied from interface:ROIReturns the x coordinate for the ROI centroid.- Returns:
-
getCentroidY
public double getCentroidY()Description copied from interface:ROIReturns the y coordinate for the ROI centroid.- Returns:
-
isEmpty
public boolean isEmpty()True if the bounding box has zero area -
getBoundsX
public double getBoundsX()Description copied from interface:ROIReturns the x coordinate for the top left of the ROI bounding box.- Returns:
-
getBoundsY
public double getBoundsY()Description copied from interface:ROIReturns the y coordinate for the top left of the ROI bounding box.- Returns:
-
getBoundsWidth
public double getBoundsWidth()Description copied from interface:ROIReturns the width of the ROI bounding box.- Returns:
-
getBoundsHeight
public double getBoundsHeight()Description copied from interface:ROIReturns the height of the ROI bounding box.- Returns:
-
getImagePlane
Description copied from interface:ROIGet the ImagePlane, which contains the values for c, z and t in a single object.- Specified by:
getImagePlanein interfaceROI- Returns:
-
getZ
public int getZ()Description copied from interface:ROIGet 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:ROIGet 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:ROIGet channel index, or -1 if the ROI relates to all available channels.(This is not currently used, but may be in the future)
-
toString
-
isLine
public boolean isLine()Description copied from interface:ROIReturns true if this ROI consists of line segments and does not enclose an area. -
isArea
public boolean isArea()Description copied from interface:ROIReturns true if this ROI encloses an area. -
isPoint
public boolean isPoint()Description copied from interface:ROIReturns true if this ROI represents distinct (unconnected) points. -
getGeometry
Description copied from interface:ROIReturns a org.locationtech.jts.geom.Geometry object.- Specified by:
getGeometryin interfaceROI- Returns:
-
getArea
public double getArea()Description copied from interface:ROIGet the area of this ROI. For lines and points this returns 0. -
getLength
public double getLength()Description copied from interface:ROIGet 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
-
getSolidity
public double getSolidity()Description copied from interface:ROICalculate the solidity, defined as ROI area / convex hull area. Returns Double.NaN if the ROI does not represent an area.- Specified by:
getSolidityin interfaceROI- Returns:
-