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.preprocessing.Resize¶
- class nidl.volume.transforms.preprocessing.Resize(target_shape, interpolation='linear', **kwargs)[source]¶
Bases:
ResampleResize a 3d volume to match a target shape.
This transformation resizes a 3d volume to a new target shape, implicitely modifying the physical spacing. Internally, it uses SimpleITK for fast and robust resampling. It handles
numpy.ndarrayortorch.Tensoras input and returns a consistent output (same type). Input shape must be
or
.- Parameters:
- target_shape: int or tuple of (int, int, int)
Output shape
. If int is given, it sets
.- 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. Methods such as bspline or lanczos produce high-quality results but are slower and best used during offline preprocessing. nearest is very fast but gives poorer results for scalar images; however, it is the default for label maps, as it preserves categorical values. For a full comparison of interpolation methods, see [1]. Descriptions of available methods:
nearest: Nearest-neighbor interpolation.
linear: Linear interpolation.
bspline: B-spline of order 3 (cubic).
cubic: Alias for bspline.
gaussian: Gaussian interpolation
.label_gaussian: Gaussian interpolation for label maps (
).hamming: Hamming-windowed sinc kernel.
cosine: Cosine-windowed sinc kernel.
welch: Welch-windowed sinc kernel.
lanczos: Lanczos-windowed sinc kernel.
blackman: Blackman-windowed sinc kernel.
- **kwargsdict
Keyword arguments given to
nidl.transforms.Transform.
References
[1]Meijering et al. (1999), “Quantitative Comparison of Sinc-Approximating Kernels for Medical Image Interpolation.”
and same type as input.