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

Class ResizeWithPadOrCropd

monai/transforms/croppad/dictionary.py:1297–1338  ·  view source on GitHub ↗

Dictionary-based wrapper of :py:class:`monai.transforms.ResizeWithPadOrCrop`. This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic ` for more information. Args: keys: keys of the corresponding items to be transformed.

Source from the content-addressed store, hash-verified

1295
1296
1297class ResizeWithPadOrCropd(Padd):
1298 """
1299 Dictionary-based wrapper of :py:class:`monai.transforms.ResizeWithPadOrCrop`.
1300
1301 This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic<lazy_resampling>`
1302 for more information.
1303
1304 Args:
1305 keys: keys of the corresponding items to be transformed.
1306 See also: monai.transforms.MapTransform
1307 spatial_size: the spatial size of output data after padding or crop.
1308 If has non-positive values, the corresponding size of input image will be used (no padding).
1309 mode: available modes for numpy array:{``"constant"``, ``"edge"``, ``"linear_ramp"``, ``"maximum"``,
1310 ``"mean"``, ``"median"``, ``"minimum"``, ``"reflect"``, ``"symmetric"``, ``"wrap"``, ``"empty"``}
1311 available modes for PyTorch Tensor: {``"constant"``, ``"reflect"``, ``"replicate"``, ``"circular"``}.
1312 One of the listed string values or a user supplied function. Defaults to ``"constant"``.
1313 See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html
1314 https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html
1315 It also can be a sequence of string, each element corresponds to a key in ``keys``.
1316 allow_missing_keys: don&#x27;t raise exception if key is missing.
1317 method: {``"symmetric"``, ``"end"``}
1318 Pad image symmetrically on every side or only pad at the end sides. Defaults to ``"symmetric"``.
1319 lazy: a flag to indicate whether this transform should execute lazily or not. Defaults to False.
1320 pad_kwargs: other arguments for the `np.pad` or `torch.pad` function.
1321 note that `np.pad` treats channel dimension as the first dimension.
1322
1323 """
1324
1325 def __init__(
1326 self,
1327 keys: KeysCollection,
1328 spatial_size: Sequence[int] | int,
1329 mode: SequenceStr = PytorchPadMode.CONSTANT,
1330 allow_missing_keys: bool = False,
1331 method: str = Method.SYMMETRIC,
1332 lazy: bool = False,
1333 **pad_kwargs,
1334 ) -> None:
1335 padcropper = ResizeWithPadOrCrop(spatial_size=spatial_size, method=method, **pad_kwargs, lazy=lazy)
1336 super().__init__(
1337 keys, padder=padcropper, mode=mode, allow_missing_keys=allow_missing_keys, lazy=lazy # type: ignore
1338 )
1339
1340
1341class BoundingRectd(MapTransform):

Callers 6

test_pad_shapeMethod · 0.90
test_pending_opsMethod · 0.90
test_collationMethod · 0.90
test_inverse.pyFile · 0.90
test_failMethod · 0.90
test_invertMethod · 0.90

Calls

no outgoing calls

Tested by 5

test_pad_shapeMethod · 0.72
test_pending_opsMethod · 0.72
test_collationMethod · 0.72
test_failMethod · 0.72
test_invertMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…