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

Class FlipBox

monai/apps/detection/transforms/array.py:323–348  ·  view source on GitHub ↗

Reverses the box coordinates along the given spatial axis. Preserves shape. Args: spatial_axis: spatial axes along which to flip over. Default is None. The default `axis=None` will flip over all of the axes of the input array. If axis is negative it counts f

Source from the content-addressed store, hash-verified

321
322
323class FlipBox(Transform):
324 """
325 Reverses the box coordinates along the given spatial axis. Preserves shape.
326
327 Args:
328 spatial_axis: spatial axes along which to flip over. Default is None.
329 The default `axis=None` will flip over all of the axes of the input array.
330 If axis is negative it counts from the last to the first axis.
331 If axis is a tuple of ints, flipping is performed on all of the axes
332 specified in the tuple.
333
334 """
335
336 backend = [TransformBackends.TORCH, TransformBackends.NUMPY]
337
338 def __init__(self, spatial_axis: Sequence[int] | int | None = None) -> None:
339 self.spatial_axis = spatial_axis
340
341 def __call__(self, boxes: NdarrayOrTensor, spatial_size: Sequence[int] | int): # type: ignore
342 """
343 Args:
344 boxes: bounding boxes, Nx4 or Nx6 torch tensor or ndarray. The box mode is assumed to be ``StandardMode``
345 spatial_size: image spatial size.
346 """
347
348 return flip_boxes(boxes, spatial_size=spatial_size, flip_axes=self.spatial_axis)
349
350
351class ClipBoxToImage(Transform):

Callers 2

__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…