Args: keys: keys of the corresponding items to be transformed. See also: :py:class:`monai.transforms.compose.MapTransform` spatial_border: specified size for every spatial border. it can be 3 shapes: - single int number, pad all the b
(
self,
keys: KeysCollection,
spatial_border: Sequence[int] | int,
mode: SequenceStr = PytorchPadMode.CONSTANT,
allow_missing_keys: bool = False,
lazy: bool = False,
**kwargs,
)
| 237 | backend = BorderPad.backend |
| 238 | |
| 239 | def __init__( |
| 240 | self, |
| 241 | keys: KeysCollection, |
| 242 | spatial_border: Sequence[int] | int, |
| 243 | mode: SequenceStr = PytorchPadMode.CONSTANT, |
| 244 | allow_missing_keys: bool = False, |
| 245 | lazy: bool = False, |
| 246 | **kwargs, |
| 247 | ) -> None: |
| 248 | """ |
| 249 | Args: |
| 250 | keys: keys of the corresponding items to be transformed. |
| 251 | See also: :py:class:`monai.transforms.compose.MapTransform` |
| 252 | spatial_border: specified size for every spatial border. it can be 3 shapes: |
| 253 | |
| 254 | - single int number, pad all the borders with the same size. |
| 255 | - length equals the length of image shape, pad every spatial dimension separately. |
| 256 | for example, image shape(CHW) is [1, 4, 4], spatial_border is [2, 1], |
| 257 | pad every border of H dim with 2, pad every border of W dim with 1, result shape is [1, 8, 6]. |
| 258 | - length equals 2 x (length of image shape), pad every border of every dimension separately. |
| 259 | for example, image shape(CHW) is [1, 4, 4], spatial_border is [1, 2, 3, 4], pad top of H dim with 1, |
| 260 | pad bottom of H dim with 2, pad left of W dim with 3, pad right of W dim with 4. |
| 261 | the result shape is [1, 7, 11]. |
| 262 | |
| 263 | mode: available modes for numpy array:{``"constant"``, ``"edge"``, ``"linear_ramp"``, ``"maximum"``, |
| 264 | ``"mean"``, ``"median"``, ``"minimum"``, ``"reflect"``, ``"symmetric"``, ``"wrap"``, ``"empty"``} |
| 265 | available modes for PyTorch Tensor: {``"constant"``, ``"reflect"``, ``"replicate"``, ``"circular"``}. |
| 266 | One of the listed string values or a user supplied function. Defaults to ``"constant"``. |
| 267 | See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html |
| 268 | https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html |
| 269 | It also can be a sequence of string, each element corresponds to a key in ``keys``. |
| 270 | allow_missing_keys: don't raise exception if key is missing. |
| 271 | lazy: a flag to indicate whether this transform should execute lazily or not. Defaults to False. |
| 272 | kwargs: other arguments for the `np.pad` or `torch.pad` function. |
| 273 | note that `np.pad` treats channel dimension as the first dimension. |
| 274 | |
| 275 | """ |
| 276 | padder = BorderPad(spatial_border=spatial_border, lazy=lazy, **kwargs) |
| 277 | Padd.__init__(self, keys, padder=padder, mode=mode, allow_missing_keys=allow_missing_keys, lazy=lazy) |
| 278 | |
| 279 | |
| 280 | class DivisiblePadd(Padd): |