imagen.boundingregion

Module

Bounding regions and bounding boxes.

class imagen.boundingregion.AARectangle(*points)[source]

Bases: object

Axis-aligned rectangle class.

Defines the smallest axis-aligned rectangle that encloses a set of points.

Usage: aar = AARectangle( (x1,y1),(x2,y2), ... , (xN,yN) )

bottom()[source]

Return the y-coordinate of the bottom of the rectangle.

centroid()[source]

Return the centroid of the rectangle.

lbrt()[source]

Return (left,bottom,right,top) as a tuple.

left()[source]

Return the x-coordinate of the left side of the rectangle.

right()[source]

Return the x-coordinate of the right side of the rectangle.

top()[source]

Return the y-coordinate of the top of the rectangle.

class imagen.boundingregion.BoundingBox(**args)[source]

Bases: imagen.boundingregion.BoundingRegion

A rectangular bounding box defined either by two points forming an axis-aligned rectangle (or simply a radius for a square).

contains(x, y)[source]

Returns true if the given point is contained within the bounding box, where all boundaries of the box are considered to be inclusive.

contains_exclusive(x, y)[source]

Return True if the given point is contained within the bounding box, where the bottom and right boundaries are considered exclusive.

containsbb_exclusive(x)[source]

Returns true if the given BoundingBox x is contained within the bounding box, where at least one of the boundaries of the box has to be exclusive.

containsbb_inclusive(x)[source]

Returns true if the given BoundingBox x is contained within the bounding box, including cases of exact match.

lbrt()[source]

return left,bottom,right,top values for the BoundingBox.

upperexclusive_contains(x, y)[source]

Returns true if the given point is contained within the bounding box, where the right and upper boundaries are exclusive, and the left and lower boundaries are inclusive. Useful for tiling a plane into non-overlapping regions.

class imagen.boundingregion.BoundingBoxIntersection(*boxes, **params)[source]

Bases: imagen.boundingregion.BoundingBox

A BoundingBox initialized as the intersection of the supplied list of BoundingBoxes.

class imagen.boundingregion.BoundingCircle(center=(0.0, 0.0), radius=0.5, **args)[source]

Bases: imagen.boundingregion.BoundingRegion

A circular BoundingRegion.

Takes parameters center (a single 2D point (x,y)) and radius (a scalar radius).

class imagen.boundingregion.BoundingEllipse(**args)[source]

Bases: imagen.boundingregion.BoundingBox

Similar to BoundingBox, but the region is the ellipse inscribed within the rectangle.

class imagen.boundingregion.BoundingRegion[source]

Bases: object

Abstract bounding region class, for any portion of a 2D plane.

Only subclasses can be instantiated directly.

centroid()[source]

Return the coordinates of the center of this BoundingBox

imagen.boundingregion.BoundingRegionParameter[source]

Parameter whose value can be any BoundingRegion instance, enclosing a region in a 2D plane.

imagen.boundingregion.Cartesian2DPoint[source]

Parameter whose value represents a point in a 2D Cartesian plane.