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

Function convert_box_to_standard_mode

monai/data/box_utils.py:606–631  ·  view source on GitHub ↗

Convert given boxes to standard mode. Standard mode is "xyxy" or "xyzxyz", representing box format of [xmin, ymin, xmax, ymax] or [xmin, ymin, zmin, xmax, ymax, zmax]. Args: boxes: source bounding boxes, Nx4 or Nx6 torch tensor or ndarray. mode: source box mode. If

(
    boxes: NdarrayOrTensor, mode: str | BoxMode | type[BoxMode] | None = None
)

Source from the content-addressed store, hash-verified

604
605
606def convert_box_to_standard_mode(
607 boxes: NdarrayOrTensor, mode: str | BoxMode | type[BoxMode] | None = None
608) -> NdarrayOrTensor:
609 """
610 Convert given boxes to standard mode.
611 Standard mode is "xyxy" or "xyzxyz",
612 representing box format of [xmin, ymin, xmax, ymax] or [xmin, ymin, zmin, xmax, ymax, zmax].
613
614 Args:
615 boxes: source bounding boxes, Nx4 or Nx6 torch tensor or ndarray.
616 mode: source box mode. If it is not given, this func will assume it is ``StandardMode()``.
617 It follows the same format with ``mode`` in :func:`~monai.data.box_utils.get_boxmode`.
618
619 Returns:
620 bounding boxes with standard mode, with same data type as ``boxes``, does not share memory with ``boxes``
621
622 Example:
623 .. code-block:: python
624
625 boxes = torch.ones(10,6)
626 # The following two lines are equivalent
627 # They convert boxes with format [xmin, xmax, ymin, ymax, zmin, zmax] to [xmin, ymin, zmin, xmax, ymax, zmax]
628 convert_box_to_standard_mode(boxes=boxes, mode="xxyyzz")
629 convert_box_mode(boxes=boxes, src_mode="xxyyzz", dst_mode="xyzxyz")
630 """
631 return convert_box_mode(boxes=boxes, src_mode=mode, dst_mode=StandardMode())
632
633
634def box_centers(boxes: NdarrayOrTensor) -> NdarrayOrTensor:

Callers 3

__call__Method · 0.90
test_valueMethod · 0.90

Calls 1

convert_box_modeFunction · 0.85

Tested by 2

test_valueMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…