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

Function is_valid_box_values

monai/data/box_utils.py:723–737  ·  view source on GitHub ↗

This function checks whether the box size is non-negative. Args: boxes: bounding boxes, Nx4 or Nx6 torch tensor or ndarray. The box mode is assumed to be ``StandardMode`` Returns: whether ``boxes`` is valid

(boxes: NdarrayOrTensor)

Source from the content-addressed store, hash-verified

721
722
723def is_valid_box_values(boxes: NdarrayOrTensor) -> bool:
724 """
725 This function checks whether the box size is non-negative.
726
727 Args:
728 boxes: bounding boxes, Nx4 or Nx6 torch tensor or ndarray. The box mode is assumed to be ``StandardMode``
729
730 Returns:
731 whether ``boxes`` is valid
732 """
733 spatial_dims = get_spatial_dims(boxes=boxes)
734 for axis in range(spatial_dims):
735 if (boxes[:, spatial_dims + axis] < boxes[:, axis]).sum() > 0:
736 return False
737 return True
738
739
740def box_area(boxes: NdarrayOrTensor) -> NdarrayOrTensor:

Callers 2

encode_boxesFunction · 0.90
box_areaFunction · 0.85

Calls 1

get_spatial_dimsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…