This function that return a :class:`~monai.data.box_utils.BoxMode` object giving a representation of box mode Args: mode: a representation of box mode. If it is not given, this func will assume it is ``StandardMode()``. Note: ``StandardMode`` = :class:`~monai.data.box_
(mode: str | BoxMode | type[BoxMode] | None = None, *args, **kwargs)
| 455 | |
| 456 | |
| 457 | def get_boxmode(mode: str | BoxMode | type[BoxMode] | None = None, *args, **kwargs) -> BoxMode: |
| 458 | """ |
| 459 | This function that return a :class:`~monai.data.box_utils.BoxMode` object giving a representation of box mode |
| 460 | |
| 461 | Args: |
| 462 | mode: a representation of box mode. If it is not given, this func will assume it is ``StandardMode()``. |
| 463 | |
| 464 | Note: |
| 465 | ``StandardMode`` = :class:`~monai.data.box_utils.CornerCornerModeTypeA`, |
| 466 | also represented as "xyxy" for 2D and "xyzxyz" for 3D. |
| 467 | |
| 468 | mode can be: |
| 469 | #. str: choose from :class:`~monai.utils.enums.BoxModeName`, for example, |
| 470 | - "xyxy": boxes has format [xmin, ymin, xmax, ymax] |
| 471 | - "xyzxyz": boxes has format [xmin, ymin, zmin, xmax, ymax, zmax] |
| 472 | - "xxyy": boxes has format [xmin, xmax, ymin, ymax] |
| 473 | - "xxyyzz": boxes has format [xmin, xmax, ymin, ymax, zmin, zmax] |
| 474 | - "xyxyzz": boxes has format [xmin, ymin, xmax, ymax, zmin, zmax] |
| 475 | - "xywh": boxes has format [xmin, ymin, xsize, ysize] |
| 476 | - "xyzwhd": boxes has format [xmin, ymin, zmin, xsize, ysize, zsize] |
| 477 | - "ccwh": boxes has format [xcenter, ycenter, xsize, ysize] |
| 478 | - "cccwhd": boxes has format [xcenter, ycenter, zcenter, xsize, ysize, zsize] |
| 479 | #. BoxMode class: choose from the subclasses of :class:`~monai.data.box_utils.BoxMode`, for example, |
| 480 | - CornerCornerModeTypeA: equivalent to "xyxy" or "xyzxyz" |
| 481 | - CornerCornerModeTypeB: equivalent to "xxyy" or "xxyyzz" |
| 482 | - CornerCornerModeTypeC: equivalent to "xyxy" or "xyxyzz" |
| 483 | - CornerSizeMode: equivalent to "xywh" or "xyzwhd" |
| 484 | - CenterSizeMode: equivalent to "ccwh" or "cccwhd" |
| 485 | #. BoxMode object: choose from the subclasses of :class:`~monai.data.box_utils.BoxMode`, for example, |
| 486 | - CornerCornerModeTypeA(): equivalent to "xyxy" or "xyzxyz" |
| 487 | - CornerCornerModeTypeB(): equivalent to "xxyy" or "xxyyzz" |
| 488 | - CornerCornerModeTypeC(): equivalent to "xyxy" or "xyxyzz" |
| 489 | - CornerSizeMode(): equivalent to "xywh" or "xyzwhd" |
| 490 | - CenterSizeMode(): equivalent to "ccwh" or "cccwhd" |
| 491 | #. None: will assume mode is ``StandardMode()`` |
| 492 | |
| 493 | Returns: |
| 494 | BoxMode object |
| 495 | |
| 496 | Example: |
| 497 | .. code-block:: python |
| 498 | |
| 499 | mode = "xyzxyz" |
| 500 | get_boxmode(mode) # will return CornerCornerModeTypeA() |
| 501 | """ |
| 502 | if isinstance(mode, BoxMode): |
| 503 | return mode |
| 504 | |
| 505 | if inspect.isclass(mode) and issubclass(mode, BoxMode): |
| 506 | return mode(*args, **kwargs) |
| 507 | |
| 508 | if isinstance(mode, str): |
| 509 | for m in SUPPORTED_MODES: |
| 510 | for n in SUPPORTED_SPATIAL_DIMS: |
| 511 | if inspect.isclass(m) and issubclass(m, BoxMode) and m.get_name(n) == mode: |
| 512 | return m(*args, **kwargs) |
| 513 | |
| 514 | if mode is not None: |
no test coverage detected
searching dependent graphs…