Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the user guide for the big picture.
nidl.volume.transforms.augmentation.RandomResizedCrop¶
- class nidl.volume.transforms.augmentation.RandomResizedCrop(target_shape, scale=(0.08, 1.0), ratio=(0.75, 1.33), interpolation='linear', **kwargs)[source]¶
Bases:
VolumeTransformCrop a random portion of a 3d volume and resize it.
It is a generalization of torchvision.transforms.RandomResizedCrop to the 3d case.
It handles
numpy.ndarrayortorch.Tensoras input and returns a consistent output (same type).- Parameters:
- target_shape: int or tuple of (int, int, int)
Expected output shape. If int, apply the same size across all dimensions.
- scale: tuple of (float, float), default=(0.08, 1.0)
Specifies lower and upper bounds for the random area of the crop, before resizing. The scale is defined with respect to the area of the original image.
- ratio: tuple of (float, float), default=(1.0, 1.33)
Range of the aspect ratio of the crop, before resizing.
- interpolation: str in {‘nearest’, ‘linear’, ‘bspline’, ‘cubic’, ‘gaussian’, ‘label_gaussian’, ‘hamming’, ‘cosine’, ‘welch’, ‘lanczos’, ‘blackman’}, default=’linear’
Interpolation techniques available in ITK. linear, the default in nidl for scalar images, offers a good compromise between image quality and speed and is a solid choice for data augmentation during training.
- kwargs: dict
Keyword arguments given.
Notes
In 3d, we define the “aspect ratio” as the ratio between each dimension size relatively to their geometric mean. It is a simple generalization from 2d to nd and we don’t particularize any dimension. The aspect ratio is sampled three times for a 3d volume (one for each dimension).
or
. Cropped area is the same across channels.