calc_bbox_corners_from_center - jaybgager/tracertools GitHub Wiki
Calculates the corner point coordinates of a bounding box using specified dimensions and a center point. Useful for generating fixed-size boxes centered on manually-chosen points of interest.
Arguments:
center_point(list of 3 integers, mandatory)- point coordinates in voxels for the center of the bounding box (e.g. [1,2,3])
dims(list of 3 integers, mandatory)- the dimensions of the bounding box in voxels
- if odd numbers are passed, they'll be increased by 1 to maintain integer measurements
Returns:
corners(list of 2 lists of 3 integers)- coordinates of the corner points as
[Xmin,Ymin,Zmin],[Xmax,Ymax,Zmax](/jaybgager/tracertools/wiki/Xmin,Ymin,Zmin],[Xmax,Ymax,Zmax)
- coordinates of the corner points as
Examples
Let's say we wanted to make a 3000x3000x200 voxel bounding box around the T2 Blowout swamp in the brain_and_nerve_cord dataset, centered on the point [102037, 179634, 3423].
INPUT:
import tracertools as tt
bbox_corners = tt.calc_bbox_corners_from_center(
center_point = [102037, 179634, 3423],
dims = [3000,3000,200]
)
print(bbox_corners)
OUTPUT:
[100537, 178134, 3323], [103537, 181134, 3523](/jaybgager/tracertools/wiki/100537,-178134,-3323],-[103537,-181134,-3523)
If we make a bounding box using these coordinates as the corner points, it's a nice fit.