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)
| 100 | |
| 101 | |
| 102 | def 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 | |
| 129 | def resize_boxes( |
no test coverage detected
searching dependent graphs…