PolygonalROI¶
- class glue.core.roi.PolygonalROI(vx=None, vy=None)[source]¶
Bases:
VertexROIBase
A class to define 2D polygonal regions of interest.
- Parameters:
- vxfloat or array-like, optional
Initial x vertices.
- vyfloat or array-like, optional
Initial y vertices.
Methods Summary
area
([signed])Return area of polygon using the shoelace formula.
centroid
()Return centroid (centre of mass) of polygon.
contains
(x, y)Test which of a set of (x, y) points fall within the region of interest.
mean
()Return arithmetic mean (of vertex positions) of polygon.
move_to
(xdelta, ydelta)Translate the ROI to a center of (x, y)
rotate_to
(theta[, center])Rotate polygon to position angle theta around center.
Methods Documentation
- area(signed=False)[source]¶
Return area of polygon using the shoelace formula.
- Parameters:
- signedbool, optional
If True, return signed area from the cross product calculation, indicating whether vertices are ordered clockwise (negative) or counter clockwise (positive).
- contains(x, y)[source]¶
Test which of a set of (x, y) points fall within the region of interest.
- Parameters:
- xfloat or array-like
x coordinate(s) of point(s).
- yfloat or array-like
y coordinate(s) of point(s).
- Returns:
- insidebool or ~numpy.ndarray
An boolean iterable, where each element is True if the corresponding (x, y) tuple is inside the Roi.
- Raises:
- UndefinedROI
If not defined.
- rotate_to(theta, center=None)[source]¶
Rotate polygon to position angle theta around center.
- Parameters:
- thetafloat
Angle of anticlockwise rotation around center in radian.
- centerpair of float, optional
Coordinates of center of rotation. Defaults to
centroid()
, for linear “polygons” tomean()
.