locan.data.regions.region.Ellipse

class locan.data.regions.region.Ellipse(center=(0, 0), width=1, height=1, angle=0)[source]

Bases: Region2D

Region class to define an ellipse.

Parameters:
  • center (npt.ArrayLike) – A point that defines the center of the ellipse with shape (2,).

  • width (float) – The length of a vector describing the principal axis in x-direction (before rotation).

  • height (float) – The length of a vector describing the principal axis in y-direction (before rotation).

  • angle (float) – The angle (in degrees) by which the ellipse is rotated counterclockwise around the center point.

Methods

__init__([center, width, height, angle])

as_artist([origin])

Matplotlib 2D patch object for this region (e.g. matplotlib.patches.Ellipse).

buffer(distance, **kwargs)

Extend the region perpendicular by a distance.

contains(points)

Return list of indices for all points that are inside the region of interest.

from_intervals(intervals)

Constructor for instantiating a line or axis-oriented, box-like Region from list of (min, max) bounds.

from_shapely(shapely_object)

Constructor for instantiating Region from shapely object.

intersection(other)

Returns a region representing the intersection of this region with other.

plot([ax])

Provide plot of region as matplotlib.axes.Axes object.

symmetric_difference(other)

Returns the union of the two regions minus any areas contained in the intersection of the two regions.

union(other)

Returns a region representing the union of this region with other.

Attributes

angle

The angle (in degrees) by which the ellipse is rotated counterclockwise around the center point.

bounding_box

A region describing the minimum axis-aligned bounding box that encloses the original region.

bounds

Region bounds min_x, min_y, ..., max_x, max_y, .

center

A point that defines the center of the ellipse.

centroid

Point coordinates for region centroid.

dimension

The region dimension.

eccentricity

Shape factor related to the ratio of the length of minor to major axis: eccentricity = sqrt(1 - (b / a)^2).

elongation

A measure between 0 and 1 for how elongated the object is.

extent

The extent (max_x - min_x), (max_y - min_y), .

height

The length of a vector describing the principal axis in y-direction (before rotation).

intervals

Provide bounds in a tuple (min, max) arrangement.

isoperimetric_quotient

Ratio of the area of a region to the area of a circle with the same perimeter:

major_axis

The major axis of the region.

max_distance

The maximum distance between any two points within the region.

minor_axis

The minor axis of the region.

points

radial_distance

Average of all absolute distances between vertices and centroid.

region_measure

Region measure, i.e. area (for 2d) or volume (for 3d).

region_specs

Legacy interface to serve legacy RoiRegion.

rotation

A Rotation2D instance corresponding to angle.

shapely_object

Geometric object as defined in shapely.

subregion_measure

Measure of the sub-dimensional region, i.e. perimeter length (for 2d) or surface area (for 3d).

vertices

0 - dimensional elements that define the region; also called points.

width

The length of a vector describing the principal axis in x-direction (before rotation).

property angle: float

The angle (in degrees) by which the ellipse is rotated counterclockwise around the center point.

Return type:

float

as_artist(origin=(0, 0), **kwargs)[source]

Matplotlib 2D patch object for this region (e.g. matplotlib.patches.Ellipse).

Parameters:
  • origin (Union[_Buffer, _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[bool | int | float | complex | str | bytes]]) – The (x, y) pixel position of the origin of the displayed image. Default is (0, 0).

  • kwargs (Any) – Other parameters passed to the matplotlib.patches object.

Returns:

Matplotlib patch for the specified region.

Return type:

matplotlib.patches.Patch

property center: ndarray[tuple[int, ...], dtype[float64]]

A point that defines the center of the ellipse.

Returns:

with shape (2,)

Return type:

npt.NDArray[np.float64]

property centroid: ndarray[tuple[int, ...], dtype[float64]]

Point coordinates for region centroid.

Returns:

of shape (dimension,)

Return type:

npt.NDArray[np.float64] | None

contains(points)[source]

Return list of indices for all points that are inside the region of interest.

Parameters:

points (Union[_Buffer, _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[bool | int | float | complex | str | bytes]]) – Coordinates of points that are tested for being inside the specified region.

Returns:

Array with indices for all points in original point array that are within the region.

Return type:

npt.NDArray[np.int64]

property eccentricity: ndarray[tuple[int, ...], dtype[float64]]

Shape factor related to the ratio of the length of minor to major axis: eccentricity = sqrt(1 - (b / a)^2).

Return type:

npt.NDArray[np.float64]

property elongation: float

A measure between 0 and 1 for how elongated the object is. It is computed as: 1 - the ratio of length of minor axis to length of major axis.

Return type:

float

property height: float

The length of a vector describing the principal axis in y-direction (before rotation).

Return type:

float

property major_axis: LineSegment2D

The major axis of the region.

Return type:

LineSegment2D

property max_distance: float

The maximum distance between any two points within the region.

Return type:

float

property minor_axis: LineSegment2D

The minor axis of the region.

Return type:

LineSegment2D

property points: ndarray[tuple[int, ...], dtype[float64]]
property region_measure: float

Region measure, i.e. area (for 2d) or volume (for 3d).

Return type:

float

property region_specs

Legacy interface to serve legacy RoiRegion.

Warning

Do not use - will be deprecated.

Return type:

dict

property rotation: Rotation2D

A Rotation2D instance corresponding to angle.

Return type:

Rotation2D

property shapely_object: Polygon

Geometric object as defined in shapely.

Return type:

Shapely object

property subregion_measure: float

Measure of the sub-dimensional region, i.e. perimeter length (for 2d) or surface area (for 3d).

Return type:

float

property vertices: ndarray[tuple[int, ...], dtype[float64]]

0 - dimensional elements that define the region; also called points.

Returns:

of shape (n_vertices, dimension)

Return type:

npt.NDArray[np.float64] | list[npt.NDArray[np.float64]]

property width: float

The length of a vector describing the principal axis in x-direction (before rotation).

Return type:

float