The affine transformations are applied in rotate, shear, translate, scale order. Args: rotate_params: a rotation angle in radians, a scalar for 2D image, a tuple of 3 floats for 3D. Defaults to no rotation. shear_params: shearing factors for
(
self,
rotate_params: Sequence[float] | float | None = None,
shear_params: Sequence[float] | float | None = None,
translate_params: Sequence[float] | float | None = None,
scale_params: Sequence[float] | float | None = None,
affine: NdarrayOrTensor | None = None,
spatial_size: Sequence[int] | int | None = None,
mode: str | int = GridSampleMode.BILINEAR,
padding_mode: str = GridSamplePadMode.REFLECTION,
normalized: bool = False,
device: torch.device | None = None,
dtype: DtypeLike = np.float32,
align_corners: bool = False,
image_only: bool = False,
lazy: bool = False,
)
| 2188 | backend = list(set(AffineGrid.backend) & set(Resample.backend)) |
| 2189 | |
| 2190 | def __init__( |
| 2191 | self, |
| 2192 | rotate_params: Sequence[float] | float | None = None, |
| 2193 | shear_params: Sequence[float] | float | None = None, |
| 2194 | translate_params: Sequence[float] | float | None = None, |
| 2195 | scale_params: Sequence[float] | float | None = None, |
| 2196 | affine: NdarrayOrTensor | None = None, |
| 2197 | spatial_size: Sequence[int] | int | None = None, |
| 2198 | mode: str | int = GridSampleMode.BILINEAR, |
| 2199 | padding_mode: str = GridSamplePadMode.REFLECTION, |
| 2200 | normalized: bool = False, |
| 2201 | device: torch.device | None = None, |
| 2202 | dtype: DtypeLike = np.float32, |
| 2203 | align_corners: bool = False, |
| 2204 | image_only: bool = False, |
| 2205 | lazy: bool = False, |
| 2206 | ) -> None: |
| 2207 | """ |
| 2208 | The affine transformations are applied in rotate, shear, translate, scale order. |
| 2209 | |
| 2210 | Args: |
| 2211 | rotate_params: a rotation angle in radians, a scalar for 2D image, a tuple of 3 floats for 3D. |
| 2212 | Defaults to no rotation. |
| 2213 | shear_params: shearing factors for affine matrix, take a 3D affine as example:: |
| 2214 | |
| 2215 | [ |
| 2216 | [1.0, params[0], params[1], 0.0], |
| 2217 | [params[2], 1.0, params[3], 0.0], |
| 2218 | [params[4], params[5], 1.0, 0.0], |
| 2219 | [0.0, 0.0, 0.0, 1.0], |
| 2220 | ] |
| 2221 | |
| 2222 | a tuple of 2 floats for 2D, a tuple of 6 floats for 3D. Defaults to no shearing. |
| 2223 | translate_params: a tuple of 2 floats for 2D, a tuple of 3 floats for 3D. Translation is in |
| 2224 | pixel/voxel relative to the center of the input image. Defaults to no translation. |
| 2225 | scale_params: scale factor for every spatial dims. a tuple of 2 floats for 2D, |
| 2226 | a tuple of 3 floats for 3D. Defaults to `1.0`. |
| 2227 | affine: If applied, ignore the params (`rotate_params`, etc.) and use the |
| 2228 | supplied matrix. Should be square with each side = num of image spatial |
| 2229 | dimensions + 1. |
| 2230 | spatial_size: output image spatial size. |
| 2231 | if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1, |
| 2232 | the transform will use the spatial size of `img`. |
| 2233 | if some components of the `spatial_size` are non-positive values, the transform will use the |
| 2234 | corresponding components of img size. For example, `spatial_size=(32, -1)` will be adapted |
| 2235 | to `(32, 64)` if the second spatial dimension size of img is `64`. |
| 2236 | mode: {``"bilinear"``, ``"nearest"``} or spline interpolation order 0-5 (integers). |
| 2237 | Interpolation mode to calculate output values. Defaults to ``"bilinear"``. |
| 2238 | See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html |
| 2239 | When it's an integer, the numpy (cpu tensor)/cupy (cuda tensor) backends will be used |
| 2240 | and the value represents the order of the spline interpolation. |
| 2241 | See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.map_coordinates.html |
| 2242 | padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} |
| 2243 | Padding mode for outside grid values. Defaults to ``"reflection"``. |
| 2244 | See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html |
| 2245 | When `mode` is an integer, using numpy/cupy backends, this argument accepts |
| 2246 | {'reflect', 'grid-mirror', 'constant', 'grid-constant', 'nearest', 'mirror', 'grid-wrap', 'wrap'}. |
| 2247 | See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.map_coordinates.html |
nothing calls this directly
no test coverage detected