Converts points to an axis-aligned bounding box. Args: points: Points representing the corners of the bounding box. Shape (N, 8, 3) for the 8 corners of a 3D cuboid or (N, 4, 2) for the 4 corners of a 2D rectangle.
(points)
| 706 | |
| 707 | |
| 708 | def convert_points_to_box(points): |
| 709 | """ |
| 710 | Converts points to an axis-aligned bounding box. |
| 711 | |
| 712 | Args: |
| 713 | points: Points representing the corners of the bounding box. Shape (N, 8, 3) for the 8 corners of |
| 714 | a 3D cuboid or (N, 4, 2) for the 4 corners of a 2D rectangle. |
| 715 | """ |
| 716 | from monai.transforms.utils_pytorch_numpy_unification import max, min |
| 717 | |
| 718 | mins = min(points, dim=1) |
| 719 | maxs = max(points, dim=1) |
| 720 | # Concatenate the min and max values to get the bounding boxes |
| 721 | bboxes = concatenate([mins, maxs], axis=1) |
| 722 | |
| 723 | return bboxes |
no test coverage detected
searching dependent graphs…