def bbox(self, image_coords=True):
"""
Return a 3 by 2 matrix, corresponding to the bounding box of the
annotation within the scan. If `scan_slice` is a numpy array
containing aslice of the scan, each slice of the annotation is
contained within the box:
bbox[0,0]:bbox[0,1]+1, bbox[1,0]:bbox[1,1]+1
If `image_coords` is `False` then each annotation slice is
instead contained within:
bbox[1,0]:bbox[1,1]+1, bbox[0,0]:bbox[0,1]+1
The last row of `bbox` give the inclusive lower and upper
bounds of the `image_z_position`.
"""
matrix = self.contours_to_matrix()
bbox = np.c_[matrix.min(axis=0), matrix.max(axis=0)]
return bbox if not image_coords else bbox[[1,0,2]]
评论列表
文章目录