Image cropping
crop_array_to_bounding_box(array, bounding_box)
Crop an input array to the specified bounding box.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The input array to crop. |
required |
bounding_box
|
BoundingBoxIndices
|
The bounding box, defined as slices for each dimension of the array. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: The cropped array. |
Raises:
Type | Description |
---|---|
ValueError
|
If the bounding box dimensions are incompatible with the input array. |
crop_image_to_bounding_box(image, bounding_box)
Crop an Image3D object to a specified bounding box.
This function modifies the Image3D
instance by cropping its internal
array data to the provided bounding box and returns a new instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image
|
Image3D
|
The input |
required |
bounding_box
|
BoundingBoxIndices
|
The bounding box to crop to. |
required |
Returns:
Name | Type | Description |
---|---|---|
Image3D |
T
|
A new |
get_bounding_box(mask_array, padding=1)
Get the bounding box of a binary mask array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask_array
|
ndarray
|
A binary mask array. |
required |
pad
|
int
|
How many voxels to pad the bounding box by. Defaults to 1. |
required |
Returns:
Name | Type | Description |
---|---|---|
BoundingBoxIndices |
BoundingBoxIndices
|
Tuple of slice objects defining the bounding box. |
restrict_bounding_box(small_bbox, large_bbox)
This restricts a bounding box by the domain of another bounding box. For example, when restricting an ROI bounding box to the domain of a brain bounding box.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
small_bbox
|
BoundingBoxIndices
|
The smaller bounding box. |
required |
large_bbox
|
BoundingBoxIndices
|
The larger bounding box. |
required |
Returns:
Name | Type | Description |
---|---|---|
BoundingBoxIndices |
BoundingBoxIndices
|
The restricted bounding box. |