scarlet.bbox¶
- class scarlet.bbox.Box(shape, origin=None)[source]¶
Bases:
object
Bounding Box for an object
A Bounding box describes the location of a data unit in the global/model coordinate system. It is used to identify spatial and channel overlap and to map from model to observed frames and back.
The BBox code is agnostic about the meaning of the dimensions. We generally use this convention:
2D shapes denote (Height, Width)
3D shapes denote (Channels, Height, Width)
- Parameters:
- shape: tuple
Size of the box
- origin: tuple
Minimum corner coordinate of the box
- Attributes:
Methods
contains
(p)Whether the box contains a given coordinate p
copy
()Copy of the box
extract_from
(image[, sub])Extract sub-image described by this bbox from image
from_bounds
(*bounds)Initialize a box from its bounds
from_data
(X[, min_value])Define range of X above min_value
grow
(radius)Grow the Box by the given radius in each direction
insert_into
(image, sub)Insert sub into image according to this bbox
- property D¶
Dimensionality of this BBox
- property bounds¶
Bounds of the box
- property center¶
Tuple of center coordinates
- extract_from(image, sub=None)[source]¶
Extract sub-image described by this bbox from image
- Parameters:
- image: array
Full image
- sub: array
Extracted image
- Returns:
- sub: array
- static from_bounds(*bounds)[source]¶
Initialize a box from its bounds
- Parameters:
- bounds: tuple of (min,max) pairs
Min/Max coordinate for every dimension
- Returns:
- bbox:
scarlet.bbox.Box
A new box bounded by the input bounds.
- bbox:
- static from_data(X, min_value=0)[source]¶
Define range of X above min_value
- Parameters:
- X: array-like
Data to threshold
- min_value: float
Minimum value of the result.
- Returns:
- bbox:
scarlet.bbox.Box
Bounding box for the thresholded X
- bbox:
- insert_into(image, sub)[source]¶
Insert sub into image according to this bbox
Inverse operation to
extract_from()
.- Parameters:
- image: array
Full image
- sub: array
Extracted sub-image
- Returns:
- image: array
- property slices¶
Bounds of the box as slices
- property start¶
Tuple of start coordinates
- property stop¶
Tuple of stop coordinates