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

Function zoom_boxes

monai/apps/detection/transforms/box_ops.py:102–126  ·  view source on GitHub ↗

Zoom boxes Args: boxes: bounding boxes, Nx4 or Nx6 torch tensor or ndarray. The box mode is assumed to be StandardMode zoom: The zoom factor along the spatial axes. If a float, zoom is the same for each spatial axis. If a sequence, zoom should contai

(boxes: NdarrayTensor, zoom: Sequence[float] | float)

Source from the content-addressed store, hash-verified

100
101
102def zoom_boxes(boxes: NdarrayTensor, zoom: Sequence[float] | float) -> NdarrayTensor:
103 """
104 Zoom boxes
105
106 Args:
107 boxes: bounding boxes, Nx4 or Nx6 torch tensor or ndarray. The box mode is assumed to be StandardMode
108 zoom: The zoom factor along the spatial axes.
109 If a float, zoom is the same for each spatial axis.
110 If a sequence, zoom should contain one value for each spatial axis.
111
112 Returns:
113 zoomed boxes, with same data type as ``boxes``, does not share memory with ``boxes``
114
115 Example:
116 .. code-block:: python
117
118 boxes = torch.ones(1,4)
119 zoom_boxes(boxes, zoom=[0.5,2.2]) # will return tensor([[0.5, 2.2, 0.5, 2.2]])
120 """
121 spatial_dims = get_spatial_dims(boxes=boxes)
122
123 # generate affine transform corresponding to ``zoom``
124 affine = create_scale(spatial_dims=spatial_dims, scaling_factor=zoom)
125
126 return apply_affine_to_boxes(boxes=boxes, affine=affine)
127
128
129def resize_boxes(

Callers 2

resize_boxesFunction · 0.85
__call__Method · 0.85

Calls 3

get_spatial_dimsFunction · 0.90
create_scaleFunction · 0.90
apply_affine_to_boxesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…