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

Class RandZoom

monai/transforms/spatial/array.py:1556–1701  ·  view source on GitHub ↗

Randomly zooms input arrays with given probability within given zoom range. This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic ` for more information. Args: prob: Probability of zooming. min_zoom: Min zoom factor. Can b

Source from the content-addressed store, hash-verified

1554
1555
1556class RandZoom(RandomizableTransform, InvertibleTransform, LazyTransform):
1557 """
1558 Randomly zooms input arrays with given probability within given zoom range.
1559
1560 This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic<lazy_resampling>`
1561 for more information.
1562
1563 Args:
1564 prob: Probability of zooming.
1565 min_zoom: Min zoom factor. Can be float or sequence same size as image.
1566 If a float, select a random factor from `[min_zoom, max_zoom]` then apply to all spatial dims
1567 to keep the original spatial shape ratio.
1568 If a sequence, min_zoom should contain one value for each spatial axis.
1569 If 2 values provided for 3D data, use the first value for both H & W dims to keep the same zoom ratio.
1570 max_zoom: Max zoom factor. Can be float or sequence same size as image.
1571 If a float, select a random factor from `[min_zoom, max_zoom]` then apply to all spatial dims
1572 to keep the original spatial shape ratio.
1573 If a sequence, max_zoom should contain one value for each spatial axis.
1574 If 2 values provided for 3D data, use the first value for both H & W dims to keep the same zoom ratio.
1575 mode: {``"nearest"``, ``"nearest-exact"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``}
1576 The interpolation mode. Defaults to ``"area"``.
1577 See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html
1578 padding_mode: available modes for numpy array:{``"constant"``, ``"edge"``, ``"linear_ramp"``, ``"maximum"``,
1579 ``"mean"``, ``"median"``, ``"minimum"``, ``"reflect"``, ``"symmetric"``, ``"wrap"``, ``"empty"``}
1580 available modes for PyTorch Tensor: {``"constant"``, ``"reflect"``, ``"replicate"``, ``"circular"``}.
1581 One of the listed string values or a user supplied function. Defaults to ``"constant"``.
1582 The mode to pad data after zooming.
1583 See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html
1584 https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html
1585 align_corners: This only has an effect when mode is
1586 'linear', 'bilinear', 'bicubic' or 'trilinear'. Default: None.
1587 See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html
1588 dtype: data type for resampling computation. Defaults to ``float32``.
1589 If None, use the data type of input data.
1590 keep_size: Should keep original size (pad if needed), default is True.
1591 lazy: a flag to indicate whether this transform should execute lazily or not.
1592 Defaults to False
1593 kwargs: other arguments for the `np.pad` or `torch.pad` function.
1594 note that `np.pad` treats channel dimension as the first dimension.
1595
1596 """
1597
1598 backend = Zoom.backend
1599
1600 def __init__(
1601 self,
1602 prob: float = 0.1,
1603 min_zoom: Sequence[float] | float = 0.9,
1604 max_zoom: Sequence[float] | float = 1.1,
1605 mode: str = InterpolateMode.AREA,
1606 padding_mode: str = NumpyPadMode.EDGE,
1607 align_corners: bool | None = None,
1608 dtype: DtypeLike | torch.dtype = torch.float32,
1609 keep_size: bool = True,
1610 lazy: bool = False,
1611 **kwargs,
1612 ) -> None:
1613 RandomizableTransform.__init__(self, prob)

Callers 9

__init__Method · 0.90
__init__Method · 0.90
run_training_testFunction · 0.90
test_correct_resultsMethod · 0.90
test_keep_sizeMethod · 0.90
test_invalid_inputsMethod · 0.90
test_auto_expand_3dMethod · 0.90
test_invertMethod · 0.90

Calls

no outgoing calls

Tested by 6

run_training_testFunction · 0.72
test_correct_resultsMethod · 0.72
test_keep_sizeMethod · 0.72
test_invalid_inputsMethod · 0.72
test_auto_expand_3dMethod · 0.72
test_invertMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…