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.
| 1295 | |
| 1296 | |
| 1297 | class 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'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 | |
| 1341 | class BoundingRectd(MapTransform): |
no outgoing calls
searching dependent graphs…