MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / box_centers

Function box_centers

monai/data/box_utils.py:634–646  ·  view source on GitHub ↗

Compute center points of boxes Args: boxes: bounding boxes, Nx4 or Nx6 torch tensor or ndarray. The box mode is assumed to be ``StandardMode`` Returns: center points with size of (N, spatial_dims)

(boxes: NdarrayOrTensor)

Source from the content-addressed store, hash-verified

632
633
634def box_centers(boxes: NdarrayOrTensor) -> NdarrayOrTensor:
635 """
636 Compute center points of boxes
637
638 Args:
639 boxes: bounding boxes, Nx4 or Nx6 torch tensor or ndarray. The box mode is assumed to be ``StandardMode``
640
641 Returns:
642 center points with size of (N, spatial_dims)
643
644 """
645 spatial_dims = get_spatial_dims(boxes=boxes)
646 return convert_box_mode(boxes=boxes, src_mode=StandardMode, dst_mode=CenterSizeMode)[:, :spatial_dims]
647
648
649def centers_in_boxes(centers: NdarrayOrTensor, boxes: NdarrayOrTensor, eps: float = 0.01) -> NdarrayOrTensor:

Callers 2

test_valueMethod · 0.90
boxes_center_distanceFunction · 0.85

Calls 2

get_spatial_dimsFunction · 0.85
convert_box_modeFunction · 0.85

Tested by 1

test_valueMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…