Box#
- class scarlet2.Box(shape, origin=None)[source]#
Bases:
ModuleBounding Box for data array
A Bounding box describes the location of a data array in the 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 arrayorigin (
tuple, optional) – Start coordinate (in 2D: lower-left corner) of the array in model frame
- property D#
Dimensionality of this BBox
- __and__(other)[source]#
Intersection of two bounding boxes
If there is no intersection between the two bounding boxes then an empty bounding box is returned.
- Parameters:
other (Box) – The other bounding box in the intersection
- Returns:
result – The rectangular box that is in the overlap region of both boxes.
- Return type:
Box
- __or__(other)[source]#
Union of two bounding boxes
- Parameters:
other (Box) – The other bounding box in the union
- Returns:
result – The smallest rectangular box that contains both boxes.
- Return type:
Box
- property bounds#
Bounds of the box
- property center#
Tuple of center coordinates
- static from_bounds(*bounds)[source]#
Initialize a box from its bounds
- Parameters:
bounds (
tupleof(min,max) pairs) – Min/Max coordinate for every dimension- Returns:
bbox – A new box bounded by the input bounds.
- Return type:
- static from_data(X, min_value=0)[source]#
Define box where X is above min_value
- Parameters:
X (
jnp.ndarray) – Data to thresholdmin_value (
float) – Minimum value of the result.
- Returns:
bbox – Bounding box for the thresholded X
- Return type:
- origin: tuple#
lower-left corner) of the array in model frame
- Type:
Start coordinate (in 2D
- shape: tuple#
Size of the array
- property slices#
Bounds of the box as slices
- property spatial#
Spatial component of higher-dimensional box
- property start#
Tuple of start coordinates
- property stop#
Tuple of stop coordinates