AnnulusPixelRegion#

class regions.AnnulusPixelRegion[source]#

Bases: PixelRegion, ABC

A base class for annulus pixel regions.

Attributes Summary

area

The exact analytical area of the region shape.

bounding_box

The minimal bounding box (in integer pixel coordinates) that contains the region.

Methods Summary

as_artist([origin])

Convert to matplotlib patch object for this region.

contains(pixcoord)

Check whether a position or positions fall inside the region, excluding the boundary.

covers(pixcoord)

Check whether a position or positions fall inside the region, including the boundary.

rotate(center, angle)

Rotate the region.

to_mask([mode, subpixels])

Return a mask for the region.

Attributes Documentation

area#
bounding_box#

Methods Documentation

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

Convert to matplotlib patch object for this region.

Parameters:
originarray_like, optional

The (x, y) pixel position of the origin of the displayed image.

**kwargsdict

Any keyword arguments accepted by Patch.

Returns:
patchPatch

A matplotlib patch.

contains(pixcoord)[source]#

Check whether a position or positions fall inside the region, excluding the boundary.

This method considers points on the boundary as outside the region, consistent with Shapely’s contains function and DE-9IM semantics.

Parameters:
pixcoordPixCoord

The position or positions to check.

Returns:
resultbool or ndarray

A boolean or boolean array indicating whether the position(s) are inside the region.

See also

covers

Check if points are inside or on the boundary.

covers(pixcoord)[source]#

Check whether a position or positions fall inside the region, including the boundary.

This method considers points on the boundary as inside the region, consistent with Shapely’s covers function and DE-9IM semantics.

Parameters:
pixcoordPixCoord

The position or positions to check.

Returns:
resultbool or ndarray

A boolean or boolean array indicating whether the position(s) are inside or on the boundary of the region.

See also

contains

Check if points are strictly inside (excludes boundary).

rotate(center, angle)[source]#

Rotate the region.

Positive angle corresponds to counter-clockwise rotation.

Parameters:
centerPixCoord

The rotation center point.

angleAngle

The rotation angle.

Returns:
regionAnnulusPixelRegion

The rotated region (which is an independent copy).

to_mask(mode='center', subpixels=5)[source]#

Return a mask for the region.

Parameters:
mode{‘center’, ‘exact’, ‘subpixels’}, optional

The method used to determine the overlap of the region on the pixel grid. Not all options are available for all region types. Note that the more precise methods are generally slower. The following methods are available:

  • 'center': A pixel is considered to be entirely in or out of the region depending on whether its center is in or out of the region. The returned mask will contain values only of 0 (out) and 1 (in).

  • 'exact' (default): The exact fractional overlap of the region and each pixel is calculated. The returned mask will contain values between 0 and 1.

  • 'subpixel': A pixel is divided into subpixels (see the subpixels keyword), each of which are considered to be entirely in or out of the region depending on whether its center is in or out of the region. If subpixels=1, this method is equivalent to 'center'. The returned mask will contain values between 0 and 1.

subpixelsint, optional

For the 'subpixel' mode, resample pixels by this factor in each dimension. That is, each pixel is divided into subpixels ** 2 subpixels.

Returns:
maskRegionMask

A mask for the region.