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
)
| 604 | |
| 605 | |
| 606 | def 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 | |
| 634 | def box_centers(boxes: NdarrayOrTensor) -> NdarrayOrTensor: |
searching dependent graphs…