bbox#
Cython code for computing per-label axis-aligned bounding boxes on integer-labelled images.
For each label l present in the input array the result contains the minimum and maximum coordinate along every axis:
result[l, axis, 0] → min coordinate
result[l, axis, 1] → max coordinate
Functions#
bbox_3d()Bounding boxes for a 3-D label image.
bbox_2d()Bounding boxes for a 2-D label image.
bbox_1d()Bounding boxes for a 1-D label image.
Notes
Label 0 is included in the output (background). The caller can
discard result[0] if the background bounding box is not needed.
The max + 1 label count may overflow for images whose maximum label
value equals the dtype maximum (e.g. 255 for uint8). This is
intentional and flagged with an inline warning.
- bbox_1d(img_)#
Compute per-label bounding boxes for a 1-D label image.
- Parameters:
img (ndarray, 1-D, integer dtype) – Label image.
Returns
- ndarray, shape
(n_labels, 1, 2), dtypeuint32 result[l, 0, 0/1]gives the min/max coordinate of label l.
- bbox_2d(img_)#
Compute per-label bounding boxes for a 2-D label image.
- Parameters:
img (ndarray, 2-D, integer dtype) – Label image.
Returns
- ndarray, shape
(n_labels, 2, 2), dtypeuint32 result[l, axis, 0/1]gives the min/max coordinate of label l along axis.
- bbox_3d(img_)#
Compute per-label bounding boxes for a 3-D label image.
- Parameters:
img (ndarray, 3-D, integer dtype) – Label image.
Returns
- ndarray, shape
(n_labels, 3, 2), dtypeuint32 result[l, axis, 0/1]gives the min/max coordinate of label l along axis.